- It is up to you. Would you rather think of the chart [oldest … newest] as [0 … ratesTotal-1] (non-series/previous is i-1) or [ratesTotal-1 … 0] (as-series/previous is i+1).
- Set all your arrays and buffers per № 1.
- Doesn't matter.
- The latest bar is not zero. It is up to you. See № 1.
- You are confused, because there are two ways and it is up to you.
How to do your lookbacks correctly #9 - #14 & #19
William Roeder:
- It is up to you. Would you rather think of the chart [oldest … newest] as [0 … ratesTotal-1] (non-series/previous is i-1) or [ratesTotal-1 … 0] (as-series/previous is i+1).
- Set all your arrays and buffers per № 1.
- Doesn't matter.
- The latest bar is not zero. It is up to you. See № 1.
- You are confused, because there are two ways and it is up to you.
How to do your lookbacks correctly #9 - #14 & #19
Thank you so much William that really cleared everything up. Highly appreciating your help.

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
Hello Folks,
I have several issues as a newbie in mql5:
1- problem understanding how loops work and how to access the latest bar and the bars before it (is the index of the previous bar i+1 or i-1 how to decide),
2-does SetAsArray function affects how the loop works also are the user defined arrays and indicator buffers timeseries or normal arrays
3- if I want to code lets say moving average is it better to start from the oldest bar to the newest or it doesn't matter
As far as I understand that the latest bar index is set to 0 and the oldest bar index is rates total-1 however when I try to print out this it comes the other way around (the latest bar index is rates total-1 and the oldest bar index is 0)
I've read this topic but it made me more confused actually http: Range not behaving as expected - Heiken Ashi - MQL4 and MetaTrader 4 - MQL4 programming forum (mql5.com)
Sorry for being long but I'm new to mql5 and help is truly appreciated
Regards.