AXIFLARE
AXIFLARE // GUIDESBACKTESTING

How to Backtest an Expert Advisor in MetaTrader 5 Properly

BY AXIFLARE RESEARCHPUBLISHED UPDATED

A backtest shows how an Expert Advisor behaved under a defined set of historical conditions. It does not predict future results. Run carefully, though, it is one of the most useful tools for understanding a strategy before it trades real capital. This guide sets out a practical workflow for the MetaTrader 5 Strategy Tester.

Why a proper backtest matters

The aim is not to produce the highest possible return. It is to see how a strategy behaved under clearly stated conditions: which data, which costs, which sizing and which period. A test with optimistic assumptions can look impressive and still tell you very little.

Open the MetaTrader 5 Strategy Tester

In MetaTrader 5, open the tester from View → Strategy Tester (Ctrl+R on Windows). The tester panel opens at the bottom of the terminal, with settings, inputs and results on separate tabs. See the official MetaTrader 5 Strategy Tester documentation for the full interface reference.

Select the Expert Advisor, symbol, timeframe and period

Choose the EA, the symbol it is intended for, the timeframe and the test dates. The timeframe should match the way the EA was designed to run; testing an M1 system on H1, or the reverse, produces results that do not describe the intended setup.

Choose a modelling mode

Every Tick Based on Real Ticks replays the broker's recorded ticks where available. Every Tick generates an intrabar tick path from minute-bar data. 1 Minute OHLC uses only the open, high, low and close of each minute bar, which is faster but coarser. Open Prices Only uses the bar-open price for testing and is appropriate only for EAs whose logic is designed to operate without relying on intrabar price movement.

For the trade-offs between the two most detailed modes, see MT5 Every Tick vs Every Tick Based on Real Ticks.

Choose the historical period

A short, favourable window can make almost any strategy look good. Aim for a period that includes different volatility environments: trending and ranging phases, quiet markets and high-volatility stretches. There is no universal minimum number of years; what matters is whether the test covers conditions the strategy is likely to meet.

Starting deposit and leverage

Set a starting deposit that reflects how you intend to use the EA. A very large deposit can hide margin pressure; a very small one can distort lot rounding. Leverage primarily changes margin requirements rather than the strategy's price logic. However, if available margin constrains whether positions can be opened or maintained, different leverage settings can indirectly change the test outcome.

Position sizing

Fixed lot sizing trades the same volume regardless of account size. Balance- or equity-based sizing scales volume with the account. Compounding reinvests gains, so position size grows as the account grows. Dynamic sizing can dramatically change long-term percentage returns and drawdown, so always know which model a test used.

Spread and commission

Realistic trading costs matter, especially for short-term strategies. Check the spread used in the test, set commission to match your account type, and account for swap where positions are held overnight. Brokers and account types do not share identical costs, so use conditions close to the ones you will actually trade.

If MT5's "Profit in pips" testing option is used, commission and swap calculations and margin control are disabled. It is useful for rough strategy estimation, but should not be used as the final test when realistic financial costs and margin behaviour matter (see the MetaTrader 5 Strategy Tester documentation).

Broker data

Historical feeds differ across brokers and servers in tick density, gaps and quoted prices. For execution-sensitive strategies, results can differ materially between data sources.

Run the test

Start the test and let it finish without changing settings. During a visual run you can watch how trades open and close; afterwards, check the Journal tab for errors such as invalid volumes or rejected orders before reading any statistics.

What to examine in the final report

Review Net Profit, Profit Factor, Balance Drawdown, Equity Drawdown, Trade Count, Win Rate, Recovery Factor, Expected Payoff and Sharpe Ratio together. None has a universal "good" value; each describes a different aspect of the test. See MT5 backtest metrics explained for how to read them.

Examine the equity curve

A smooth balance curve alone is not enough. Floating losses on open positions appear in equity, not balance, so look at the equity graph and the equity drawdown figure. See balance vs equity drawdown in MT5.

Test different periods

Run the same settings across several separate periods. The goal is to see whether behaviour stays broadly consistent, not to retune parameters for each period until every one looks good.

Test another broker or data source where practical

Running the same test on a second broker's data can reveal how sensitive a strategy is to a particular feed, spread profile or execution environment.

Avoid curve fitting

Do not repeatedly change parameters until one historical period looks perfect. A strategy that only works under a narrow configuration may be fragile once conditions change.

Forward testing

Follow historical testing with a current demo or forward test on your intended broker. It shows behaviour under present spreads and execution. It is not proof of future profitability.

Practical MT5 backtest checklist

  • Correct symbol
  • Correct timeframe for the EA's design
  • Appropriate modelling mode
  • Sufficient history across different conditions
  • Realistic deposit
  • Realistic spread, commission and swap
  • Position sizing model understood
  • Balance and equity drawdown reviewed
  • Trade count reviewed
  • Multiple periods checked
  • Forward test performed

Final perspective

A careful backtest narrows down what you do not know about a strategy; it does not remove risk. For a broader framework, see how to evaluate an XAUUSD EA, and please read our Risk Disclosure.

Educational content only. Nothing in this guide constitutes investment advice. Trading involves substantial risk.