Learn

How to backtest an EA in MT5

MetaTrader 5's Strategy Tester runs a compiled Expert Advisor against historical prices and reports how it would have traded. Here's how to set it up, which modelling mode to choose, and how to read the results honestly.

Running a backtest

  1. 1

    Open the Strategy Tester

    In MT5 press Ctrl+R, or choose View → Strategy Tester. The EA must already be installed and compiled.
  2. 2

    Pick the EA, symbol and timeframe

    Choose your Expert Advisor, the symbol it trades, and the timeframe it was designed for.
  3. 3

    Set the date range

    Use a custom period long enough to include different market conditions: trends, ranges, and volatile news weeks, not just a recent stretch that happens to suit the strategy.
  4. 4

    Choose the modelling mode

    This decides how price moves inside each bar; see the section below.
  5. 5

    Set deposit, leverage and inputs

    Use the deposit and leverage you'd really trade with, and check the EA's settings on the Inputs tab. Tick Visual mode if you want to watch the trades being placed.
  6. 6

    Start and read the report

    Click Start. When it finishes, the Backtest tab has the report, the Graph tab shows the balance curve, and the Journal lists every order and any errors.

Choosing a modelling mode

  1. 1

    Every tick based on real ticks

    Replays your broker's recorded ticks, including real spreads. The most realistic, the slowest, and only as good as the tick history your broker provides.
  2. 2

    Every tick

    Generates artificial ticks inside each one-minute bar. Detailed, but the in-bar path is simulated rather than recorded.
  3. 3

    1 minute OHLC

    Uses just four prices per minute: the open, then the low and high (low first on a rising minute, high first on a falling one), then the close. Fast and a good middle ground for EAs that make decisions on closed bars; less exact for tight stops, which can be hit inside a minute in ways four prices don't capture.
  4. 4

    Open prices only

    Only each bar's open price. Very fast, but valid only for EAs that act solely at the start of a bar. Stops and trailing stops are modelled crudely.

Reading the report

  1. 1

    Total net profit

    Profit after the whole test. Meaningless on its own without the drawdown next to it.
  2. 2

    Maximal drawdown

    The largest fall from a peak. This is the pain you'd have had to sit through, and the number prop firm rules are measured against.
  3. 3

    Profit factor

    Gross profit divided by gross loss. Above 1 means winners outweighed losers over this period.
  4. 4

    Total trades

    Too few trades (a few dozen) and the other numbers are mostly luck.

What a backtest can't tell you

A backtest shows how your rules behaved on one stretch of history, not what they'll do next. Tuning inputs until the curve looks perfect usually fits noise rather than finding an edge, so test on a period you didn't tune on, then run the EA on a demo account. More on backtesting pitfalls.

Quick answers

Which modelling mode should I use in the MT5 Strategy Tester?

Use Every tick based on real ticks for a final check if your broker has the data; 1 minute OHLC is a fast, reasonable choice for EAs that decide on closed bars. Open prices only is only valid for EAs that act solely at the open of each bar.

How much history should I backtest an EA on?

Enough to cover several different market conditions and at least a few hundred trades. A few months of one trending market can make almost any strategy look good.

Does a good backtest mean the EA will be profitable?

No. A backtest describes how the rules behaved on past data. Overfitting, spreads, slippage and changing markets all mean live results can be very different.

How to install an EA in MT5 · Create an EA from your strategy

Give us your trading strategy

Describe it in plain language and see exactly what your bot will do. Free, no account needed.

Build My EA

Your first EA is free.