All guides · Trading bots

How to Backtest an EA in the Strategy Tester

How to test a trading bot on years of past prices in MetaTrader's Strategy Tester, and which numbers to read in the report.

What it is

A backtest runs your bot on historical prices to show how it would have traded: every entry, exit, win and loss. MetaTrader's built-in Strategy Tester does this for any EA in both MT4 and MT5.

Step by step

  1. Open the Strategy Tester with View → Strategy Tester (Ctrl+R).
  2. Choose your bot as the Expert, then pick the symbol it was built for and a long date range: several years if your broker's history allows.
  3. Set the modelling to "Every tick based on real ticks" in MT5 if available (otherwise "Every tick"), or "Every tick" in MT4.
  4. Set the deposit and leverage to match the account you plan to trade, and check the bot's Inputs.
  5. Click Start and wait for the run to finish.
  6. Open the results: look at net profit, maximum drawdown, the number of trades and the longest losing streak, then the equity graph.
  7. Change one input at a time and run again to see how sensitive the results are.

Why it matters

A backtest is the cheapest way to find out whether a bot's idea held up in the past and how bad its losing stretches got. It won't predict the future, but a bot that lost money for ten years of history is very unlikely to start winning tomorrow.

Good to know

Judge a bot by its drawdown and consistency, not just its profit: would you have kept running it through its worst stretch? Make sure there are enough trades (dozens at least) for the result to mean something.

Common mistakes

Over-optimizing inputs until the past looks perfect (it won't repeat); testing too short a period; ignoring spread and swap costs; and treating a backtest as a guarantee.

Related