MetaTrader

Is Your Multi-Symbol EA Reading Data That Isn't Ready?

Ionut Claudiu Fratila · Published Nov 23, 2026 · 8 min read · —
MetaTrader 5MQL5Expert AdvisorsMulti-SymbolStrategy TesterData Access
Fibre-optic patch cables plugged into a network panel

An Expert Advisor that only looks at its own chart has a simple life: a new price arrives, OnTick() runs, and the bars it reads belong to that chart. Once an EA starts reading other symbols or other timeframes, that changes. The data it asks for may not have been downloaded yet, may not have been built for that timeframe yet, or may belong to a slightly different moment from the chart’s own bars.

None of this raises an error by default. A function returns fewer bars than asked for, or -1, and if the code doesn’t check, the EA carries on with whatever is in its arrays. This article explains how MetaTrader 5 makes data available to programs, what the documentation says about readiness, and the checks we look for when reviewing multi-symbol EAs, including ones written with AI assistants.

OnTick() Belongs to One Symbol

The NewTick event is generated for an EA only when a new tick arrives for the symbol of the chart it is attached to. If a NewTick event is already waiting in the queue or being processed, a new one is not added (MQL5 Reference, OnTick).

So an EA on a EURUSD chart that also reads GBPUSD has no event for GBPUSD ticks. It sees GBPUSD only when EURUSD ticks, or through the other events an EA receives, such as Timer, BookEvent and ChartEvent. If EURUSD is quiet, the GBPUSD data the EA last read can be older than it looks.

How the Terminal Builds Price History

MetaTrader 5 receives price data from the trade server as packed blocks of one-minute bars. It stores them in HCC files, one file per year of minute bars for each symbol, and builds each timeframe from them on request into the HC format. Each timeframe is prepared separately, so having minute history does not mean the H1 or D1 series has been built yet. Series that are not used for a while are released from memory, and the “Max bars in chart” setting caps how many bars programs can access. A change to that setting takes effect only after the terminal restarts (MQL5 Reference, Organizing Data Access).

The reference is direct about the consequence: the availability of price data or indicator values at a given moment is not guaranteed. Because any update from the server rebuilds all timeframes and recalculates indicators, access to data “can be closed, even if these data were available a moment ago” (Organizing Data Access).

Check, Exit, Try Again

The tempting fix is a loop that waits until the data arrive. MetaQuotes advises against it. “Do-nothing” loops are acceptable only in scripts, which have no events to fall back on. In custom indicators they are strongly discouraged, because they stop the calculation of all indicators and other price-data handling on the symbol. For EAs and indicators, the documented approach is to use the event model: if the data for a required series can’t be obtained during OnTick() or OnCalculate(), exit the handler and rely on the data being available at the next call (Organizing Data Access).

The same page includes a CheckLoadHistory() example that shows the full sequence for a script: make sure the symbol is in Market Watch with SymbolSelect(), check whether the series is synchronised, read the bar count and the first available date, and request more bars with CopyTime() to make the terminal load them. The Sleep() waits in that example suit scripts only.

The Readiness Checks Available

MQL5 gives several ways to ask whether data are ready:

  • SeriesInfoInteger() with SERIES_SYNCHRONIZED reports whether a symbol and timeframe are synchronised at the current moment. Other properties of the same function give the bar count, the first dates in the terminal and on the server, and SERIES_LASTBAR_DATE, the open time of the last bar (MQL5 Reference, History Database Properties).
  • SymbolIsSynchronized() reports whether a symbol’s data in the terminal are synchronised with the trade server (MQL5 Reference, SymbolIsSynchronized).
  • CopyRates() returns the number of elements copied, or -1 on error. Called from an EA or script, it starts a download or build if the data are not ready. Called from an indicator, it returns -1 immediately while the download or build starts. It also returns -1 for data beyond the maximum bars setting (MQL5 Reference, CopyRates).
  • BarsCalculated() returns how many values an indicator handle has calculated, or -1 if it hasn’t calculated them yet. MetaQuotes points to it for reading indicator data straight after creating the handle (MQL5 Reference, BarsCalculated).

In practice, that means every Copy*() result should be compared with the number of bars requested, not just checked for -1. A partial result is still a result, and an array that was filled on an earlier call may still hold old values. The CopyRates() documentation notes that, when called from an Expert Advisor, it returns whatever data is ready when the timeout runs out, while the download continues in the background (CopyRates).

Bars From Different Symbols Don’t Open Together

Even when every series is ready, bars on two symbols may not open at the same moment. MetaQuotes’ own tester example makes the point: when a new H1 bar opens on EURUSD, “there is no guarantee” that one has opened on USDJPY yet (Testing Trading Strategies). MetaQuotes’ Synchronize_Bars_Use_Sleep example on the same page compares SERIES_LASTBAR_DATE across symbols, which backs the advice to compare bar times.

An EA that combines bars from several symbols should therefore check that the latest bar on each one has the same open time, for example by comparing SERIES_LASTBAR_DATE or the times in the copied rates, before treating them as one moment. If they don’t match yet, use the check-exit-retry approach above, and decide in advance how long to wait before skipping that bar. A symbol with different trading hours, or no ticks in that bar (a holiday, for example), may never produce a matching bar.

A timer helps here. EventSetTimer() and EventSetMillisecondTimer() generate Timer events, handled in OnTimer(), that do not depend on the chart symbol ticking. The documentation sets the limits: in live running, timer events arrive no more often than once every 10–16 milliseconds because of hardware limits, and a new Timer event is not queued if one is already waiting or being processed (MQL5 Reference, EventSetMillisecondTimer).

What Changes in the Strategy Tester

The tester loads other symbols’ history from the client terminal, not from the trade server, the first time the EA calls for that symbol’s data. At that first call the test pauses while the history is passed to the testing agent and a tick sequence is generated for the symbol. Indicator creation, SymbolSelect(), SymbolIsSynchronized(), Bars() and the Copy*() functions are among the calls that count. MetaQuotes recommends selecting the symbols in the terminal’s Market Watch and loading their data before testing a multi-currency EA, and notes that calling SymbolSelect() in OnInit() loads the history immediately before the test begins. The tester’s own Market Watch is emulated and starts with only the tested symbol (Testing Trading Strategies).

Two further rules apply in “Open prices only” mode. The EA is called only once per bar, so there is no later tick in which to wait for another symbol’s bar; MetaQuotes shows two ways to wait, Sleep() inside OnTick() or a timer, and notes that TimeTradeServer() rather than TimeCurrent() shows the current server time after Sleep(), because TimeCurrent() is the time of the last tick. The EA also cannot read a timeframe lower than the testing timeframe, and any higher timeframe must be a whole multiple of it: testing on M20 allows H1 but not M30. For other symbols, the same limit is based on the first timeframe the EA accesses for each one (Testing Trading Strategies).

Limits and Caveats

These checks make an EA more careful about the data it uses. They say nothing about whether its trading logic is any good, and nothing here suggests that any strategy will work. We make no claims about performance.

Readiness is also a moving target. The documentation itself says data can become unavailable a moment after it was available, so a check passed on one call is not a guarantee for the next. Each program has only one timer, and a timer cannot deliver bars that the server has not sent. Logging needs planning too: Print() and Comment() don’t run during optimisation except in OnInit(), and Alert(), SendMail(), SendNotification() and WebRequest() don’t run in the tester at all (Testing Trading Strategies). This article covers MetaTrader 5 and MQL5 only, and the behaviour described is taken from the current MQL5 Reference, which MetaQuotes may update.

Conclusion

Is your multi-symbol EA reading data that isn’t ready? It may be, unless the code checks. The documented pattern is straightforward: don’t rely on OnTick() for symbols the chart doesn’t show, check every Copy*() and BarsCalculated() result against what was asked for, exit and retry rather than loop, compare bar times across symbols before combining them, and preload the symbols a test will use. None of it needs extra software.

This is everyday work in our MetaTrader Services and Algorithm Development, and the same checks are part of our AI Code Rescue reviews. If you have a multi-symbol EA you would like checked, you can tell us about it here.

Drafted with AI assistance; reviewed, edited and approved by Ionut Claudiu Fratila.