Download MetaTrader 5

using icustom without knowing how many candles back to get buffer output

To add comments, please log in or register
Brian Kester
823
Brian Kester  

Hi, I am a new programmer. I have read the book and documentation.  I have been searching my question on icustom.

How can i find the last signal produced by my custom indicator without knowing how many bars back the last one appeared?

The indicator paints a line, and may not have painted again since some number of bars back, so i cant put in a shift of "1" or "2" in icustom, because the last line draw could be any number of bars back.

 

should I use an operator loop to check each bar back to find the last signal? assign the signal to a global variable and then break the loop and use that global variable as my "last signal"?

 

Thank you.

whroeder1
16086
whroeder1  
c3po: should I use an operator loop to check each bar back to find the last signal? assign the signal to a global variable and then break the loop and use that global variable as my "last signal"?
No need for the global variable
int iLastSig=0; for(; iLastSig < Bars; iLastSig++)
  if( iCustom(..., iLastSig) != EMPTY_VALUE) break;
Print("last signal on bar "+iLastSig);
Brian Kester
823
Brian Kester  

thanks WHRoeder. You are great! 

To add comments, please log in or register