MetaTrader 5 HelpAlgorithmic Trading, Trading RobotsHow the Tester Downloads Historical Data

How the Tester Downloads Historical Data

Loading Historical Data, Preparing for Testing, and Adjusting the Test Start Date

The Strategy Tester creates a highly realistic market simulation. To achieve this, it preloads sufficient historical data for the selected symbol.

Before running any test, the platform synchronizes historical data:

  • From the trading server, M1 bars and tick data for the selected symbol are downloaded to the terminal. On the first launch of the tester, the terminal downloads the entire available history for the symbol.
  • From the terminal, the history is copied in compressed form to the testing agent. The agent then generates ticks locally or uses actual tick data (if available).
  • In multi-currency tests, when the strategy first accesses a new symbol or timeframe, the test is paused while missing data is downloaded. The system also downloads an additional buffer of data so that indicators can calculate values from the very first bar.

Minimum Historical Data Requirements

To ensure calculation stability, the tester always loads a "pre-start history buffer":

  • D1 and below — from the beginning of the previous calendar year. This provides at least 1 year of history. Example: if the test start date is 01.03.2023, the terminal will download form the terminal data from 01.01.2022. This equals to 14 months before the test start.
  • W1 — at least 100 weekly bars (~2 years).
  • MN1 — at least 100 monthly bars (~8 years).

If the available history is insufficient, the tester automatically shifts the actual start date forward to the nearest point that meets the requirements.

In such cases, testing begins later than the date specified by the user. The tester log will show a relevant message, for example:

start time changed to 2024.03.15 00:00 to provide data at beginning

This is not an error but a built-in mechanism to ensure correct computations.

For multi-currency tests, whenever the strategy accesses a new symbol or timeframe, the tester pauses to load additional history. This also includes the downloading of an extra buffer for indicator calculations and margin recalculations.

The Strategy Tester stores history for each symbol centrally, available to all local agents. Example (EURUSD):

\Program Files\MetaTrader 5 Strategy Tester\Tester\bases\<trading_server_name>\history\EURUSD

Tick history is stored similarly:

\Program Files\MetaTrader 5 Strategy Tester\Tester\bases\<trading_server_name>\ticks\EURUSD

How to Reduce or Avoid Test Start Date Shifts

Use a lower timeframe.

The tester requires at least 100 bars on the selected timeframe before modeling can begin.

This ensures stable indicator calculations and proper initialization.

  • If you run a test on D1, at least 100 daily bars (~5 months) are needed.
  • On H1 or M15, only 100 hourly or 15-minute bars are required. This amount of data is almost always available, even if the history is limited.
  • Therefore, when historical data is insufficient, the start date shift is smaller on lower timeframes than on higher ones.

alert_icon However, the Expert Advisor must operate correctly on the chosen timeframe. If a strategy is originally designed for D1, then when testing on M15 or H1 you must ensure it synchronizes its calculations properly and does not start recalculating signals too frequently.

Minimum History by Timeframe and Potential Test Start Shift

Testing Timeframe

Minimum Data Loaded

Possible Start Shift

M1

≥100 bars (≈1h 40m)        

Virtually none

M15

>100 bars (~25h)

Minimal

H1

≥100 bars (~4 days)        

Minimal

D1

≥100 bars (~5 months)        

Up to 5 months

W1

≥100 weeks (~2 years)            

Up to 2 years

MN1

≥100 months (~8 years)            

Up to 8 years (if history is limited)

How to Read the Table

  • On D1, the tester will always shift the start date forward until at least 100 daily bars are available.
  • On H1 or M15, only a few days of data are needed, which is usually available, so the test starts much closer to the chosen date.
  • On higher timeframes (W1 and MN1), the shift can be very large, since years of history are required.

Additional Tester Features

  • Tick generation modes:
    • Every Tick — ticks are generated from M1 bars, providing maximum realism. This is the most resource-intensive and time-consuming testing mode.
    • 1 Minute OHLC — faster but less realistic. Tick sequences are built only from M1 OHLC prices. The number of generated control points is significantly reduced, which shortens test duration. The OnTick() function is triggered at all OHLC points.
    • Open Prices Only — uses only the opening prices of bars on the selected timeframe. Very fast but less accurate, and requires caution in multi-currency tests. OnTick() is called only at the beginning of each bar at its Open price. Because of this, stop levels and pending orders may not trigger at exact prices (especially on higher timeframes). However, this mode is best for quick preliminary Expert Advisor testing. This is the fastest and least accurate type of testing.
    • Every Tick based on real ticks — maximum accuracy. Instead of generated tick sequences, the tester uses broker-provided tick data. M1 bars are also used in real-tick mode. The bars are used to verify and correct tick history. This also prevents discrepancies between tester and live terminal charts.
  • Time simulation:
    • TimeLocal(), TimeTradeServer(), and TimeGMT() return identical values during tests.
  • OnTimer and Sleep:
    • These functions are supported during tests. Timers slow down the simulation, while Sleep() simulates pauses (but infinite loops cause errors).

Agent Cache and Reuse

  • Historical data is stored in compressed form and reused if the test interval and settings remain unchanged.
  • Local agent processes remain active for about 5 minutes after a test ends, enabling faster startup of subsequent tests.