Skip to content
Glossary

Backtesting

Updated 28 November 2026 · 4 min read · Reviewed against our editorial policy

In brief

Backtesting is the process of applying a fixed rule to historical market data to estimate how it would have performed. It is a useful filter for ideas and a way to understand a strategy's past behaviour, but it does not predict future returns. Its results are only as reliable as the data and assumptions behind them, and the main errors to guard against are overfitting, look-ahead bias, survivorship bias and unrealistic transaction costs.

  • A backtest shows how a rule would have behaved on one historical data set, not how it will behave next.
  • Overfitting, look-ahead bias and survivorship bias can each make a poor rule look strong, so test for them deliberately.
  • Transaction costs, slippage and taxes must be modelled realistically, because frequent trading can turn a paper profit into a loss.

Backtesting is the process of applying a fixed set of trading or investment rules to historical market data to see how that rule would have performed before any real money is committed.

How it works

A backtest has four parts: a precisely stated rule (entry, exit and position sizing), a historical data set, a simulation engine that steps through time, and a set of performance measures. The simulator should only use information that was available on each historical date, and it should charge the costs a real investor would pay. The output is typically an equity curve with annual return, volatility, maximum drawdown and a risk-adjusted measure such as the Sharpe ratio.

Backtesting answers the question 'what would this rule have done?' It cannot tell you what the rule will do. Past data is one sample of market behaviour, and the future may look different.

Worked example

Suppose a rule holds a broad equity index when its price closes above its 200-day moving average, and holds cash otherwise. Using hypothetical data over ten years, the starting value is 10,000 units.

  • Gross result: the rule grows to 16,500 units, compared with 15,000 units for holding the index throughout.
  • Costs: the rule trades 40 times over the decade. If each trade costs 0.1% of the amount traded, and the portfolio is about 10,000 units, each trade costs roughly 10 units, or about 400 units in total.
  • Net result: about 16,100 units, still ahead of simple holding in this illustration.

The lesson is not that the rule works. The result depends on one data set, one period and one set of assumptions. Changing the moving average to 180 or 220 days might reverse the ranking, and that sensitivity is itself important information.

Why it matters to investors

Backtesting is useful for filtering ideas. A rule that loses money even before costs over a long and varied history is unlikely to be robust. It also shows what a strategy has historically felt like, including deep drawdowns, long stretches of underperformance and how often it trades. That experience matters, because investor behaviour often breaks a strategy before the numbers do.

The real danger is false confidence. A smooth, rising equity curve can be produced by mistakes in the test itself, which is why careful design matters more than the size of the apparent return.

Common mistakes

Overfitting

Overfitting happens when a rule is tuned so closely to past noise that it captures coincidences rather than repeatable patterns. With enough parameters, almost any history can be fitted. A warning sign is a rule with many thresholds that works well only at one exact setting. Out-of-sample testing, where parameters are chosen on one period and checked on a later period never used for tuning, is the standard safeguard.

Look-ahead bias

Look-ahead bias occurs when the test uses information that was not known at the time of the decision. Examples include using a company's annual earnings before they were published, or triggering a trade at the same closing price that generated the signal. Every signal should be lagged to the moment it would actually have been observable.

Survivorship bias

Survivorship bias occurs when the data set includes only assets that still exist today. Companies that failed, were delisted or were merged away are missing, so the historical universe looks better than it was. A test of 'the largest companies' built from today's list quietly selects past winners. Point-in-time data, which includes securities as they existed on each historical date, reduces this problem.

Transaction costs and frictions

Many simple backtests ignore costs. Brokerage, taxes where relevant, bid-ask spreads, slippage and market impact all reduce results, and they compound with trading frequency. A rule that trades daily can look profitable on paper and lose money after realistic costs. Costs should be modelled conservatively, and the sensitivity of results to them should be tested.

Other pitfalls

Short histories may contain only one market regime. Unadjusted prices after a stock split or a dividend can create false signals. Changing the rule after seeing its results is a form of overfitting, even when no formal optimiser was used.

What to watch out for

Ask whether the rule was defined before the test, whether the data is point-in-time, whether costs are realistic and whether the result holds on data that was not used to design the rule. A backtest that passes these checks is still only evidence, not proof.

Related concepts

Useful companion ideas include the Sharpe ratio for risk-adjusted return, drawdown for measuring peak-to-trough losses, slippage for the gap between expected and actual execution prices, volatility for how much returns fluctuate, and the benchmark index against which any rule should be compared.

Frequently asked questions

Can a strong backtest prove that a strategy will work in the future?

No. A backtest shows how a rule behaved on a specific historical data set under specific assumptions. Markets change, and a pattern that existed in one period may not persist, so a backtest is best treated as evidence to be tested further, not as a forecast.

How can I tell whether I have overfitted a rule?

A common sign is that performance collapses when a parameter is changed slightly, such as moving an average from 200 to 210 days. Another sign is that the rule was adjusted many times after seeing poor results. Testing the rule on a holdout period it was never tuned on is the most practical check.

Why do backtests usually look better than live results?

Backtests often contain small advantages that are hard to repeat in practice, including look-ahead bias, survivorship bias, unrealistic execution prices and understated costs. Live trading also introduces behavioural errors, such as abandoning a rule after a loss. Conservative assumptions about costs and execution help narrow the gap.

Continue learning

Educational content only — not investment, tax or legal advice. See our disclaimer.