✦ Guide

How to backtest a trading strategy

By Fraser AI Solutions · Updated

The short answer

Backtesting runs your exact trading rules on historical data to see how they would have performed. A useful backtest uses clean data, realistic costs, rules written before testing, and out-of-sample checks — and is still no guarantee of future results.

What a backtest is — and isn't

A backtest applies precise trading rules to past market data to estimate how a strategy would have behaved. It's a way to reject bad ideas cheaply. It is not proof that a strategy will work in the future.

Step by step

  1. Write the rules down first. Entry, exit, position size and stop-loss rules must be exact enough that a computer can follow them with no judgment calls.
  2. Get suitable data. Use data that matches how you'll trade (daily vs. intraday), adjusted for splits and dividends, and covering different market conditions.
  3. Model costs honestly. Include commissions, the bid-ask spread and slippage. Many strategies that look profitable disappear once costs are included.
  4. Hold data back. Develop on one period and test on another you haven't looked at (out-of-sample), or use walk-forward testing.
  5. Look beyond total return. Check maximum drawdown, the number of trades, win rate, and how results change across years.
  6. Paper trade. Run the strategy live with simulated money before risking capital.

The biases that make backtests lie

BiasWhat happensHow to avoid it
OverfittingRules are tuned until they fit past noise perfectlyFew parameters, out-of-sample tests
Look-ahead biasThe test uses information that wasn't available at the timeOnly use data available at each decision point
Survivorship biasDelisted or bankrupt stocks are missing from the dataUse survivorship-free data sets
Ignoring costsFees and slippage are left outModel realistic costs on every trade

From backtest to trading bot

If a strategy survives honest testing and paper trading, it can be automated through a broker's API — with risk controls such as maximum position size, daily loss limits and a kill switch. Fraser AI Solutions builds custom backtests and trading bots to each trader's specification.

This guide is general education, not investment advice. Trading involves risk of loss, and past performance — real or backtested — doesn't predict future results.

Want this set up for you?

We install, tune and manage it — you run your business.