How to Backtest a Strategy Properly
A backtest is not proof that a strategy works. It is a check that the strategy did not obviously fail on one particular slice of history.
Backtesting is the only way to evaluate a strategy without spending money, and it is also the easiest place in trading to fool yourself. The difference is process.
Start with the data
Bad data produces confident nonsense. Check for gaps, obviously wrong prices, and whether corporate actions have been adjusted. For equities, ensure delisted companies are included — testing only survivors systematically inflates results.
Use the longest history you reasonably can, covering more than one market regime. A strategy tested only through a bull market has not been tested.
Model costs pessimistically
- Spread — assume you cross it on both sides.
- Commission — use your actual broker's schedule.
- Slippage — assume worse fills than the bar close, especially on stops and around news.
- Financing — overnight costs matter for leveraged or multi-day positions.
If the strategy only works with optimistic cost assumptions, it does not work.
Validate across time, not at random
Do not shuffle. Use walk-forward validation: train on one window, test on the next, roll forward, repeat. Every test period must be strictly later than the data that produced the model being tested. Keep a final block untouched until you are finished developing, and look at it once.
Look past total return
Total return is the least useful headline number. What matters:
- Maximum drawdown — can you actually sit through it?
- Sharpe or Sortino — return relative to the risk taken.
- Expectancy per trade — what you earn on average.
- Trade count — twenty trades is an anecdote, not a sample.
- Consistency across periods — or is one exceptional stretch carrying everything?
- Worst losing streak — because you will experience it.
Sanity checks before you believe it
Treat an exceptional backtest as a bug report until you have proven otherwise.
Shuffle your labels — performance should collapse to chance. Perturb your parameters — results should degrade gradually, not fall off a cliff. Remove the best month — if profitability disappears, the edge was one event.
What to expect live
Worse. Always worse. Regime change, costs you did not model and execution reality all take their share. A strategy that is only viable if live matches backtest is not viable. Build in that margin before you commit capital.
Educational content only. Not financial advice. Backtested results do not guarantee future performance.
See the models in action
Reading about forecasting is one thing. Create a free account and get 5 AI predictions a month — no card required.
Start free