Home > Blog > CopyTicks vs CopyRates: Designing EAs for History Gaps

MQL5EA development

CopyTicks vs CopyRates: Designing EAs for History Gaps

Published: 2026-11-20Read time: about 3 min
⏱ This article reflects information as of its publish date. EA performance figures (PF, DD, annual return) change with live trading and re-validation — check the latest on the EA pages. See the latest EA results →
Contents (5)
  1. Bottom line: don't build an EA on the assumption that "the data is complete"
  2. How it works: tick history and bar history are different things
  3. The difference between the two functions
  4. Differences in backtesting
  5. Differences in live trading
  6. Checklist: protecting your EA from gaps
  7. Limits and caveats: what even we don't know
  8. Summary

Bottom line: don't build an EA on the assumption that "the data is complete"

An MT5 EA reads the market mainly through two functions: CopyTicks, which pulls ticks, and CopyRates, which pulls candlesticks (bars). Both read history data, but the Strategy Tester and a live account return different contents, and the data lines up differently in each.

When we build an EA, we assume that "the number of data points you asked for may not come back." History that looked perfectly complete in a backtest can be partly missing in live trading, right after startup or after a connection drop. This article explains how that works, and which points you can check yourself when choosing an EA.

Recommended Broker Comparison →

🎁 Download Free EA

📧 Free 8-email course + subscriber-only pack of 13 MT5 indicators

* Privacy strictly protected. You can unsubscribe at any time.

How it works: tick history and bar history are different things

The difference between the two functions

ItemCopyTicksCopyRates
Unit retrieved1 tick (one price update)1 bar (one timeframe candle)
Main contentsbid / ask / last / millisecond timestamp / flagsopen, high, low, close / tick volume / spread
Data volumeVery largeSmall
Contents in the testerVaries by modeling modeBars built by the tester
How gaps appear in live tradingDepends on how deep a history the broker servesToo few bars before loading finishes

A bar is an aggregation of ticks. On M1, if not a single tick arrives during that minute, no bar is created. During low-liquidity hours or the weekly open, bars with scattered timestamps are perfectly normal.

Differences in backtesting

The tester's modeling options are "Every tick based on real ticks," "Every tick (generated)," "1 minute OHLC," and "Open prices only." In any mode other than real ticks, what CopyTicks returns is ticks generated by the tester, not the price movement the broker actually delivered. An EA that makes decisions from the tick sequence can see its results change significantly when you switch modes. An EA that decides only from confirmed bar values is less affected by comparison.

Differences in live trading

On a live account, the terminal fetches the history it needs from the server bit by bit. Right after you attach an EA or restart a VPS, that fetching isn't finished, so both CopyRates and CopyTicks may return fewer bars than requested, or return an error. CopyTicks called from an EA waits for synchronization for a certain amount of time, but that doesn't guarantee everything will be there.

Checklist: protecting your EA from gaps

These are the checks we build in during development. When choosing an EA, look for the same thinking in its manual or settings.

  • Check the returned count every time: if you asked for 100 bars and got 60, don't make a decision on that bar. If the return value is -1, log GetLastError.
  • Check the sync state: before entering the entry logic, confirm that history has finished loading using SERIES_SYNCHRONIZED in SeriesInfoInteger or Bars().
  • Check the latest bar's time: if the time of the last bar retrieved is far from TimeCurrent(), treat the data as stale and stop trading.
  • Count by time, not by bar index: match on "the bar at this hour and minute" rather than "N bars ago." Calculations won't drift even if a bar in the middle is missing.
  • Don't fill the gaps: filling a hole with the previous value can inject a breakout that never happened into the logic. We choose to skip instead.
  • Wait and watch right after reconnecting: you can also design the EA to ignore the first few ticks after returning from a disconnection.

An EA that decides on confirmed bars is less likely to be swayed by missing ticks in the first place. We cover the thinking in related articles under EA & MT5 Know-How. For how to read the settings, see EA setup guide.

Limits and caveats: what even we don't know

To be honest, we don't have a full picture of how far back each broker keeps tick history on its server. Even for the same symbol name, history depth and gap locations differ between brokers, and the only way to find out is to pull the data on each account. That is the reality.

Also, the more strictly you guard against gaps, the more trades get skipped. The risk of trading wrongly on incomplete data goes down, but you also miss profit that might have been available on that bar. This is the price paid for safety, and there is no right answer for how strict to be.

Furthermore, even in real-tick mode, the tester does not reproduce delivery delays or slippage. An EA that holds up against gaps in a backtest isn't guaranteed to behave the same way live. We run forward tests of our EAs in parallel on an Exness demo account, but that too is not under the same conditions as a live account.

If you use a VPS, always reload history right after a restart. We cover the operating environment in VPS information.

Summary

  • CopyTicks returns tick-level history and CopyRates returns bar-level history, and they differ in both contents and data volume
  • Depending on the modeling mode, CopyTicks in the tester returns generated ticks
  • In live trading, history can be missing right after startup or reconnection
  • Check the returned count, sync state, and latest bar time every time, and skip trading if they don't line up
  • The stricter the gap protection, the more trades are skipped, and the depth of each broker's history can only be confirmed on your own account

📧 Free 8-email course + subscriber-only pack of 13 MT5 indicators

* Privacy strictly protected. You can unsubscribe at any time.

Have a question about EAs or FX?

You can post it on the Nattzy trading forum (free sign-up). Questions beyond this article are welcome too — EA settings, choosing a broker and more.

Ask on Nattzy ↗

Comments & questions