Backtesting tests a trading strategy against historical market data to evaluate how it would have performed. By applying your trading rules to past prices, you can measure potential profitability, win rate, and drawdowns before risking real money. It’s a crucial step in strategy development—though backtests have limitations and must be validated with forward testing.
- Tests strategies on historical data to measure potential performance
- Helps validate ideas before risking real capital
- Beware of curve-fitting and over-optimization
How Backtesting Works
Backtesting simulates trading on past data:
Backtest Process:
1. Define Strategy Rules
Entry: Buy when price crosses above 20 EMA
Exit: Sell when price crosses below 20 EMA
Stop: 3% below entry
2. Apply to Historical Data
Test period: Jan 2020 - Dec 2024
Stock: NIFTY 50
Timeframe: Daily
3. Record All Trades
Trade 1: Buy ₹11,500, Sell ₹12,200 = +6.1%
Trade 2: Buy ₹12,100, Stop ₹11,737 = -3.0%
... (100+ trades)
4. Calculate Metrics
Win Rate: 45%
Average Win: 8.2%
Average Loss: 3.1%
Profit Factor: 1.9
Max Drawdown: 12%
Quick Reference: Backtest Metrics
| Metric | What It Measures | Good Value |
|---|---|---|
| Win Rate | % of winning trades | 40-60% |
| Profit Factor | Gross profit / Gross loss | Above 1.5 |
| Max Drawdown | Largest peak-to-trough decline | Below 20% |
| Sharpe Ratio | Risk-adjusted returns | Above 1.0 |
| Trade Count | Statistical significance | 100+ trades |
Example: Backtest Results
Strategy: RSI Mean Reversion (2019-2024)
| Metric | Result |
|---|---|
| Total Trades | 156 |
| Win Rate | 52% |
| Average Win | ₹8,500 |
| Average Loss | ₹4,200 |
| Profit Factor | 1.72 |
| Max Drawdown | 15.4% |
| Annual Return | 24.6% |
| Sharpe Ratio | 1.4 |
Interpretation: Promising but needs out-of-sample validation.
Backtesting applies trading rules to historical data to measure potential performance. It helps validate strategies before risking capital. Watch for curve-fitting—over-optimization that fails on new data. Always forward test after backtesting.
Backtest Pitfalls
Curve Fitting
Over-optimizing parameters to fit historical data. Works on past, fails on future.
Example: “RSI 14 didn’t work, but RSI 11.5 with 33/67 thresholds is perfect!” This is likely curve-fitted.
Survivorship Bias
Using only stocks that exist today. Many failed companies aren’t in the data.
Look-Ahead Bias
Using information that wouldn’t have been available at trade time.
Ignoring Costs
Brokerage, slippage, and impact costs reduce real returns vs backtest.
Best Practices
Use Out-of-Sample Testing
Develop on 70% of data, test on remaining 30% that wasn’t used.
Keep Rules Simple
Fewer parameters = less curve-fitting risk. Simple strategies often beat complex ones.
Include Costs
Add realistic brokerage and slippage. 0.05-0.1% per trade for stocks.
Test Multiple Markets
Strategy that works on multiple stocks/markets is more robust.
Forward Test
After backtesting, paper trade or trade small to validate in real-time.
Backtest Workflow
- Hypothesis – What market behavior are you exploiting?
- Rules – Exact, mechanical entry and exit criteria
- In-Sample Test – Develop on historical period
- Out-of-Sample Test – Validate on unseen period
- Paper Trade – Forward test in real-time
- Small Live – Trade with minimal capital
- Scale – Increase size if profitable
Common Mistakes
-
Only testing winners – Test strategies that “look” good but might not be statistically valid.
-
Too few trades – 20 trades isn’t statistically significant. Need 100+.
-
Ignoring drawdowns – A 60% drawdown would make you quit in real trading.
-
Perfect entry assumptions – Real trading has slippage and partial fills.
How JournalPlus Supports Backtesting
JournalPlus logs your trades for forward-testing comparison. Track whether live results match your backtest expectations and identify where reality differs from simulation.