Blog

How to Backtest an Expert Advisor in MT5, Step by Step

TradeSmithy Team5 min read

Short answer: open the Strategy Tester in MetaTrader 5 (Ctrl+R), choose your EA, symbol, timeframe and date range, set the modelling mode (use "Every tick based on real ticks" for final tests), enter a realistic deposit, leverage and execution delay, then press Start. Judge the result on profit factor, maximum equity drawdown, number of trades and history quality — not on net profit alone.

Step 1: Open the Strategy Tester

In MT5, press Ctrl+R or choose View → Strategy Tester. On the Overview tab, choose Single test. The Settings tab is where every decision below lives.

Step 2: Choose the EA, symbol and timeframe

Pick your Expert Advisor from the list, then the exact symbol your broker uses — XAUUSD, XAUUSDm and GOLD are different histories. The timeframe is the chart period the EA thinks it is attached to; if your EA checks conditions on a new H1 bar, test on H1.

Step 3: Set the date range

Use as much history as the strategy's logic deserves, and keep part of it back. Build and tune on, say, 2019–2023; judge on 2024–2026. A result on data you never looked at is worth more than any number of runs on data you tuned against.

Step 4: Pick the modelling mode

ModeWhat it simulatesUse it for
Every tick based on real ticksThe broker's recorded ticks, where availableFinal validation
Every tickTicks generated from 1-minute barsStrategies that act inside a bar
1 minute OHLCFour prices per 1-minute barFast checks of bar-close strategies
Open prices onlyOne price per barVery fast screening of strategies that act only at bar open
Math calculationsNo pricesOptimising pure calculations

If your EA uses stops, trailing stops or intrabar logic, anything coarser than every tick will misstate the result. We cover the difference in detail in a later post on real versus generated ticks.

Step 5: Deposit, leverage and delays

  • Deposit and currency: what you will actually trade with.
  • Leverage: your account's real leverage — it changes margin, and therefore which trades can be opened at all.
  • Delays: "Zero latency, ideal execution" is a fantasy. A random delay is a fairer test for anything short-term.

Step 6: Set the inputs

On the Inputs tab, set the values you want to test. These are the EA's input variables — in a TradeSmithy graph, every global parameter node becomes one, and any indicator period can be wired to one.

Step 7: Run it and read the report

Press Start. The Backtest tab then shows the report. The numbers that matter, in order:

MetricWhat it tells youWarning sign
Total tradesWhether the sample means anythingUnder ~100 trades
Profit factorGross profit ÷ gross lossBelow ~1.2 after costs
Equity drawdown maximalThe worst peak-to-trough fall, including open tradesLarger than you could sit through
Expected payoffAverage result per tradeSmaller than the spread
Recovery factorNet profit ÷ max drawdownBelow ~2
History qualityHow much of the test used real dataWell below 100%

The Graph tab shows balance and equity. A balance line that rises smoothly while equity dips far below it is the fingerprint of a grid or martingale EA holding losers open.

Common backtesting mistakes

  • Testing with zero or unrealistically low spread.
  • Tuning parameters and judging on the same dates.
  • Too few trades to mean anything.
  • Ignoring commission on raw-spread accounts.
  • Treating a backtest as a forecast. It is evidence about the past; see our honest take on making money with a bot.

Backtest without tying up your own computer

TradeSmithy runs backtests on its own servers. On a Pro project you choose the symbol, timeframe, dates, deposit, leverage, spread (or the symbol's recorded spread) and modelling mode — every tick, 1-minute OHLC or open prices — and queue the run. It keeps going if you close the tab, and returns an equity curve, the full trade list and the tester log, which you can export to Excel.

Start free to build the EA and test it in your own MetaTrader, or go Pro for $19 per 30 days for 50 server backtests a month alongside the AI assistant. New to builders? Start with the EA builder comparison.

Frequently asked questions

How long should I backtest an EA for?

Long enough to include different market conditions and at least a few hundred trades, with a separate period held back for validation.

Which MT5 modelling mode is most accurate?

Every tick based on real ticks, where your broker has recorded tick history for the period.

Why is my MT5 backtest so slow?

Real-tick modelling on long periods processes enormous amounts of data. Screen with 1-minute OHLC, then validate the survivors on real ticks.

Can I trust a backtest?

Trust it as far as its assumptions: costs, data quality, and whether the rules were tuned on the same period. Always forward test on demo.

Keep reading

← More from the TradeSmithy blog