Disliked{quote}...What I want to achieve is a way for open orders in a skipping manner...indicator sends a buy signal...the next ...signals ...are not executed...Ignored
Inserted Code
string get_signal_with_skipping() { //skip every x signals int count_skip = 3; //count how many signals occur per bar static int count_signal_buy; //set the signal count to 0 on a new bar if(new_candle())count_signal_buy=0; //get a signal bool signal_buy = something from icustom; //if the signal is a buy if(signal_buy==true){ //increase the count of buy signals by 1 count_signal_buy++; //accept the first or every 3rd signal from the first, #1, #4, #7 etc if(count_signal_buy==1 || MathMod(count_signal_buy-1,count_skip)==0){ return("buy"); } } //if a valid buy signal hasnt been returned above, then return some na value return("na"); }
Or to accept new signals when they're at least x seconds apart, would be something like:
Inserted Code
string get_signal_with_time_gap() { //minimum time gap, seconds int t_gap_sec = 5; //save last signal time static long t_last_signal; //get a signal bool signal_buy = something from icustom; //if the signal is a buy if(signal_buy==true){ //server time for comparing to last tick time long t_check = TimeCurrent(); //if time difference is more or equal to the gap if(t_check-t_last_signal>=t_gap_sec){ //update the last time for the next check t_last_signal = t_check; return("buy"); } } //if a valid buy signal hasnt been returned above, then return some na value return("na"); }
1