Backtesting is how you validate whether a trading strategy has an edge before risking real money. Done properly, it separates strategies worth trading from strategies that only look good in hindsight.
Done poorly, it gives you false confidence in strategies that will fail live.
What Backtesting Actually Tests
Backtesting answers one question: Would this strategy have been profitable over historical data?
It does NOT answer:
- Will it be profitable in the future? (no guarantee)
- Will I be able to execute it consistently? (that’s a behavioral question)
- Are the market conditions that created the edge still present?
Understanding these limitations is crucial. A backtest is a necessary but insufficient condition for strategy viability.
The Backtesting Process
Step 1: Define Rules Precisely
Your strategy must be specific enough that two people would take the same trades:
Bad: “Buy when the stock looks oversold.”
Good: “Buy when RSI(14) crosses above 30 on the daily chart, price is above the 200-day SMA, and volume is above the 20-day average.”
Every entry, exit, position sizing, and stop loss rule must be explicit.
Step 2: Split Your Data
Never backtest on the same data you used to develop the strategy.
- In-sample period: The data you use to develop/optimize the strategy (e.g., 2020-2023)
- Out-of-sample period: Data the strategy has never seen (e.g., 2024-2025)
- Walk-forward period: Recent data for final validation (e.g., 2026)
If a strategy works in-sample but fails out-of-sample, it’s curve-fitted — not a real edge.
Step 3: Account for Real-World Costs
Your backtest must include:
- Commissions: Per-trade or per-share fees
- Slippage: The difference between your expected price and actual fill (typically 0.05-0.2% for liquid instruments)
- Spread: Bid-ask spread, especially for less liquid instruments
- Borrowing costs: For short positions (hard-to-borrow fees)
A strategy that shows 15% annual returns before costs might show 5% after costs — or negative returns for high-frequency approaches.
Step 4: Evaluate the Right Metrics
Profit alone is not enough. Evaluate:
| Metric | What It Tells You |
|---|---|
| Net Profit | Total returns after costs |
| Win Rate | Percentage of winning trades |
| Profit Factor | Gross profit ÷ gross loss (>1.5 is good) |
| Max Drawdown | Worst peak-to-trough decline |
| Sharpe Ratio | Risk-adjusted returns (>1.0 is decent) |
| Number of Trades | Statistical significance (need 100+) |
| Expectancy | Average $ per trade |
Full guide to trading metrics.
Common Backtesting Mistakes
1. Curve Fitting (Overfitting)
The #1 mistake. Adding rules or parameters until the strategy perfectly fits historical data.
Signs of curve fitting:
- Strategy has many parameters (5+) tuned to specific values
- Works spectacularly on one time period, poorly on others
- Small changes in parameters destroy performance
- Uses obscure indicators or unusual lookback periods
Prevention: Use out-of-sample testing. If it doesn’t work on data it hasn’t seen, it’s not a real edge.
2. Survivorship Bias
Testing only on stocks that exist today. Stocks that went bankrupt or were delisted are ex