B

Backtesting

Quick Answer

Backtesting is the process of applying a trading strategy or set of rules to historical market data to estimate how it would have behaved in the past. It can help evaluate strategy logic, risk and historical performance, but the results are simulated and do not guarantee that the strategy will perform similarly in live trading.

How does Backtesting work?

A backtest applies predefined trading rules to historical price data.

For example, a strategy might specify:

  • when to enter a trade;

  • when to exit;

  • position size;

  • stop-loss or take-profit rules;

  • trading hours;

  • other conditions used by the strategy.

The backtesting system then moves through historical data and simulates what would have happened if those rules had been followed.

MetaTrader 5's Strategy Tester, for example, runs an Expert Advisor using historical price data and records virtual transactions according to its algorithm. The tester can also simulate factors such as execution delays and supports separate forward-testing periods for checking selected parameters on data that was not used for optimisation.

Once the test is complete, the trader can evaluate statistics such as profit and loss, drawdown, number of trades, win rate or other relevant performance measures.

Key features of Backtesting

Several characteristics are important when evaluating a backtest:

  • Historical data is used: The strategy is tested against past market conditions rather than future prices.

  • Rules should be defined in advance: Entry, exit and risk-management logic should be clear enough to reproduce consistently.

  • Costs matter: Spreads, commissions, financing and other costs can materially change simulated results.

  • Execution assumptions matter: Slippage, delays, liquidity and fill assumptions can affect whether a backtest resembles live trading.

  • Data quality matters: Missing, inaccurate or insufficient historical data may distort results.

  • Different time periods can produce different outcomes: A strategy that performs well in one market environment may behave differently in another.

  • Forward testing can complement backtesting: Testing parameters on separate data may help evaluate whether results depend too heavily on the original sample. MetaTrader 5 explicitly supports splitting testing into backtest and forward-test periods.

Simple Backtesting example

Suppose a hypothetical strategy has one rule:

Buy when a 20-period moving average crosses above a 50-period moving average.

The backtest uses five years of historical data.

During that period, the simulated strategy produces:

100 trades
55 profitable trades
45 losing trades

The simplified win rate would be:

55 ÷ 100 × 100 = 55%

Assume the simulated gross profit is $12,000 and gross loss is $8,000:

$12,000 − $8,000 = $4,000 simulated net profit

This result describes only what the strategy would have produced under the assumptions used in the historical simulation. It does not show what the strategy will earn in future trading.

This example is illustrative only and does not represent actual FxGrow results, performance or a recommended strategy.

Potential benefits and uses

Backtesting may help traders and developers evaluate a strategy before risking capital in live markets.

It can be used to:

  • identify whether trading rules behave as intended;

  • estimate how a strategy performed under different historical conditions;

  • compare variations of the same strategy;

  • examine historical drawdowns and losing periods;

  • identify obvious weaknesses in entry or exit logic;

  • evaluate whether execution assumptions materially affect results;

  • support further forward testing or paper trading.

MetaTrader 5 describes strategy testing as a way to evaluate how an automated strategy would have traded historically before applying it in a real market environment.

Risks, limitations and common misconceptions

A common misconception is that a profitable backtest proves that a strategy is profitable.

It does not.

The CFTC warns that hypothetical trading results do not represent actual trading and may overestimate or underestimate performance because simulated trades have not been exposed to real market factors such as liquidity.

Another major limitation is overfitting. This occurs when a strategy is adjusted too closely to historical data, causing it to capture past noise rather than a repeatable market relationship. A highly optimised backtest can therefore look impressive while performing poorly on new data.

Look-ahead bias can also invalidate a test if the strategy accidentally uses information that would not actually have been available at the time a simulated trade occurred.

Other limitations include:

  • survivorship bias in historical datasets;

  • unrealistic transaction costs;

  • assumed fills at unavailable prices;

  • insufficient historical periods;

  • ignoring market-impact or liquidity constraints;

  • changing market structure.

MetaTrader 5 also notes that execution delay can be emulated during strategy testing because prices may change between sending a trading request and execution.

Backtesting should therefore be treated as an analytical tool rather than proof of future profitability.