General

Backtesting

Last Updated
Quick Definition

Backtesting — Backtesting tests a trading strategy on historical data to see how it would have performed, helping validate ideas before risking capital.

Track Backtesting with JournalPlus

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

MetricWhat It MeasuresGood Value
Win Rate% of winning trades40-60%
Profit FactorGross profit / Gross lossAbove 1.5
Max DrawdownLargest peak-to-trough declineBelow 20%
Sharpe RatioRisk-adjusted returnsAbove 1.0
Trade CountStatistical significance100+ trades

Example: Backtest Results

Strategy: RSI Mean Reversion (2019-2024)

MetricResult
Total Trades156
Win Rate52%
Average Win₹8,500
Average Loss₹4,200
Profit Factor1.72
Max Drawdown15.4%
Annual Return24.6%
Sharpe Ratio1.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

  1. Hypothesis – What market behavior are you exploiting?
  2. Rules – Exact, mechanical entry and exit criteria
  3. In-Sample Test – Develop on historical period
  4. Out-of-Sample Test – Validate on unseen period
  5. Paper Trade – Forward test in real-time
  6. Small Live – Trade with minimal capital
  7. Scale – Increase size if profitable

Common Mistakes

  1. Only testing winners – Test strategies that “look” good but might not be statistically valid.

  2. Too few trades – 20 trades isn’t statistically significant. Need 100+.

  3. Ignoring drawdowns – A 60% drawdown would make you quit in real trading.

  4. 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.

Common Questions

What is backtesting in trading?

Backtesting applies your trading rules to historical data to see how they would have performed. If your strategy says 'buy when RSI crosses above 30,' backtesting shows every such signal and resulting profit or loss over years of data.

Is backtesting reliable?

Backtesting has limitations. Curve-fitting, hindsight bias, and changing market conditions can make backtests look better than real results. Use out-of-sample testing and paper trading to validate.

How do you backtest a strategy?

Define exact rules (entry, exit, stop, target), apply them to historical data, record every trade, and calculate performance metrics. Use software for large datasets or do it manually for recent data.

What is curve fitting in backtesting?

Curve fitting is over-optimizing a strategy to fit past data perfectly. The strategy 'works' historically but fails on new data because it was designed specifically for that past, not for general market behavior.

What software is used for backtesting?

TradingView (Pine Script), Amibroker, MetaTrader, Python with pandas/backtrader, and Excel for simple strategies. Many platforms offer built-in backtesting for technical strategies.

Share this article

Track Backtesting Automatically

JournalPlus calculates your backtesting and other key metrics from your trade data. Import trades and get instant insights.

SSL Secure
One-Time Payment
7-Day Money-Back
4.9/5 (1,287 reviews)
Track Backtesting automatically 7-Day Money-Back
Buy Now - ₹6,599 for Lifetime Buy Now - $159 for Lifetime