Backtesting a Strategy
Education library

Platforms8 min read

How to Backtest a Trading Strategy in MetaTrader

Backtesting is the process of running a trading strategy against historical price data to see how it would have performed. It is a genuinely useful step before risking real capital, but it is also easy to produce a backtest that looks excellent and tells you almost nothing reliable about the future, usually because of data quality problems or unintentional curve fitting.

This guide covers how to run a backtest in MetaTrader 5's strategy tester, what to watch for in the results, and why a strong backtest should be followed by forward testing before it is trusted with meaningful size.

Using the MT5 strategy tester

Open the Strategy Tester from the View menu or with Ctrl+R. Select the expert advisor you want to test, the instrument, the timeframe, and the date range for the historical period. Choose a model — Every tick based on real ticks is the most accurate but requires downloadable tick data and is slower to run; Open prices only is faster but far less precise about intrabar behaviour.

Set the starting deposit, leverage and spread to match a realistic account rather than default values, then run the test. Results appear as a summary of net profit, drawdown, win rate and profit factor, alongside a full trade-by-trade report and an equity curve chart showing how the account balance moved over the tested period.

Data quality and modelling assumptions

A backtest is only as reliable as the data behind it. Many brokers' free historical data has gaps, incorrect spreads, or missing tick-level detail, particularly on less common instruments or during volatile periods, and a strategy tested on poor data can show results that would never occur live. MT5 allows you to download higher-quality tick data through its history centre, and it is worth checking the quality report the tester produces, which shows what percentage of ticks used were modelled versus real.

Modelling assumptions also matter beyond raw price data. Spread is often held fixed in a backtest even though real spread widens during news and thin liquidity; slippage is frequently not modelled at all unless you specifically configure it; and swap costs on positions held overnight need to be included for any strategy that holds trades longer than a day. A backtest that ignores all three will systematically overstate real-world results.

  • Use Every tick based on real ticks where possible, and check the modelling quality percentage
  • Set a realistic fixed or variable spread rather than leaving a default zero-spread assumption
  • Include an estimate for slippage and swap costs where relevant to the strategy

The risk of curve fitting

Curve fitting happens when a strategy's parameters are adjusted repeatedly against the same historical data until the results look strong, effectively tailoring the rules to that specific period's noise rather than to a genuine, repeatable edge. A telltale sign is a strategy with many finely tuned inputs — an unusual stop distance, an oddly specific moving average length — that performs exceptionally on the tested period and considerably worse the moment the data changes even slightly.

A useful check is to split your data: optimise parameters on one portion of history, then run the same unchanged settings on a separate, later portion the optimisation never saw. A strategy that holds up reasonably well out of sample has a better chance of reflecting something real; one that collapses has likely been fitted to noise rather than to a genuine pattern.

Forward testing before scaling up

A backtest, however carefully built, cannot capture everything about live trading — execution quirks, your own behaviour under real risk, and conditions that have not occurred in the tested history. Forward testing on a demo account, watching the strategy trade in real time without financial risk, is the next step, and it should run long enough to see the strategy behave through more than one type of market condition, not just a single favourable week.

Once a strategy has held up in forward testing, moving to a lower-cost evaluation account before committing to a larger funded programme is a sensible way to confirm it holds up under real drawdown pressure and genuine psychological stakes, which no backtest or demo account fully replicates. Treating the evaluation stage itself as part of the testing process, rather than skipping straight to maximum size, tends to produce steadier long-term results.

Frequently asked questions

What is the difference between Every tick and Open prices only in the MT5 tester?

Every tick based on real ticks simulates price movement within each candle using actual historical tick data, giving the most realistic result but requiring more data and processing time. Open prices only uses just the opening price of each candle, running much faster but missing all the detail of how price moved within the bar, which can materially misstate results for strategies sensitive to intrabar movement.

How do I know if my backtest results are curve fitted?

A common warning sign is a strategy with many finely tuned parameters that performs unusually well on one specific historical period. Testing the same unchanged settings on a separate period the optimisation did not use is the most reliable check — a large drop in performance out of sample suggests curve fitting.

Should I go straight from backtesting to a funded account?

It is generally better to forward test on a demo account first, then confirm the strategy on a lower-cost evaluation before committing significant capital or effort. Backtesting and demo trading cannot fully replicate real drawdown pressure, so treating an evaluation as a further, smaller-stakes test is a reasonable step before scaling up.

Trade it on a funded account

MixFunded evaluations start from $5. Payouts are processed every Monday in USDT (TRC-20) and published on-chain.