Strategy & risk · testing an edge

How to Backtest a Trading Strategy

Backtesting tells you whether a strategy has an edge before you risk money on it. Learn how to test rules honestly, the traps of overfitting, and why forward testing is the real proof.

Amir Wahab 8 min read 1,350 words
70–80% of retail investor accounts lose money trading CFDs. This page is education, not advice. All trade examples are constructed composites.

The short answer

Backtesting is checking how a strategy would have performed on past data, to see if it has an edge before you risk real money. Do it honestly: write objective rules a stranger could follow, test a large sample across different conditions, and measure the result as expectancy in R. The great danger is overfitting — tuning a strategy until it looks perfect on history and then fails live. The real proof is forward testing on data the strategy has never seen.

Why backtest at all?

Trading an untested strategy is gambling with extra steps — you have no idea whether it has an edge. Backtesting lets you estimate that edge cheaply, on history, before a cent is at risk. It answers the only question that matters: over many trades, does this make money?

It also builds the confidence to follow a plan through a losing streak, because you have seen the strategy survive drawdowns before. You cannot trust rules you have never tested.

Define objective rules

A strategy you can backtest must be mechanical enough to be unambiguous: exact entry conditions, a defined stop, a defined target or exit. If two people reading your rules would take different trades, the rules are too vague to test.

Writing rules this precisely is valuable in itself — it forces you to turn a vague idea (“buy the dip”) into something concrete you can actually execute and measure.

Gather a large enough sample

A handful of trades proves nothing; luck dominates. Aim for a large sample — at least 100 trades, more if you can — spanning different market conditions: trends, ranges, high and low volatility. A strategy that only worked in one 2020-style trend is not a strategy.

Record each trade's result in R, then compute the expectancy and the worst drawdown. Those two numbers tell you whether the edge is real and whether you could survive trading it.

The trap: overfitting

Overfitting is the cardinal sin of backtesting: adding rules and tweaking parameters until the strategy looks flawless on past data. A curve fit perfectly to history describes the past, not the future, and it falls apart the moment conditions change.

Guard against it with simplicity — fewer rules and round, un-tuned parameters generalise better. If a setting looks magical, be suspicious. The goal is a robust edge that works roughly everywhere, not a fragile one that works perfectly nowhere but the sample.

Forward test before you scale

The honest final step is forward testing: running the strategy on new data it has never seen — either on a demo account or with micro lots in live conditions. This is the only test that cannot be gamed, because you cannot fit to data that has not happened yet.

Only after a strategy holds up forward, on a decent sample, does it earn real size. Backtest to find a candidate edge; forward test to confirm it; then scale slowly. Past results are evidence, never a promise.

Frequently Asked Questions

What is backtesting a trading strategy?

Backtesting is checking how a strategy would have performed on historical price data to estimate whether it has an edge before risking real money. It measures results like expectancy and drawdown over many past trades.

How many trades do I need to backtest?

At least 100 trades, and ideally more, across different market conditions — trends, ranges, high and low volatility. A small sample is dominated by luck and cannot confirm an edge.

What is overfitting in backtesting?

Overfitting is tuning a strategy's rules and parameters until it looks perfect on past data. Such a strategy describes history rather than predicting the future, and it typically fails in live trading. Simplicity guards against it.

Is backtesting enough to trust a strategy?

No. Backtesting can be gamed by overfitting, so the real proof is forward testing — running the strategy on new data it has never seen, on demo or with micro lots — before scaling up.

What should I measure when backtesting?

Record each trade's result in R-multiples, then calculate the strategy's expectancy and its worst drawdown. Those tell you whether the edge is positive and whether you could survive trading it.


On this page

More in this pillar

Go deeper: method & risk.

Related guides

Keep going.