Backtesting: The Complete Guide

Backtesting is the process of applying a set of trading rules to historical market data to measure how those rules would have performed. It is the foundation of systematic trading: before risking real capital, you simulate every trade the strategy would have made, compute Sharpe ratio, CAGR, and maximum drawdown, and decide whether the edge is real or an artefact of overfitting.

Definition

Backtesting — simulating a trading strategy on historical data to generate a trade log and performance statistics. A valid backtest uses only data that would have been available at each decision point, processes bars sequentially, and is validated on data the strategy has never "seen" during development.

Why does backtesting matter?

Without a rigorous historical test, a trading strategy is an untested hypothesis. Markets are noisy: almost any rule produces apparent profits on a short slice of history by chance. Backtesting turns intuition into a falsifiable claim. If the strategy cannot generate positive risk-adjusted returns across multiple years and market regimes, it is unlikely to do so with live capital.

Backtesting also quantifies risk before you experience it. Knowing that a strategy had a 35% maximum drawdown in 2022 lets you decide, in advance, whether you can tolerate that loss — rather than discovering it with real money on the line.

The backtesting process in five steps

Every backtest follows the same sequence regardless of the tool you use. The full step-by-step guide covers each in detail, but the core loop is:

  1. Define entry and exit rules — every condition must be deterministic: indicator, parameter, operator, threshold. "Buy when RSI is low" is not a rule.
  2. Source historical OHLCV data — exchange-sourced, at the resolution your strategy operates on (daily, hourly, minute), covering at least 3–5 years.
  3. Apply rules bar-by-bar — process each bar using only data available at that bar's close. Never look ahead.
  4. Set position sizing — fixed fractional sizing (1–2% of equity per trade) is the standard starting point. Sizing affects drawdown as much as the signals do.
  5. Compute and interpret metrics — Sharpe ratio, CAGR, maximum drawdown, win rate, and profit factor.

Key metrics and what they mean

MetricFormulaTarget
Sharpe ratioAnnualised excess return ÷ annualised volatility> 1.0 (strong: > 2.0)
CAGR(End equity / Start equity)^(1/years) − 1Benchmark-relative
Max drawdownLargest peak-to-trough equity loss (%)< 20% for most traders
Win rateWinning trades ÷ total tradesMeaningless alone
Profit factorGross profit ÷ gross loss> 1.5 is healthy

Win rate is the most misunderstood metric. A strategy that wins 35% of trades but averages a 3:1 win/loss ratio has a positive expectancy — it will make money over enough trades. A strategy that wins 70% of trades but has a 0.3:1 win/loss ratio will lose money. Always evaluate win rate alongside profit factor.

The three biggest backtesting mistakes

Most backtest failures trace back to one of three errors:

1. Look-ahead bias

Using future data — even accidentally — to make a past decision. A signal computed on tomorrow's close but used to trade today's open will look perfect in a backtest and fail immediately in live trading.

2. Overfitting

Tuning too many parameters until the strategy fits historical noise rather than a genuine market pattern. With enough parameters, you can fit any dataset perfectly — and predict nothing.

3. Survivorship bias

Testing only on assets that still exist today, ignoring those that went bankrupt, were acquired, or were delisted. Equity universes constructed this way systematically overstate returns.

How do you validate a backtest result?

The minimum validation requirement is an in-sample / out-of-sample split: develop your strategy on the first 70–80% of your data, then test it exactly once on the remaining 20–30%. If out-of-sample performance degrades significantly, the strategy is overfit.

For more rigorous validation, use walk-forward analysis, which rolls the optimisation and test window forward across the full dataset. This tests whether the strategy is robust across time — not just one lucky split. Monte Carlo simulation adds a further stress-test by randomising trade order and estimating the distribution of possible outcomes.

For statistical rigour, consider the Deflated Sharpe Ratio, which adjusts for the number of strategy trials you ran before selecting the winner.

Topics in this guide

Run your first backtest in minutes — no code required

Describe your strategy in plain English on backtester.run. The platform validates the rules, runs a full zipline backtest on live market data, and returns Sharpe ratio, CAGR, drawdown, and an equity curve.

Start free →

Frequently Asked Questions

What does backtesting a trading strategy mean?
Backtesting means applying a set of trading rules to historical market data to see how those rules would have performed. You define when to buy and when to sell, then replay past price bars and record every simulated trade. The result is a set of statistics — Sharpe ratio, CAGR, maximum drawdown, win rate — that quantify the strategy's historical edge.
Is a good backtest result a guarantee of future profit?
No. A backtest only tells you how a strategy would have performed on the specific data you tested. Markets evolve, regimes change, and overfitting to historical noise is easy. A backtest is a necessary first filter, not a proof of future edge. Validate with walk-forward analysis and out-of-sample testing before trusting any result.
How long should a backtest period be?
At minimum, your backtest should span 3–5 years and include multiple market regimes — a trending period, a choppy sideways period, and at least one significant drawdown event. For daily strategies, 5 years gives roughly 1,250 bars. For intraday strategies, 1–2 years of minute data is typically sufficient.
What data do you need to backtest a strategy?
You need historical OHLCV (open, high, low, close, volume) data for the instrument you plan to trade, at the resolution your strategy operates on. Use exchange-sourced data, not adjusted or synthetic data. For equities, be aware of survivorship bias — your universe should include delisted stocks, not just those that survived to today.
What is the difference between backtesting and paper trading?
Backtesting replays historical data instantly, letting you test years of strategy performance in seconds. Paper trading runs your strategy forward in real time on live data without real money. Both are simulation — neither involves real slippage, partial fills, or the psychological pressure of live capital at risk.
Can you backtest a strategy without knowing how to code?
Yes. backtester.run accepts plain-English strategy descriptions — moving average crossovers, RSI thresholds, stop-losses — and executes a full zipline backtest automatically. You describe the rules; the platform handles the code, data sourcing, and result computation.

© 2026 backtester.run · All rights reserved · support@backtester.run

Backtest results are hypothetical and do not guarantee future performance.