indice of TimeHour()

To add comments, please log in or register
paul selvan
629
paul selvan  

Hello 

I meet  problem with  indice of TimeHour()

When the indice is a constant  like :

int t = TimeHour(Time[2]);
  
Comment(t);

TimeHour of indice 2 is properly displayed.

-------------------------------------------------------------------------------------------------------------------------------+

But with its indice is a variable :

int counted_bars = IndicatorCounted();
if (counted_bars <0) return(-1);
if (counted_bars > 0) counted_bars--;
int limit = Bars - counted_bars;
  
int t = TimeHour(Time[limit]);
 
Comment(t);

When  integer variable limit - function of Bars or IndicatorCounted() - is indice of function TimeHour() why nothing is displayed by  Comment(t) ?

Thank you

William Roeder
20207
William Roeder  
paulselvan: why nothing is displayed by  Comment(t) ?

Because your indicator crashed. When counted_bars is zero, limit equals Bars, and Time[Bars] does not exist.

Start using the new Event Handling Functions.
          Event Handling Functions - Functions - Language Basics - MQL4 Reference

See How to do your lookbacks correctly.

No need for the decrement. Contradictory information on IndicatorCounted() - MQL4 and MetaTrader 4 - MQL4 programming forum

paul selvan
629
paul selvan  
thank you for the info
To add comments, please log in or register