Browse the library

Glossary

Backtesting

Testing a trading rule on historical data to see how it would have performed, before risking money on it.

On this page
  1. How it works
  2. Common traps
  3. Related terms

Backtesting is the process of applying a precisely defined trading or investing rule to historical market data to estimate how it would have performed. It turns an idea such as "buy when the 50-day average crosses above the 200-day" into numbers: total return, win rate, average gain and loss, and the worst drawdown. A backtest is a cheap way to reject a bad idea before it costs real money, but a good backtest is far from proof that a strategy will work.

How it works

  1. Write the rules so that a computer could follow them with no judgment: entry, exit, position size and which securities qualify.
  2. Run them bar by bar over past data, using only information available at each point in time.
  3. Subtract realistic costs: commissions, the bid-ask spread and slippage.
  4. Measure results and compare them with simply holding a benchmark.

Common traps

  • Overfitting. Tuning parameters until the past looks perfect captures noise. A strategy with many knobs almost always backtests well and trades badly.
  • Look-ahead bias. Using data that was not yet known, such as a day's closing price to trade at that day's open, or later-revised earnings.
  • Survivorship bias. Testing only companies that exist today leaves out the ones that went bankrupt or were delisted.
  • Too few trades or one market regime. Twenty trades in a rising market prove little.

Safeguards include holding back an out-of-sample period, walk-forward testing and then paper trading before using real money.

Written and fact-checked by Finabase Research. Last reviewed . Spotted an error? Tell us.

Educational content, not investment advice. Finabase Learn explains how markets and tools work. It does not recommend any security or strategy, and examples are for illustration only. Investing involves risk, including the loss of principal. Rules and figures are for the United States unless stated and can change — check the cited source before you act.