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”
| Mode | What it does | Use it for |
|---|---|---|
| Every tick based on real ticks | Replays the broker’s recorded ticks, with their real spreads | Final tests of anything you will trade |
| Every tick | Generates ticks from minute bars | Quick checks when real ticks are missing |
| 1 minute OHLC | Four prices per minute bar | Fast first passes of slower strategies |
| Open prices only | One price per bar | EAs that only act at a bar’s open |
| Math calculations | No price history at all | Testing 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:
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 report | What to look for |
|---|---|
| History quality | Close to fully real ticks over the whole period |
| Total trades | Hundreds rather than dozens, before believing any average |
| Expected payoff | Comfortably larger than your average cost per trade |
| Equity drawdown | Read the equity figure, not only the balance figure: floating losses count at prop firms |
| Max consecutive losses | Multiply by your risk per trade: could you sit through it? |
| Profit factor | Suspicious 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