How to Backtest Trading Strategies
Backtesting a trading strategy means testing its rules against historical market data to see how it would have performed — before you risk real money. Done well, it is the closest thing traders have to a controlled experiment. Done badly, it produces confident nonsense. This guide covers how to backtest trading strategies properly, the metrics that actually matter, the mistakes that fool most people — and 15 real backtests we ran on NIFTY and BANKNIFTY so you can see each idea in action.
What is backtesting?
Backtesting in trading is the process of applying a set of trading rules to past price data and recording the results as if you had traded them at the time. If your rule is “buy NIFTY when the 20-day average crosses above the 50-day average,” a backtest walks through history, takes every signal that rule would have fired, and tallies the profit, loss and risk along the way. The output is not a prediction — it is evidence about whether an idea has any edge, and what it costs you to hold.
Why backtest before you trade
- It separates ideas that work from ideas that just sound good.
- It reveals the drawdown you would have to sit through — the number that actually blows up accounts.
- It lets you compare variants objectively — entry times, stops, strikes — instead of by gut feel.
- It builds the conviction to stick with a strategy through its inevitable rough patch.
How to backtest a trading strategy, step by step
- 1. Define the rules precisely. Entry, exit, position size and stop, with no ambiguity. “Buy the dip” is not a rule; “buy at the close of any day NIFTY falls more than 1%, exit next close” is.
- 2. Use quality historical data. Clean, and granular enough for your strategy — minute-level (and the full option chain) for intraday and options strategies, daily for swing systems.
- 3. Run it over a meaningful sample. Enough trades to be statistically real, and across different market regimes — trending and range-bound. A single bull year flatters everything.
- 4. Measure the right metrics. Not just the return (see below).
- 5. Stress-test the parameters. Vary the entry time, the stop, the strike. If the result collapses when you nudge a setting, it was overfit to the past, not a real edge.
The metrics that matter (and the one that lies)
A single return number tells you almost nothing. Judge a strategy on the full picture:
- Win rate — how often you win. Necessary, but deeply misleading on its own.
- Average win vs average loss — the asymmetry that actually decides profitability.
- Net P&L — the bottom line in points or rupees, after costs.
- Maximum drawdown — the worst peak-to-trough fall. The survival number.
- Sharpe ratio — return per unit of risk; how smooth the ride is.
- Equity curve — the shape. A smooth climb and a jagged one can share the same endpoint and be completely different strategies to live with.
The mistakes that fool most backtesters
- Overfitting (curve-fitting). Tuning a strategy until it fits the past perfectly — it then fails live. The more knobs you turn, the more suspicious a great result should make you.
- Look-ahead bias. Using information the trade would not have had at the time — like using the day's closing price to decide a morning entry.
- Survivorship bias. Testing only on instruments or periods that happened to survive, quietly ignoring the ones that didn't.
- Ignoring costs and slippage. Brokerage, taxes and the gap between the price you see and the price you get. A strategy that churns thousands of trades can be wiped out by costs alone.
- Too-short a sample. A strategy that only ever saw a bull market has not been tested — it has been flattered.
- Idealized fills. Assuming a stop fills exactly at its level. We made this exact mistake testing a straddle stop-loss — a perfect-fill assumption made the stop look great; using realistic fills flipped the conclusion entirely.
15 real backtests to learn from
Every principle above is easier to see in a real example. Here are the studies we have run — each a complete, honest backtest on NIFTY or BANKNIFTY, with the equity curve and the caveats spelled out:
Myth-busting
- 53% win rate, and it still lost money — why win rate lies — This NIFTY breakout strategy won more often than it lost, and ended in the red. A lesson in the most misread metric in trading.
- The 'buy the dip' myth: buying NIFTY after every red day — Does the reflex actually pay? Tested on two years — it returned 0% while just holding returned 35%.
- NIFTY's entire two-year rally happened overnight — Split NIFTY's return into the overnight gap and the intraday session. One made +11,247 points. The other lost money.
Option selling
- The 9:45 AM NIFTY short straddle — what a year of data really says — Everyone sells it. The win rate is only 41% — and it still made money. Here's why that's not a contradiction.
- Expiry-day option selling: is it really free money? — Selling the expiry-day straddle won more than half its trades — and still lost money over two years. The tail is the whole story.
- Straddle vs strangle on NIFTY — which survives the drawdown? — Same data, same rules, ATM straddle vs 300-point strangle. The straddle earned more points — and the strangle was the better trade.
- Does a stop-loss help the short straddle? Not the way you'd think — No stop, a fixed 40-point stop, or a trailing stop — run on the same NIFTY straddle. The stop you'd expect to help hurt the most.
- 9:20, 9:45 or 10:15? When to sell the NIFTY straddle — Same straddle, three entry times, two years of data. Waiting half an hour tripled the return — but there's a reason it isn't later.
Intraday
- Opening-range breakout: buy the breakout, or sell the option? — Same NIFTY breakout signal, two ways to trade it. Buying the option lost. Selling the other side won +2,063 points — with a catch.
- VWAP intraday on BANKNIFTY, backtested — Go long above VWAP, exit below — the most-drawn line in intraday trading. Over two years it churned 4,205 trades and bled.
- Fade the gap or chase it? NIFTY opening gaps, tested — When NIFTY gaps more than 0.3% at the open, does the gap fill or run? Two years, 194 gap days, one clear answer.
Greeks
- Selling the 0.1-delta strangle — does far-OTM actually protect you? — We backed out the delta of every NIFTY strike from live prices and sold the 0.1-delta strangle. Win rate: 77%. But read the loss column.
Trend following
- Does the 20/50 moving-average crossover work on NIFTY? — The 'hello world' of trend following, tested. It returned +9% — but how it got there is the whole lesson.
Comparison
- NIFTY vs BANKNIFTY for intraday option selling — Same strategy, same ~40% win rate on both — but the ride was very different. The debate, settled with data.
Seasonality
- Is any weekday better for NIFTY? Two years of day-of-week returns — Friday carried the index; Tuesday was the only red day. A look at NIFTY's day-of-week seasonality — with the usual caveat.
Backtesting on Indiquant
Indiquant lets you backtest trading strategies on NIFTY and BANKNIFTY — spot, futures and options — by describing them in plain English. No code, no data wrangling. You get win rate, drawdown, Sharpe and the full equity curve in seconds, so you can judge an idea honestly instead of hoping.
Indiquant is in invite-only alpha. Register your interest to start backtesting your own strategies on real Indian-market data.
Register for alpha access Options backtesting →Frequently asked questions
What does it mean to backtest a trading strategy?
Backtesting a trading strategy means applying its exact rules to historical market data and recording the results as if you had traded them at the time. It estimates how a strategy would have performed — its returns, win rate and drawdown — before you risk real money.
What data do I need to backtest a strategy?
You need clean historical price data at the right granularity for your strategy — daily data for swing strategies, and minute-level data (including the option chain, for options strategies) for intraday ones. The data should cover a period long enough to include different market conditions.
How much historical data is enough for a backtest?
Enough to include both trending and range-bound markets and produce a meaningful number of trades — usually at least a couple of years, and ideally across more than one market regime. A strategy tested only in a bull market hasn't been tested; it's been flattered.
Why do backtested strategies fail in live trading?
The usual culprits are overfitting (tuning a strategy until it fits the past perfectly), ignoring costs and slippage, look-ahead bias, and too-short a sample. A backtest that looks perfect is often a warning sign, not a green light.
Can I backtest trading strategies without coding?
Yes. Indiquant lets you describe a strategy in plain English and backtest it on NIFTY and BANKNIFTY — spot, futures and options — with no programming required.