Please, read the docs:
Indexing goes from the past to the present meaning that a tick with the index 0 is the oldest one in the array.
To get the latest tick you need latest[n - 1].
- www.mql5.com
If you looked closely, you would find that I'm only expecting 1 index as a return so using latest[n - 1] yielded the same behavior I was talking about.
You did not post exact log which you got after running this script, this is why I'm not sure it works as you said. For example, CopyTicksRange for 1 ms may return many ticks. To see timing could be also important.
You did not post exact log which you got after running this script, this is why I'm not sure it works as you said. For example, CopyTicksRange for 1 ms may return many ticks. To see timing could be also important.
2026.07.20 18:17:09.061 Testing (EURUSD,H1) ==================================================== 2026.07.20 18:17:09.062 Testing (EURUSD,H1) SymbolInfoTick 2026.07.20 18:17:09.062 Testing (EURUSD,H1) time_msc=1784571428897 2026.07.20 18:17:09.062 Testing (EURUSD,H1) time=2026.07.20 18:17:08 2026.07.20 18:17:09.062 Testing (EURUSD,H1) bid=1.1406600000 2026.07.20 18:17:09.062 Testing (EURUSD,H1) ask=1.1407500000 2026.07.20 18:17:09.062 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.062 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.062 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.062 Testing (EURUSD,H1) spread=9 points 2026.07.20 18:17:09.062 Testing (EURUSD,H1) CopyTicks 2026.07.20 18:17:09.062 Testing (EURUSD,H1) time_msc=1784571428897 2026.07.20 18:17:09.062 Testing (EURUSD,H1) time=2026.07.20 18:17:08 2026.07.20 18:17:09.062 Testing (EURUSD,H1) bid=1.1407100000 2026.07.20 18:17:09.062 Testing (EURUSD,H1) ask=1.1407100000 2026.07.20 18:17:09.062 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.062 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.062 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.062 Testing (EURUSD,H1) spread=0 points 2026.07.20 18:17:09.062 Testing (EURUSD,H1) CopyTicksRange 2026.07.20 18:17:09.062 Testing (EURUSD,H1) time_msc=1784571428897 2026.07.20 18:17:09.062 Testing (EURUSD,H1) time=2026.07.20 18:17:08 2026.07.20 18:17:09.062 Testing (EURUSD,H1) bid=1.1407100000 2026.07.20 18:17:09.062 Testing (EURUSD,H1) ask=1.1407100000 2026.07.20 18:17:09.062 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.062 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.062 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.062 Testing (EURUSD,H1) spread=0 points 2026.07.20 18:17:09.062 Testing (EURUSD,H1) ==================================================== 2026.07.20 18:17:09.338 Testing (EURUSD,H1) ==================================================== 2026.07.20 18:17:09.338 Testing (EURUSD,H1) SymbolInfoTick 2026.07.20 18:17:09.338 Testing (EURUSD,H1) time_msc=1784571429400 2026.07.20 18:17:09.338 Testing (EURUSD,H1) time=2026.07.20 18:17:09 2026.07.20 18:17:09.338 Testing (EURUSD,H1) bid=1.1406500000 2026.07.20 18:17:09.338 Testing (EURUSD,H1) ask=1.1407400000 2026.07.20 18:17:09.338 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.338 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.338 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.338 Testing (EURUSD,H1) spread=9 points 2026.07.20 18:17:09.338 Testing (EURUSD,H1) CopyTicks 2026.07.20 18:17:09.338 Testing (EURUSD,H1) time_msc=1784571429400 2026.07.20 18:17:09.338 Testing (EURUSD,H1) time=2026.07.20 18:17:09 2026.07.20 18:17:09.338 Testing (EURUSD,H1) bid=1.1407000000 2026.07.20 18:17:09.338 Testing (EURUSD,H1) ask=1.1407000000 2026.07.20 18:17:09.338 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.338 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.338 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.338 Testing (EURUSD,H1) spread=0 points 2026.07.20 18:17:09.338 Testing (EURUSD,H1) CopyTicksRange 2026.07.20 18:17:09.338 Testing (EURUSD,H1) time_msc=1784571429400 2026.07.20 18:17:09.338 Testing (EURUSD,H1) time=2026.07.20 18:17:09 2026.07.20 18:17:09.338 Testing (EURUSD,H1) bid=1.1407000000 2026.07.20 18:17:09.338 Testing (EURUSD,H1) ask=1.1407000000 2026.07.20 18:17:09.338 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.338 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.338 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.338 Testing (EURUSD,H1) spread=0 points 2026.07.20 18:17:09.338 Testing (EURUSD,H1) ==================================================== 2026.07.20 18:17:09.444 Testing (EURUSD,H1) ==================================================== 2026.07.20 18:17:09.444 Testing (EURUSD,H1) SymbolInfoTick 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time_msc=1784571429525 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time=2026.07.20 18:17:09 2026.07.20 18:17:09.444 Testing (EURUSD,H1) bid=1.1406400000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) ask=1.1407300000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.444 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.444 Testing (EURUSD,H1) spread=9 points 2026.07.20 18:17:09.444 Testing (EURUSD,H1) CopyTicks 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time_msc=1784571429525 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time=2026.07.20 18:17:09 2026.07.20 18:17:09.444 Testing (EURUSD,H1) bid=1.1406900000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) ask=1.1406900000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.444 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.444 Testing (EURUSD,H1) spread=0 points 2026.07.20 18:17:09.444 Testing (EURUSD,H1) CopyTicksRange 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time_msc=1784571429525 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time=2026.07.20 18:17:09 2026.07.20 18:17:09.444 Testing (EURUSD,H1) bid=1.1406900000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) ask=1.1406900000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.444 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.444 Testing (EURUSD,H1) spread=0 points 2026.07.20 18:17:09.444 Testing (EURUSD,H1) ====================================================
OnTick() can be triggered after a batch of ticks. In such case, you can have different values.
All is normal.
OnTick() can be triggered after a batch of ticks. In such case, you can have different values.
All is normal.
What made me write this simple script in the first place is to investigate after I have used the python API using CopyTicksRange gave me near results where the spread and ticks are not consistent alongside the same call using SymbolInfoTick from also the python API. it's like the saved data retrieved from CopyTicksRange comes from a different feed.
Ticks can come fast (several in same milliseconds). OnTick is not necessary called for each of them individually.
So within OnTick(), if you check like you did (SymbolInfoTick versus index 0 of CopyTicks/Range) you can have different ticks. Get and check ALL the ticks, not 1 (count), or 1 ms.
Also you should check according to your last check (OnTick) as using SymbolInfoTick timemsc as reference will not necessarily give you the first tick in the batch.
Using Python API should not change this behaviour.
Ticks can come fast (several in same milliseconds). OnTick is not necessary called for each of them individually.
So within OnTick(), if you check like you did (SymbolInfoTick versus index 0 of CopyTicks/Range) you can have different ticks. Get and check ALL the ticks, not 1 (count), or 1 ms.
Also you should check according to your last check (OnTick) as using SymbolInfoTick timemsc as reference will not necessarily give you the first tick in the batch.
Using Python API should not change this behaviour.
The msc timestamp matched tick should be the same. That is :
2026.07.20 18:17:09.444 Testing (EURUSD,H1) SymbolInfoTick 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time_msc=1784571429525 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time=2026.07.20 18:17:09 2026.07.20 18:17:09.444 Testing (EURUSD,H1) bid=1.1406400000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) ask=1.1407300000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.444 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.444 Testing (EURUSD,H1) spread=9 points 2026.07.20 18:17:09.444 Testing (EURUSD,H1) CopyTicks 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time_msc=1784571429525 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time=2026.07.20 18:17:09 2026.07.20 18:17:09.444 Testing (EURUSD,H1) bid=1.1406900000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) ask=1.1406900000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.444 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.444 Testing (EURUSD,H1) spread=0 points 2026.07.20 18:17:09.444 Testing (EURUSD,H1) CopyTicksRange 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time_msc=1784571429525 2026.07.20 18:17:09.444 Testing (EURUSD,H1) time=2026.07.20 18:17:09 2026.07.20 18:17:09.444 Testing (EURUSD,H1) bid=1.1406900000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) ask=1.1406900000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) last=0.0000000000 2026.07.20 18:17:09.444 Testing (EURUSD,H1) volume=0 2026.07.20 18:17:09.444 Testing (EURUSD,H1) flags=6 2026.07.20 18:17:09.444 Testing (EURUSD,H1) spread=0 points
Should all have the same properties.
It is a known phenomona. See https://www.mql5.com/ru/forum/233647/page3#comment_15601676 check if the fix there solves yours. However it is better to go with a professional broker that does not have this account type fiasco going on.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I have been using CopyTicksRange to get a range of ticks to then construct 1-minute OHLC data from the raw ticks, later i tried looking through my broker and execute some testing trades and i found that CopyTicksRange returns ticks that are different from using SymbolInfoTick. To test this i wrote this simple MQL5 Code and the results were as follow