Indicator freezes on start of new bar - page 2

 

In MQL4, the latest data number is 0, but in MQL5, it's the oldest one.

You should consider that point to get a correct result.

The first your program doesn't work correctly because it's for MQL5.


Regarding "for" statement, usually the same result is obtained in either direction, but in rare cases, it can not be calculated in the opposite direction.

I think this is an example.

Reason: