There is nothing wrong. Index 0 is the OLDEST bar, not the current one, as the arrays are not indexed as series by default in MT5.
In MT5, you must set the direction.
To define the indexing direction in the time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[] arrays, call the ArrayGetAsSeries() function. In order not to depend on defaults, call the ArraySetAsSeries() function for the arrays to work with.
Event Handling / OnCalculate - Reference on algorithmic/automated trading language for MetaTrader 5
Event Handling / OnCalculate - Reference on algorithmic/automated trading language for MetaTrader 5

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I was getting wrong values in OnCalculate() method in my custom indicator.
Here is a test indicator just logging the values.
and the log output is:
as it can be seen, the prices are not correct and not even near to the current market price.
I've test with other charts and the values are not the same but they are wrong too.
Any help would be appreciated.
Regards,