Comparing a run with MetaTrader 5, and porting an Expert Advisor

How the MetaTrader 5 comparisons were set up, what to export, how MQL5 constructs translate, and what cannot be replicated.

Solo in inglese per ora.Apri la pagina in inglese

How the recorded comparisons with MetaTrader 5 were set up, what to export, how common MQL5 constructs translate, and what has been measured so far. The differences themselves are on Differences from the MetaTrader 5 Strategy Tester.

Which settings does a run take, and which MT5 settings have no counterpart?

Setting herePreselectedMT5 counterpart
Start and end date (whole UTC days, end included)—From / To (server time; the end date was not included in the reports we compared)
Mode: Tick by tick or Bar by bar (M1)Bar by barModelling
Initial balance10,000Deposit
Account currencyUSDDeposit currency
Leverage (1:N)1:100Leverage
Account type: Hedged or Netting — the strategy's own, not a run settingThe strategy'sThe account's hedging or netting mode
Slippage (points)0none
Virtual symbol per instrumentnoneThe symbol specification
Record a replayoffVisual mode (closest)
  • MT5 settings with no counterpart here: execution delays, margin call and stop out levels, profit calculation in pips, the optimization criterion, and the symbol's sessions, freeze level and margin rates. MT5's forward period, one split, has no direct counterpart: here a walk-forward runs rolling folds. The stops level has one only through a virtual symbol that states it.

  • The run limits: leverage up to 1:500, an initial balance up to 1,000,000,000, and a span of at most 10,957 days (Limits and numbers).

How the recorded comparisons were set up

On the MT5 side:

  • Run "Every tick based on real ticks" on the same data: a custom symbol built from the same UTC Dukascopy ticks and 1-minute bars, with the terminal's GMT offset at 0.
  • Give the custom symbol the catalog's digits, tick size, contract size and lot limits; commission 0; swap disabled; stops level 0; trading sessions 00:00–24:00 every day.
  • Run the EA's inputs from a file (.set or .ini): the tester's Inputs tab keeps old values across recompiles. Treat the report's Inputs block as the record of the run.
  • Check the tick value against a real deal before sizing from it (see What is a point worth?).

On this side:

  • Tick mode; slippage 0; no virtual symbol, or one that matches the custom symbol; the same deposit, leverage and currency, and a strategy of the same account type (all recorded comparisons are on hedging accounts).
  • The strategy's time zone = the clock the EA's hours are written in. On UTC-imported data that is UTC, unless the EA converts its hours explicitly.
  • End date = MT5's end date minus one day.
  • ATR with the Sma smoothing; ADX with the Wilder smoothing for iADXWilder and the Exponential one for iADX; Parabolic SAR with its MetaTrader method; Bollinger buffer numbers translated; MT5 index k at a new bar = shift k − 1 in a candle-close rule.

Can I export the trades to compare them line by line?

  • Yes: "Export report" on a finished run downloads its closed trades as CSV, one row per close event (export). Times are UTC to the second; MT5's are server time.

  • Profit is net of both legs' commission and of position-booked swap. Compare it with MT5's profit + swap + commission summed over that position's deals.

Porting an EA

Can I import MQL5 code or a .set file?

  • No. There is no MQL5 import and no export to MT5. Rebuild the logic in the strategy builder (graph view), write it in the strategy's text Source view, or describe it to an AI app you connect.

How do common MQL5 reads translate?

MQL5Here
Close[1], iClose(…, 1) at a new barCandle data, shift 0, in a candle-close rule on that timeframe
Close[2]shift 1
iMA(…, ma_shift = k, …)[i]Moving average with its Shift field set to k, read at shift i (the same value as the unshifted average read at shift i + k); iBands' bands_shift maps to the Bollinger Bands Shift field the same way
iBands buffer 0 / 1 / 2Bollinger buffer 1 / 0 / 2
iATRATR with the Sma smoothing
iADXWilder buffer 0 / 1 / 2ADX with the Wilder smoothing (the preselected one), buffer 0 / 1 / 2 — the same order: adx, plusDi, minusDi
iADXADX with the Exponential smoothing, the buffers in the same order
a breakout over the previous N bars: Close[1] > High[iHighest(…, N, 2)]Close shift 0 > Highest of N, shift 2
a session's high or low within one daySession Range, in the strategy's zone
a session window that crosses midnightnot supported by Session Range; latch a Price Range instead
OrderSend refusing a stop or target on the wrong sideadd a Market Price (bid/ask) condition to the entry
flatten "at 16:00" on the bar that opens at 16:00minute-of-day ≥ 960 and < 960 + the timeframe's minutes
  • Indicators. Every built-in indicator has a counterpart in the catalog, with the same parameters in the same order; custom indicators and an indicator applied to another indicator's output have none.

  • Why the window form for time exits. A condition "hour ≥ 16" fires at the first event at or after 16:00; on an early-close day or into a weekend that is the reopen, where the EA's 16:00 bar never existed and the EA kept the position to its stop. The window form fires only inside the 16:00 bar; it matched MT5's flatten to the second.

What cannot be expressed?

  • Arbitrary MQL5 code. A strategy here is rules over the 62 value types (constants, the indicators, candle data, time, price and session ranges, expressions, exposure, trade and account values, account history, status holders, record sets, market price) and the 20 actions (open, close, partial close, delete and modify, by side, market, limit or stop), with AND/OR/NOT conditions, crossovers and drawdown limits, within the hard limits.

  • Not expressible today: custom indicators, an indicator applied to another indicator's output, and the part of an indicator line drawn ahead of the newest bar; per-tick decisions on the forming bar that no read of closed bars reproduces; session windows that cross midnight (in Session Range); a timer other than every 1 minute (and On Timer itself, for a new strategy); trade-transaction events, Sleep, files, network or DLL calls; close-by; and the broker-side rules a tester applies beyond the stops level and the side of a stop and target (margin rates, the freeze level).

What has been measured

  • 11 strategies were compared with MT5's real-tick tester on the same Dukascopy ticks, over two to almost three years each. Where the comparison is asserted, the two agree trade for trade on about 97% to 100% of trades, and every remaining difference is named, with its cause, and capped at or just above the count observed. For example: 8,707 of 8,738 trades exact on an M1 SMA cross; 534 of 534 paired and 532 exact on a US100 session strategy; 477 of 477 paired, every open and close to the second, on a US100 opening-range breakout. Two strategies are measured rather than asserted — one because MT5 refused, for lack of free margin, trades the backtest takes. The full table is in Why you can trust the engine → results, strategy by strategy.

  • Bar mode is not compared trade by trade (see Which modes are there?).

  • What the agreement rests on, beyond the comparisons: one strategy evaluation shared by the backtest and live; no look-ahead by construction (next-bar-open fills in bar mode, last-closed higher-timeframe reads for candle-close rules, a run that stops rather than read missing data); deterministic replays of the real feed; and a recorded replay of what the strategy actually read. See Why you can trust the engine.


Not yet documented

  • Live: another symbol's 1-minute candles at a candle close. Both backtest modes read them one bar late; the live engine's behaviour on the same read has not been measured.
  • Netting accounts have not been compared with MT5.
  • Commissions and swaps have not been compared with MT5: every comparison ran with both at zero.

Domande?support@algotradinghub.io

Ultimo aggiornamento: 21 nov 2026© 2026 AlgoTradingHub