Try calling ACR once in init
//{https://www.mql5.com/en/forum/129734/page2 says ArrayCopyRates is a nonreentrant, // non-thread-safe call. Therefor you must put a mutex around the call in // case of multiple EAs on multiple charts. Alteratively, since init() is // single threaded across all charts, put all ACRs there. //} ArrayCopyRates(acr.arr, market.pair, period.market); // I'm in an OnInit.

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
This one caused me a lot of trouble, as it happens randomly... I had missed quite some trades because of this bug, but thanks to some logs I have found it in the end.
The time in yellow is the time of the computer, while the time in red is the time of the last candle. There is also a third time accessible to EAs through the TimeCurrent() function: the current time of the broker -- closely related to the computer time (apart from the timezone difference). If an EA is using this time information to check if the market has stepped into a new period, it can fail from time-to-time, as this information is not in sync with the candle information provided by the terminal (the time values in red).
02:59:59 test EURCAD,H1: [03.01 09:00] close=1.34561
This is clearly a MT4 bug, as a workaround one can use iTime() instead of the above getBarTime() -- however iTime() is bar count dependent: for smaller periods backtest can fail