Why usFeaturesTemplatesBlogGlossary

Backtesting Trading Strategies: A Step-by-Step Guide

SEBI’s studies found that 9 in 10 individual F&O traders lose money. The single cheapest defence against joining them is to test an idea on history before risking capital on it. But a backtest only helps if it is honest — and most are not.

A strategy that returned 30% CAGR in a backtest can lose money in production. Not because the data lied. Because the backtest had a bug. Survivorship bias, look-ahead bias, ignored transaction costs: any one of them is enough to turn an honest historical return into a fantasy.

This guide walks through how to backtest properly on Indian markets. Which decisions actually matter. Which biases will eat your returns if you are not watching. How to read the output so you trust the strategies that deserve trust.

What is Backtesting?

Backtesting is the process of testing a trading strategy against historical market data to evaluate how it would have performed in the past. It is the single most important step before deploying any algorithmic trading strategy with real capital.

A good backtest tells you not just whether a strategy is profitable, but how it makes money: during which market conditions, with what level of risk, and whether the results are statistically meaningful or just noise.

Why Backtesting Matters

Without backtesting, you are gambling. With backtesting, you are making informed decisions based on evidence.

Here is what a good backtest reveals:

  • Expected returns: CAGR, total returns, and consistency over time.
  • Risk profile: maximum drawdown, volatility, and worst-case scenarios.
  • Risk-adjusted performance: Sharpe ratio, Sortino ratio, and Calmar ratio.
  • Strategy behaviour: how the strategy performs in bull markets, bear markets, and sideways conditions.

How to Backtest: Step-by-Step

Step 1: Define Your Strategy Rules

Be precise. Vague rules like “buy good stocks” cannot be backtested. You need:

  • Universe: which stocks can the strategy trade? For example, Nifty 500 or Nifty Midcap 150.
  • Entry signal: when to buy. For example, `@ROCP(close, 252) > 0.15` (trailing 12-month return above 15%).
  • Exit signal: when to sell. For example, when a stock falls out of the top 20 by `@ROCP(close, 252)` on the next rebalance.
  • Position sizing: how much to allocate per stock. Equal weight, or weighted by `1 / @ATR(14)`, or another scheme.
  • Rebalance frequency: how often to review. Monthly on the first trading day is a common default.

Step 2: Choose Your Data

Use quality historical data that includes:

  • Adjusted close prices (accounting for splits and dividends).
  • Delisted stocks (to avoid survivorship bias).
  • Sufficient history. At least 10 years is the minimum for meaningful results.

Step 3: Set Realistic Assumptions

Your backtest must account for:

FactorWhy It Matters
Transaction costsBrokerage fees reduce returns on every trade
SlippageYou won’t always get the exact price you see
LiquiditySmall-cap stocks may not have enough volume
TaxesShort-term capital gains tax in India is 15%

Step 4: Run the Backtest

Execute your strategy rules against historical data, day by day or month by month. Track:

  • Portfolio value over time (the equity curve).
  • Individual trades (entry price, exit price, holding period).
  • Rebalance-level changes (what was bought, what was sold, and why).

Step 5: Analyse Results

Do not just look at total returns. Focus on:

  • CAGR: compound annual growth rate. Annualised returns.
  • Maximum drawdown: the largest peak-to-trough decline. This is your worst-case scenario.
  • Sharpe ratio: returns per unit of risk. Above 1.0 is good. Above 1.5 is excellent.
  • Win rate: percentage of profitable trades.
  • Benchmark comparison: did you beat the Nifty 50? If not, the strategy needs a better justification than absolute return.

Common Backtesting Mistakes

1. Look-Ahead Bias

Using information that would not have been available at the time of the trade. For example, using quarterly results data that was published after the trade date.

Fix: ensure all data used in signals was available on or before the decision date.

2. Survivorship Bias

Only testing on stocks that exist today, ignoring delisted companies. This inflates returns because you are excluding stocks that went to zero. A backtest of the “current Nifty 500” run over 2010 to 2024 conveniently excludes every name that fell out of the index: DHFL, YESBANK (during its 2020 collapse), RCOM, JETAIRWAYS. The historical index of 2012 had different constituents from the index of 2025.

Fix: use a survivorship-bias-free dataset that includes delisted stocks and reconstructs the historical universe at each rebalance date. Not today’s constituents projected backwards.

3. Overfitting

Tuning your strategy parameters until the backtest looks perfect. If you optimise 20 parameters across 10 years of data, you will find a “strategy” that works. It will not work in the future.

Fix: keep parameters simple. Use out-of-sample testing. If your strategy needs 10 or more parameters, it is probably overfit.

4. Ignoring Transaction Costs

A strategy that trades 200 times a year with 0.5% slippage per trade will lose 100% of its capital to costs alone, regardless of signal quality.

Fix: always include realistic transaction costs in your backtest. For Indian markets, assume at least 0.1% to 0.3% per trade for slippage and brokerage combined.

5. Cherry-Picking Time Periods

Testing only during bull markets (2020 to 2024) and claiming your strategy “works”. Every strategy works in a bull market.

Fix: test across multiple market regimes including 2008, 2011, 2018, and 2020 (the COVID crash).

Interpreting Backtest Results

MetricGoodWarning
CAGR> Nifty 50 CAGR< 12% (barely beats FD)
Max Drawdown< 20%> 35% (psychologically hard)
Sharpe Ratio> 1.0< 0.5 (too much risk for the return)
Number of Trades20 to 200 per year> 500 per year (cost drag)

What Backtesting Cannot Tell You

Backtesting is essential but not sufficient. It cannot:

  • Predict the future. Past performance does not guarantee future results.
  • Account for regime changes. A new regulation or market structure change can invalidate historical patterns.
  • Capture execution risk. Real-world execution is messier than simulations.

This is why paper trading (forward testing with simulated money) is the critical next step after backtesting.

Conclusion

Done properly, backtesting gives you the confidence to deploy capital systematically. Done poorly, it gives you false confidence in strategies that will fail. The investment in proper methodology pays back the first time it stops you from going live with a curve-fit strategy that would have lost money in production.

What to try next

Run a backtest on saral.money on a survivorship-bias-free Nifty 500 universe across 2010 to 2024. Start with a single-rule momentum strategy (top 20 by `@ROCP(close, 252)`, monthly rebalance) and read the equity curve against the Nifty 500 benchmark. Note where the strategy underperforms. Those years are the truth of the strategy, not the headline CAGR.