Download MetaTrader 5
To add comments, please log in or register
No time to learn MQL5? Order your application from a developer!
chinaski 2012.06.27 19:33 


i am looking for a smart method to detect bar change within Indicator. Unfortunately, this seems to be an extra science (don't know what's the problem to give each bar a unique index...??)

However, my idea was to use OnCalculate time[] parameter for this.

On each call, i do a print of  time[0] and this always returns the same time 1999.04.23 00:00:00  - except for latest live ticking bar.

So the timevalues for bar of the past (e.g. when attaching indicator to chart) are all the same 999.04.23 00:00:00.


Anyone know why ?

Thank you 

chinaski 2012.06.27 22:40  

Ah, the problem is that onCalculate seems only to be applied for new bars.

How to check an indicator (not Expert) against bars in the past ? 

Biantoro Kunarto
Biantoro Kunarto 2012.06.28 02:30  

If you using OnCalculate event In the indicator, time[0] refers to first bar not the last bar. If you want to check the last bar you can use :
int bars=Bars(_Symbol,_Period);
To add comments, please log in or register