EQUILABS
Expert Advisors

How to run a backtest in the MetaTrader Strategy Tester, step by step

A backtest shows how an Expert Advisor would have traded on past prices. Done carefully, it is the fastest way to understand an EA before risking money. Done carelessly, it produces a beautiful curve that means very little.

By EQUILABSUpdated 28 November 20264 min read

Open the Strategy Tester

In both MetaTrader 4 and MetaTrader 5, open View > Strategy Tester, or press Ctrl+R. A panel opens at the bottom of the terminal. The steps below follow the order of the settings in that panel.

The five steps of a backtest, in the order of the Strategy Tester panel.

Step 1: choose the EA, symbol and timeframe

Select the Expert Advisor, the symbol it is made for (for example XAUUSD) and the timeframe its guide recommends. Many EAs read their own timeframe internally, but a wrong chart period can still change the result.

Step 2: choose the modelling mode

This decides how the tester rebuilds price movement inside each candle, and it matters more than any other setting.

ModePlatformWhen to use it
Every tick based on real ticksMT5Most realistic; uses the broker's recorded ticks and spreads
Every tickMT4 and MT5Ticks generated from one-minute data; good for most EAs
1 minute OHLCMT5Faster, for a first rough test
Open prices onlyMT4 and MT5Only for EAs that act once per new candle

For any EA that uses stop losses, take profits or pending orders inside a candle, use the most detailed mode available. In MetaTrader 4, check the modelling quality shown in the report: low values mean the price data had gaps.

Step 3: dates, deposit, leverage and spread

  • Dates: use several years if possible, including calm and volatile periods. A test over three good months shows very little.
  • Deposit and leverage: match what you will actually trade.
  • Spread: in MetaTrader 4 you can choose current spread or a fixed value; a fixed, realistic value makes results more comparable. In MetaTrader 5 with real ticks, the recorded spread is used.
  • Execution delay (MetaTrader 5): adding a delay simulates slower execution and shows whether the EA depends on perfect fills.

Step 4: inputs, then start

Open the Inputs tab and set the EA's parameters, ideally the same values you plan to use live. Then press Start. Visual mode lets you watch the trades on a chart, which is useful to check that the EA behaves as described.

Step 5: read the report

The report shows many numbers. These are the ones to read first:

  • Total net profit and the balance curve: is the growth steady, or does it come from a few lucky trades?
  • Maximum drawdown, in money and percent: could you live through it? See what is drawdown.
  • Profit factor: gross profit divided by gross loss. Above 1 means profitable; very high values on few trades are a warning sign, not a promise.
  • Total trades: a result based on 30 trades is far less reliable than one based on 300.
  • Largest losing trade and maximum consecutive losses: they show what the bad days look like.

Avoid fitting the past

The tester can run thousands of combinations of settings through optimisation. It is tempting to pick the single best combination, but that combination is often tuned to the noise of that exact period. A few habits reduce this risk:

  1. Prefer settings that work reasonably across a range of values, not one sharp peak.
  2. Keep part of the history unused, then test the chosen settings on it. This is called an out-of-sample test.
  3. Be suspicious of curves that go up in a perfectly straight line, especially with martingale or grid logic. See martingale and grid risks.

Why news EAs need more than a backtest

Backtests have clear limits for news trading:

  • The tester cannot reproduce the real spread widening and slippage of the release minute at every broker.
  • MetaTrader does not allow WebRequest in the Strategy Tester, so an EA that downloads a live news calendar cannot fetch it there in the normal way.
  • Pending orders in the tester fill exactly at their price, while live fills during news can be several dollars away.

For these reasons a news EA should always be judged on a forward test as well: a demo or small live account over real releases. Our article on backtest vs forward test explains how to combine both.

Key takeaways

  • Open the Strategy Tester with Ctrl+R and set EA, symbol, timeframe, modelling mode, dates, deposit and spread.
  • Use the most detailed modelling mode for EAs that work inside a candle; real ticks in MT5 are the most realistic.
  • Read net profit, maximum drawdown, profit factor, number of trades and losing streaks together.
  • Avoid over-optimisation: prefer stable ranges and check out-of-sample periods.
  • News EAs need a forward test, because the tester cannot reproduce real news spreads, slippage and calendar downloads.

Trading carries a high level of risk and may not be suitable for everyone. This article is for education only and is not financial advice. Past results do not guarantee future results.

Keep reading