When i do a copy rates with start index=0, count=2, then rates[1] seems to be the latest bar as i tested by a small script.
This is the contrary to what i read in the MQL5 Help:
"The elements ordering of the copied data is from present to the past, i.e., starting position of 0 means the current bar."
According my test, the current bar is stored in 1 not in 0.
Can anyone confirm this ?
Hello chinaski,
if you want your array to be copied from present to the past, you have to explicitly use
ArraySetAsSeries(rates,true);
When i do a copy rates with start index=0, count=2, then rates[1] seems to be the latest bar as i tested by a small script.
This is the contrary to what i read in the MQL5 Help:
"The elements ordering of the copied data is from present to the past, i.e., starting position of 0 means the current bar."
According my test, the current bar is stored in 1 not in 0.
Can anyone confirm this ?
It's exactly what is described in MQL5 documentation.
Your problem comes from the indexation of your result array, as Malacarne said you.
Hello Angevoyageur,
don't understand this.
From Doc:
"The elements ordering of the copied data is from present to the past, i.e., starting position of 0 means the current bar."
So according what Documentation says: 0 in the target array (ordering of the copied data) is current bar but it is NOT.
1 is the index of the current bar.
So, i mean, without using
ArraySetAsSeries
it should carry the current bar in index=0 and not in index=1.
Hello Angevoyageur,
don't understand this.
From Doc:
"The elements ordering of the copied data is from present to the past, i.e., starting position of 0 means the current bar."
So according what Documentation says: 0 in the target array (ordering of the copied data) is current bar but it is NOT.
1 is the index of the current bar.
So, i mean, without using
it should carry the current bar in index=0 and not in index=1.
Hello chinaski,
you are copying 2 bars of data. In this case, the standard indexation of bars in C++ (and MQL5) is to set 0 as the oldest bar and 1 as the current bar.
If you want to invert the indexation, you have to use
ArraySetAsSeries(rates,true);
After doing that, the MT5 terminal will interprete 0 as the current and, of course, 1 as he oldest bar.
Hello Angevoyageur,
don't understand this.
From Doc:
"The elements ordering of the copied data is from present to the past, i.e., starting position of 0 means the current bar."
So according what Documentation says: 0 in the target array (ordering of the copied data) is current bar but it is NOT.
1 is the index of the current bar.
So, i mean, without using
it should carry the current bar in index=0 and not in index=1.
You misunderstood the documentation. It means the source data are always copied from present to past, BUT you are accessing the target array and there it depends of the indexation. See explanation of Malacarne above.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
When i do a copy rates with start index=0, count=2, then rates[1] seems to be the latest bar as i tested by a small script.
This is the contrary to what i read in the MQL5 Help:
"The elements ordering of the copied data is from present to the past, i.e., starting position of 0 means the current bar."
According my test, the current bar is stored in 1 not in 0.
Can anyone confirm this ?