Introduction
BacktestingBacktestingThe process of testing a trading strategy against historical data to evaluate its performance and expectancy before risking real money.Read full glossary entry → is the process of applying a set of technical trading rules to historical price data to determine how that strategy would have performed in the past. It is the cornerstone of strategy development, transforming speculative ideas into data-backed trading systems. By looking back, you can calculate the mathematical expectancy of your edge before putting capital at risk.
Why It Matters
- Builds Execution Confidence: Knowing your strategy has survived years of historical data helps you execute rules without hesitation during drawdowns.
- Quantifies the Statistical Edge: Provides objective numbers (win rate, average win/loss, max drawdown) instead of subjective guesses.
- Eliminates Unprofitable Systems: Identifies flaws and weaknesses in a strategy before you lose real money executing it.
- Develops Rule Objectivity: Forces you to define clear, mechanical rules for entries and exits.
Key Backtesting Metrics
When analyzing your historical test results, focus on these five core performance metrics:
Metric Calculation / Definition
─────────────────────────────────────────────────────────────────────────────
Win Rate (Number of Winning Trades / Total Trades) * 100
Average Win/Loss Ratio Average Dollar Size of Wins / Average Dollar Size of Losses
Profit Factor Gross Profits / Gross Losses (Should be > 1.2)
Max Drawdown The largest peak-to-trough decline in equity
Expectancy (R-multiple) Average profit per trade expressed as a multiple of risk (R)
The Expectancy Formula
Mathematical expectancy tells you how much you can expect to make per trade on average: $$\text{Expectancy} = (\text{Win Rate} \times \text{Average Win Size}) - (\text{Loss Rate} \times \text{Average Loss Size})$$
How to Conduct a Valid Backtest
- Write Down Strict Rules: You must define entry filters, stop-loss placement, and take-profit targets. If a rule involves "discretion," it cannot be cleanly backtested.
- Select a Diverse Dataset: Gather data spanning at least 2 to 5 years. Ensure this period includes a bull marketBull MarketA market condition characterized by a sustained period of rising prices, optimistic investor sentiment, and strong economic/fundamental indicators.Read full glossary entry →, a bear marketBear MarketA market condition characterized by a sustained period of falling prices, typically defined by a decline of 20% or more from recent highs, accompanied...Read full glossary entry →, and a consolidating (sideways) market.
- Log Every Trade: Keep a spreadsheet recording date, direction, entry, stop, exit, P&L (in R-multiples), and comments. Do not skip losing trades—that is cheating the data.
- Calculate Stats: Run the math to find your win rate, average risk-to-reward ratioRisk-to-Reward RatioA measure used to compare the potential profit of a trade against its potential loss. A ratio of 1:2 means the trader is risking $1 to potentially mak...Read full glossary entry →, and drawdown metrics.
- Forward Test: Execute the exact same rules in real-time on a demo account for 30–50 trades to verify if spreads, commissions, and execution lag alter the results.
Common Mistakes
[!WARNING]
- Curve-Fitting (Over-optimization): Adding complex rules to eliminate historical losses (e.g., "Only buy on Tuesdays if RSI is below 42 and the moon is waxing"). This makes the system match the past perfectly but fail in the future. Keep rules simple and robust.
- Hindsight Bias: Checking what happened after the signal before deciding if you would have taken the trade. When backtestingBacktestingThe process of testing a trading strategy against historical data to evaluate its performance and expectancy before risking real money.Read full glossary entry →, you must slide the chart bar-by-bar and make decisions without looking ahead.
- Ignoring Transaction Costs: Failing to account for commissions, swap fees, and slippage. In high-frequency day trading, these costs can easily turn a profitable strategy into a losing one.