How to backtest a strategy without fooling yourself
Backtesting runs a strategy over historical data to estimate how it would have performed. Done well, it filters out bad ideas cheaply. Done badly — with lookahead bias, ignored costs, or tuning on the same data you test on — it manufactures confidence in strategies that lose real money. This is the honest, step-by-step process.
The backtesting process, step by step
- Define exact rules — entry, exit, stop, and position size, with no ambiguity a human has to resolve.
- Get clean historical data — real OHLCV from the exchange you will trade, covering different market regimes.
- Simulate trade by trade — apply the rules bar by bar, only using information available at that moment.
- Subtract realistic costs — fees, spread, and slippage on every fill.
- Measure the right metrics — not just return, but drawdown, Sharpe, and win rate vs risk-reward.
Data and cost assumptions decide everything
A backtest is only as honest as its assumptions. Use real historical data from the venue you trade — survivorship-biased or gappy data quietly inflates results. And cost matters enormously: a high-frequency strategy that ignores the bid-ask spread can show a fat profit that evaporates the moment you add a realistic 0.1% round-trip cost. Where to get clean data is covered in backtesting data sources.
The biases that manufacture a fake edge
Lookahead bias — using data that would not have been available yet (e.g. the bar's close to decide a trade taken at its open). Overfitting — tuning parameters until the curve looks perfect on the test data, fitting noise rather than signal (see overfitting in trading). Survivorship bias — testing only on assets that still exist, ignoring the ones that went to zero. Each one turns a losing idea into a beautiful backtest.
Validating the result
The single most important discipline is out-of-sample testing: tune on one period, then test on a separate period the strategy never saw. If the edge survives, it is more likely real; if it collapses, it was a curve-fit. Walk-forward analysis formalises this. Run your rules in our browser backtester, then forward-test with paper trading before risking capital.
Frequently asked questions
How do I backtest a trading strategy?
Define exact rules, get clean real historical data covering several market regimes, simulate the rules bar by bar using only information available at the time, subtract realistic fees and slippage, and measure drawdown and Sharpe — not just return.
What is lookahead bias in backtesting?
It is accidentally using information that would not have been available at the moment of the trade — for example, using a bar's closing price to decide a trade supposedly taken at its open. It makes a strategy look far better than it could ever be live.
Why do good backtests fail live?
Usually because of overfitting (parameters tuned to historical noise), ignored trading costs, lookahead bias, or testing only on a favourable period. Out-of-sample and walk-forward testing expose most of these problems.
How much historical data do I need?
Enough to cover multiple market regimes — trending, ranging, and at least one crash. A backtest over a single calm year will badly overstate the edge of most strategies.