Guide

How to backtest an EA with real tick data in MT5

Most backtests flatter the strategy because a few settings are left at their defaults. Here is how to set up the MT5 Strategy Tester so the result is one you can plan with.

A backtest is only as honest as its settings. The MT5 Strategy Tester can replay real broker ticks with variable spreads and execution delays, but several of those options are not the defaults. Leave them as they are and you get a result that looks better than anything you will see live.

This guide walks through the setup I use, in the order that matters.

Why tick data matters

Bar-based modes have to guess what happened inside each bar. When a bar’s range contains both your stop and your target, the tester decides which was hit first from a model, not from the market. Spreads are also simplified. The strategies most distorted by this are exactly the ones traders automate most: scalpers, tight stops, grids and anything that trades around news.

Step 1: choose “Every tick based on real ticks”

ModeWhat it doesUse it for
Every tick based on real ticksReplays the broker’s recorded ticks, with their real spreadsFinal tests of anything you will trade
Every tickGenerates ticks from minute barsQuick checks when real ticks are missing
1 minute OHLCFour prices per minute barFast first passes of slower strategies
Open prices onlyOne price per barEAs that only act at a bar’s open
Math calculationsNo price history at allTesting calculations, not trading

Real ticks come from your broker’s history, and how far back it goes depends on the broker. After a run, check the history quality line in the report. If a large share of the period was not covered by real ticks, the result for that part is a model, not a replay.

Step 2: test on the broker and account you will trade

Spreads, commissions, swaps, contract sizes and server time all differ between brokers, and between account types at the same broker. A strategy tested on a raw-spread account and traded on a standard account is two different strategies. Log in to the account type you will use, even if it is a demo, before you test.

Step 3: include every cost

  • Spread is included automatically with real ticks, including the widening at session opens and around news.
  • Commission depends on how your broker’s account is set up. Check that the report actually shows commission on each deal. If it does not, add it yourself before trusting the result.
  • Swaps matter for anything that holds overnight, especially on gold and indices.
  • Execution delay can be simulated in the tester’s settings. A random delay is a reasonable stand-in for a retail connection; set it on every serious test.

Step 4: keep some data you never optimise on

MT5’s forward option splits the period: the optimiser works on the first part, and the best settings are then run on the part they have not seen. Use it. Better still, keep a final stretch of data out of every test until the very end. If the settings only work where they were tuned, you have found the past, not an edge.

Step 5: optimise without fitting the noise

  • Optimise few parameters, over sensible ranges, in coarse steps.
  • Look for plateaus, regions where neighbouring settings also work, not single peaks.
  • Rank results with a criterion that rewards sample size and punishes drawdown, not raw profit:
OnTester.mqh10 lines
1// Custom optimisation criterion: reward edge and sample size, punish drawdown2double OnTester()3{4   double trades = TesterStatistics(STAT_TRADES);5   if(trades < 100) return 0.0;                        // too few trades to judge6 7   double pf = TesterStatistics(STAT_PROFIT_FACTOR);8   double dd = TesterStatistics(STAT_EQUITY_DDREL_PERCENT);9   return pf * MathSqrt(trades) / MathMax(dd, 1.0);10}

Step 6: read the report like a sceptic

Line in the reportWhat to look for
History qualityClose to fully real ticks over the whole period
Total tradesHundreds rather than dozens, before believing any average
Expected payoffComfortably larger than your average cost per trade
Equity drawdownRead the equity figure, not only the balance figure: floating losses count at prop firms
Max consecutive lossesMultiply by your risk per trade: could you sit through it?
Profit factorSuspicious if very high on a small sample

What about MT4?

MT4’s tester builds ticks from minute bars, so its tick modelling is an approximation even at its best setting. Third-party tick data tools improve it, but if the EA is worth testing seriously, it is usually worth converting to MT5 and testing there.

Checklist

  • “Every tick based on real ticks”, with history quality checked
  • Your broker, your account type, your symbol name
  • Commission visible on deals, swaps included, random delay on
  • A forward period, plus a final period you never optimise on
  • Few parameters, plateaus not peaks, a custom criterion
  • Equity drawdown and losing streaks read before profit
Written by

Algorithmic trading developer at Vertex Algorithms. Builds MT4/MT5 Expert Advisors, Python trading bots and Pine Script for traders, prop-firm traders and trading businesses.

Want an independent test of your EA?

I test EAs on real tick data with realistic costs, out of sample, with walk-forward and Monte Carlo checks, and give you a plain-English verdict.

WhatsApp