Pillar Guide · 11 min read

How to Backtest a Trading Strategy: The Complete Guide

Backtesting lets you evaluate a strategy before risking real capital. But most traders backtest incorrectly — optimising for past data instead of testing genuine edge. This guide covers the full process from data selection to forward testing.

Why backtest at all?

A backtest answers the question: “Did this strategy have positive expectancy over a large historical sample?” It forces you to make your rules explicit, provides statistical context for what realistic performance looks like, and helps you avoid abandoning a good strategy during a normal drawdown.

The key word is “correct.” A backtest that is over-fitted to historical data gives false confidence and is more dangerous than no backtest at all.

The 6-step backtesting process

1
Define the rules explicitly
Write down your exact entry and exit conditions before looking at any chart. Rules must be objective enough that two traders would take the same trade. If there is ambiguity, the backtest is invalid.
2
Select historical data
Use at least 2-3 years of data across multiple market conditions. Include both trending and ranging markets. A strategy that only works in a bull market is not a strategy — it's just leveraged exposure.
3
Run the test (walk-forward)
Split your data into an in-sample training period and an out-of-sample test period. Optimise only on the training set, then verify on the test set without any modification.
4
Calculate key metrics
Win rate alone is insufficient. Track: profit factor, maximum drawdown, average R-multiple, Sharpe ratio, and longest losing streak. A valid strategy should have at least 100 trades in the sample.
5
Stress test the parameters
If changing an entry parameter by 10% destroys the results, the strategy is curve-fitted. A genuine edge should be robust to small parameter changes.
6
Forward test before going live
Paper-trade the strategy in real-time for at least 30 trades. If the results are broadly similar to the backtest, proceed to small live size.

Common backtesting mistakes

Look-ahead bias
Using information that wasn't available at the time of the trade (e.g., using a daily close to trigger an intraday entry). Always verify your signals are based only on data available at bar open.
Survivorship bias
Only testing on stocks that still exist today ignores the many that went bankrupt. Use point-in-time data for equity backtests.
Ignoring transaction costs
Slippage and commissions can easily consume 20-30% of apparent edge, especially on high-frequency strategies. Always include realistic costs.
Too few trades
Less than 50 trades is noise. At 30 trades, a coin flip can look like a 60% win rate. Require at least 100 trades.
Over-optimising parameters
Testing 50 parameter combinations to find the best-performing one is curve fitting by definition. Use one or two reasonable parameters and test them once.

Frequently asked questions

What is backtesting in trading?

Backtesting is the process of applying a trading strategy to historical price data to evaluate how it would have performed. It provides an objective measure of a strategy's win rate, R:R, profit factor, and maximum drawdown before risking real capital.

What is curve fitting in backtesting?

Curve fitting (or overfitting) is when a trading strategy is optimised so precisely for historical data that it has no predictive value for future performance. A curve-fitted strategy typically shows exceptional backtest results but fails in live trading. It is identified by excessive parameters, very limited trade sample sizes, or results that are too consistent to be realistic.

How many trades do I need for a valid backtest?

A reliable backtest requires at least 100 trades, preferably 200+, across multiple market conditions (trending and ranging, bull and bear). Fewer than 50 trades is statistically unreliable — variance will dominate the results.

What is the difference between backtesting and forward testing?

Backtesting tests a strategy against historical data. Forward testing (paper trading) applies the same strategy in real-time to future data — but without real money at risk. Forward testing validates that the backtest results were not the product of curve fitting.

Backtest strategies inside Tradapt

Tradapt's backtest tool lets you test strategies on real historical candle data with built-in SMA crossover strategies — or define your own rules.

Start for free

Continue learning