How to backtest a trading strategy: a plain guide

A backtest runs a set of trading rules over past prices and records what would have happened. It answers one question: if you had followed these rules over this period, how would it have gone compared with doing something simpler?

It cannot tell you what will happen next. Used carefully, it can tell you whether an idea held up in the past or fell apart, and that is worth knowing before you put money behind it.

Step 1: write the rules down exactly

A rule you can test has no room for judgement. "Buy when the stock looks cheap" cannot be tested. "Buy when the price closes 10% below its highest close of the last 50 days, and sell when it closes back above that high" can. Every entry, exit and position size has to be written so that a computer, or a stranger, would act the same way you would.

Step 2: choose the data and the period

Use daily prices adjusted for splits, and decide how dividends are treated. Test over as long a period as the data allows, and make sure it includes falls as well as rises. A rule tested only through a long rise will look better than it is.

Note where the data comes from and when it ends. Results depend on both.

Step 3: pick the comparison before you look

Decide in advance what the strategy has to beat. For most ideas the honest comparison is buying and holding the same stock or fund over the same dates. If a strategy cannot beat that, the extra effort, risk and tax of trading it are hard to justify.

Step 4: run it and record everything

Record every trade, not just the totals. The useful outputs are the return per year (CAGR), the largest fall from a peak (maximum drawdown), the share of closed trades that made money, the number of trades, the time spent in the market, and the same figures for the comparison.

Step 5: try to break it

This is the step most people skip. Change the settings a little and see whether the result survives. Test on other tickers. Hold back the most recent years, choose your settings on the earlier ones, and then see how those settings did on the years you did not use. A result that only works with one exact setting on one ticker is usually luck.

The mistakes that flatter results

Look-ahead bias. Using information the rule could not have known at the time, such as trading at a day's close using a signal calculated from that same close, or using today's list of index members to test the past.

Survivorship bias. Testing only companies that still exist. The ones that failed and were dropped are missing, so the past looks kinder than it was.

Over-fitting. Trying hundreds of settings and reporting the best one. With enough tries, something will look good by chance. The more variations you test, the stronger the evidence you need before believing any of them.

Ignoring costs. Commission, spreads, foreign-exchange charges and tax all reduce real results, and frequent trading pays them more often. Our own headline figures assume no trading costs, and we say so on every page, so treat them as an upper bound.

Small samples. Ten trades prove almost nothing. Look for hundreds of trades across many years and conditions.

What we found when we did this ourselves

We run the same rules on every published ticker, 553 backtests per ticker from default settings, against buying and holding the same ticker over the same dates. Most of the time the strategy does not win. On SPY, 3 of 553 backtests beat holding. On QQQ, 97 of 553 did, which is 17.5%. On AAPL and MSFT, none did.

Figures are from the StrategyLens published cards, updated 29 October 2026. They are hypothetical backtests with no trading costs, before tax, and they will change as the cards are refreshed.

A list of winners tells you nothing unless you can also see how many tests lost.

A short checklist

Rules written exactly. Long data period with falls in it. Comparison chosen in advance. Every trade recorded. Settings varied, other tickers tried, recent years held back. Costs and tax considered. A large enough sample. If a backtest you are reading skips several of these, treat its result with care.

Reading someone else's backtest

Most backtests you will see were run by someone else, often someone selling the strategy. A few signs make a result more believable. The rules are written out in full. The test period is long and includes at least one serious fall. The number of trades is stated. The comparison with buying and holding is shown on the same page. Costs are stated, even if they are set to zero. And losing tests are shown as well as winning ones.

A few signs should make you more careful. A smooth rising line with no explanation of the rules. A test that starts just after a market low. A single ticker, chosen after the fact. Returns quoted without a drawdown. And phrases such as "guaranteed" or "never lost a year", which no honest backtest can support.

None of this proves a strategy works or fails. It tells you how much weight the result can bear, which is the right question to ask of any past test.

This is research, not financial advice. Past results, real or simulated, do not tell you what will happen next.

What is backtesting?

Running a fixed set of trading rules over past prices to see what would have happened, usually compared with simply buying and holding the same thing over the same dates.

Can a backtest predict future returns?

No. It describes the past under stated assumptions. It can show whether an idea held up before, which is useful, but markets change.

What is the most common backtesting mistake?

Trying many settings and reporting the best one. With enough attempts something looks good by chance, so test on other tickers and on years you did not use to choose the settings.