Skip to content
Log in
← Glossary

backtest

Running a rule on past prices to see how it would have done; useful, but easy to fool yourself with.

A backtest is a replay of a trading rule on historical prices to estimate how it would have performed. It lets someone inspect a rule against past data before using it in a live setting.

A useful test defines its rule and costs first, then applies them consistently to a suitable set of past observations. It should account for fees, spread, slippage, and what information would actually have been available at the time.

A backtest describes one historical simulation, not a forecast. Always ask what could be wrong with the test: incomplete data, accidental tuning, or a period that does not resemble future conditions can make the result misleading.

Example

Marc tests a simple fictional rule on four Northwind Foods price moves: buy after a daily rise and close at the next day's end. The four before-cost results are +$4, −$2, +$3, and −$1.

Working: total before costs = 4 − 2 + 3 − 1 = $4. If each of four trades costs $0.50 in fees and spread, total costs are 4 × $0.50 = $2; simulated net = $4 − $2 = $2. Four trades are far too few to establish a reliable pattern. What could be wrong with this test? It may use too few trades, omit slippage, or reflect a market period the rule was tuned to.

Common mistakes

  • Treating a historical result as a forecast or proof of future performance.
  • Leaving out spread, fees, or slippage.
  • Changing the rule repeatedly after seeing the test results.
  • Most people who trade lose money.

Learn it in the course