It's not a bug: it's the tester's design. OnInit() only sees the pre-history that the agent preloads before the From. To have more previous months: drag the From back and filter internally, or use a custom symbol if you need complete control.
It's not a bug: it's the tester's design. OnInit() only sees the pre-history that the agent preloads before the From. To have more previous months: drag the From back and filter internally, or use a custom symbol if you need complete control.
The Strategy Tester data is limited to 1 year back the "From date".
The testing agent downloads only the missing history, with a small margin to provide the necessary data on the history, for the calculation of the indicators at the starting time of testing. For the time-frames D1 and less, the minimum volume of the downloaded history is one year.
Thus, if we run a testing on an interval 2010.11.01-2010.12.01 (testing for an interval of one month) with a period of M15 (each bar is equal to 15 minutes), then the terminal will be requested the history for the instrument for the entire year of 2010. For the weekly time-frame, we will request a history of 100 bars, which is about two years (a year has 52 weeks). For testing on a monthly time-frame the agent will request the history of 8 years (12 months x 8 years = 96 months).
If there isn't necessary bars, the starting date of testing will be automatically shifted from past to present to provide the necessary reserve of bars before the testing.
https://www.mql5.com/en/docs/runtime/testing#multicurrency
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I’m seeing a consistent mismatch between the history available on a live chart and what the Strategy Tester gives me. I only need to show OnInit() to illustrate it.
Code used in OnInit :
Live chart (XAUUSD, H1):
H1 bars=61795 | first=1998.04.22 00:00 | last=2025.08.12 09:00
Strategy Tester run #1 (settings):
Symbol: XAUUSD, H1
Date: Custom period, From 2020.04.30 to 2025.07.31
Model: Every tick (other settings standard)
Tester log:
MQL_TESTER=1 | DATA_PATH=C:\Users\...\Agent-127.0.0.1-3000
H1 bars=7820 | first=2019.01.02 01:00 | last=2020.04.29 23:00
Strategy Tester run #2 (to check behavior):
Date: From 2021.04.30 to 2025.07.31
Tester log:
Observations:
On a live chart I have ~61k H1 bars (data since 1998).
In the tester I consistently get ~7.8k bars and the earliest date sits roughly ~10–11 months before the “From” date (2019-01-02 or 2020-01-02 in the examples).
“Max bars in chart = Unlimited” doesn’t change this in the tester.
I also tried forcing loads with CopyRates (date ranges and start/count), polling Bars() , and waiting for SERIES_BARS_COUNT to grow. No effect in the tester.
Questions:
Is the Strategy Tester sandbox limited to whatever historical depth the agent has cached for the symbol, regardless of what’s available on the live terminal?
Is there a supported way to force the tester to download/use deeper prehistory for a broker symbol (e.g., ensure ~24 months prior to the test start), without switching to a custom symbol?
If I run a dummy test with an earlier “From” date, should that permanently extend the agent’s cache so later tests see deeper history, or is the depth still constrained per test/run?
Any known XAUUSD/H1 limitations (broker-side or tester-side) that would explain why live has data back to 1998 but the tester stops ~10–11 months before the “From” date?
Thanks in advance for any pointers.