Download MetaTrader 5

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

To add comments, please log in or register
Do you know that MQL5 can create custom graphical tools?
Brian Kester
818
Brian Kester 2014.06.04 12:23 

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
14472
whroeder1 2014.06.04 15:56  
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
818
Brian Kester 2014.06.04 17:08  

thanks WHRoeder. You are great! 

To add comments, please log in or register