Guide · Systematic

How to backtest a trading strategy in India

The short answer

A backtest runs a fully specified set of rules over historical data to estimate the distribution of that rule's outcomes: its expectancy, the spread of its results, and the depth of its drawdown. It does not predict one future return. The honest deliverable is expectancy plus variance plus drawdown, never a single number, and it is only as trustworthy as three things: unambiguous rules, honest costs, and testing on data the rule was not built on.

Most retail platforms will hand you a Sharpe ratio in five seconds. That number is not the problem; treating it as an answer is. A backtest is a simulation, and a simulation inherits every assumption you feed it. Feed it survivorship bias, zero costs, and one lucky market, and it will return a beautiful curve that means nothing. This guide is the method: how to run a backtest whose answer actually carries information, step by step, with the Indian specifics that decide whether a paper edge exists in reality. The catalogue of every way a backtest can quietly lie to you lives in its own companion piece, the bias treatise; here we build the process that defends against them.

What a backtest actually is

Start with the epistemics, because they change how you read every result that follows. A single trade has a random outcome. A rule applied over a hundred trades produces a sample from an underlying distribution you can never see directly. Backtesting is an attempt to estimate the shape of that distribution from history: not "this rule will make X next year" but "this rule has an expectancy of roughly this, a spread of roughly that, and in its worst historical stretch it drew down this far for this long."

Read that way, three habits follow immediately. First, one number is never the answer; you report expectancy, variability and drawdown together, because a rule with a healthy average return and a ruinous worst case is not a good rule. Second, the number of observations governs your confidence: an estimate from twenty trades is almost worthless no matter how clean it looks, while the same edge across four hundred trades spanning several market regimes carries real weight. Third, the backtest is evidence, not proof. It shifts your justified confidence up or down. It never reaches certainty, which is why the honest end of the process is a slow live ramp rather than a victory lap.

The one-number trap. If someone shows you a strategy as a single figure, whether a return or a Sharpe or a hit ratio, they have shown you the least informative summary of a distribution and hidden the rest. Ask for the drawdown, the trade count, and the out-of-sample result before you believe anything.

The seven-step protocol

A backtest whose answer means something is not a button; it is a sequence of real decisions, each of which can invalidate the result if you get it wrong. Here is the pipeline, and then each step in turn.

The seven-step backtesting pipeline Seven boxes flow left to right: specify the rules, choose the data, include the costs, split in-sample and out-of-sample, walk forward, choose metrics, apply the verdict. A return arrow loops from the verdict back to the start, showing that a failed or refined test re-enters the process. From rule to verdict: the pipeline 1 Specify the rules, no judgement 2 Data adjusted, survivor-free 3 Costs full stack plus slippage 4 Split in-sample / out-of-sample 5 Walk forward, rolling 6 Metrics that matter, with N 7 Verdict stability, sample size a failed or refined test re-enters the process, it does not get quietly re-tuned in place
Each box is a decision, not a setting. The dashed return path matters as much as the forward flow: when a rule fails out-of-sample, the honest move is to redesign and re-run the whole pipeline, not to nudge a parameter until the same data looks better, which simply overfits to the answer you wanted.

Step 1: Specify the rules unambiguously

A rule is testable only if a machine could follow it identically every time. Entry, exit, stop and position size must each be a precise condition, not a description. "Buy on a strong breakout" is not a rule; "buy when price closes above the highest high of the prior twenty sessions, size so that the distance to the stop risks a fixed fraction of equity" is. The test of specification is simple: if a human has to judge, it is not yet testable. Every discretionary "unless it looks weak" you leave in is a place where hindsight will sneak into the result.

Step 2: Choose the data, and clean it for India

Two data problems silently corrupt more Indian backtests than anything else. The first is corporate actions. If a stock does a bonus issue or a split, the raw price drops mechanically while shareholder wealth is unchanged. An unadjusted 1:1 bonus halves the quoted price overnight: to a backtest that looks like a 50 percent crash and will trigger every stop and every trend rule falsely. Prices must be adjusted for splits, bonuses and rights before you test a single bar; the mechanics of why a bonus moves the quoted price without changing value are set out in the bonus-issue guide.

The second is survivorship. If you test on the index's current constituents, you are testing only the companies that survived and were promoted, and quietly deleting the ones that were delisted or demoted. That flatters results, and in Indian small-caps the effect is large, not academic. The fix has a name: a point-in-time universe, the set of stocks that were actually in the index on each historical date, delistings and all.

The India scoop. A November 2025 study of the Nifty Smallcap 250 (Ranse, Cluster University of Jammu) quantified this precisely. A survivor-only backtest reported roughly 26.2 percent annualised; the survivorship-free universe delivered about 21.2 percent, an overstatement of 4.94 percentage points, close to 23 percent in relative terms, with the Sharpe inflated about 9 percent. Over nine years around 82.5 percent of the stocks that entered the index had been removed, yet most analyses silently drop them. If your data vendor cannot give you delisted names, assume your small-cap backtest is overstated.

Step 3: Include costs honestly

This is where most paper edges die, so it gets its own worked section below. In one line: model the full Indian statutory stack plus slippage and impact on every trade, because a strategy is only real if it clears its costs.

Step 4: Split in-sample and out-of-sample

Divide the history. Develop and tune on the in-sample block; hold the out-of-sample block back untouched, then run the frozen rules on it exactly once. If the edge survives on data the rule never saw during development, it is more likely to be real. If it collapses, you fitted noise. The discipline is fragile in one specific way: the moment you look at the out-of-sample result and go back to re-tune, that data is now in-sample, and its protective power is spent.

Step 5: Walk forward

A single split tests one slice of the future once. Walk-forward is the rolling, honest generalisation: optimise on a window, test on the next unseen block, roll both windows forward, repeat across the whole timeline. It mirrors how a live strategy is genuinely run, re-fitted periodically and traded blind into the near term, and it produces many out-of-sample segments across different regimes instead of one. A rule that only worked in a single bull phase is exposed far more reliably here than by any one split. The next figure shows how the windows roll.

Step 6: Choose metrics that matter

CAGR alone lies, because it says nothing about the suffering that earned it. The metrics that carry information, and the way each one misleads when read alone, are laid out in the metrics table below. The single most important is the least glamorous: the trade count, because it is the sample size that decides how much any other metric can be trusted.

Step 7: Apply the verdict rules

Before a rule earns any live capital, it must clear explicit gates: a minimum trade count large enough that the result is not luck; stability of the edge across up, down and sideways markets, not just the regime it was born in; and a positive expectancy that survives honest costs and the out-of-sample and walk-forward tests intact. Regime stability is its own discipline, because a rule that only works when the market trends needs a regime filter to know when to stand aside. A rule that passes on the friendly regime and fails on the hostile one has not passed.

The Indian cost stack, with a worked example

Costs are not a footnote to a backtest; on a high-frequency rule they are frequently the difference between an edge and a slow bleed. India layers several statutory charges on every trade, and then reality adds slippage on top. You must model all of it. The rates below are the current framework: verify the live figures against your exchange and broker before you rely on them, because statutory rates change with each budget.

The full Indian trading cost stack (current framework; rates change with statute, confirm before use)
ComponentBasisTypical rateNote
Securities Transaction Tax (STT)Trade valueDelivery 0.1% each side; intraday 0.025% on the sellThe largest statutory line on delivery
Exchange transaction chargeTrade value~0.003% (NSE cash)Set by the exchange; varies by segment
SEBI turnover feeTrade value0.0001%The smallest line, but real
Stamp dutyBuy side only0.015% delivery; 0.003% intradayUniform national rate since 1 July 2020
GSTOn brokerage + charges18%On the service fees, not on trade value or STT
Depository (DP) chargePer scrip, delivery sellA flat rupee fee per scripFixed, so it bites small orders hardest
Slippage and impactTrade value~0.05% to 0.20%+Worse on thin counters and large orders

Now watch a plausible edge meet that stack. Suppose an intraday rule shows a gross average gain of 0.45% per round-trip on a liquid stock near ₹500, which looks like a comfortable edge. Model the intraday costs honestly on each side and it is a different picture.

A plausible intraday edge before and after the full cost stack (illustrative, per round-trip)
LineEffect on the round-tripRunning edge
Gross edge (assumed)+0.45%+0.45%
STT (intraday, sell side 0.025%)−0.025%+0.425%
Stamp duty (buy 0.003%)−0.003%+0.422%
Exchange charge (~0.003% each side)−0.006%+0.416%
SEBI fee + GST on charges−0.002%+0.414%
Slippage + impact (~0.20% each side)−0.40%+0.014%
Brokerage + its GST− variesnear zero or negative

The statutory taxes are small; slippage is the killer. A gross edge of 0.45% that looked ample is almost entirely consumed before brokerage, and once realistic fills and commission are added, the rule that "worked" in a zero-cost backtest is a way to pay the exchange for the privilege of trading. This is not pessimism, it is arithmetic, and it is exactly why a costed backtest is the only kind worth reading. Building the cost model correctly, and every other guard in this pipeline, is precisely what the method we teach is built around.

In-sample, out-of-sample and walk-forward, in one picture

The three splitting ideas are easiest to see on a timeline. A plain split trains on the early history and tests once on the tail. Walk-forward slides that arrangement along, producing a chain of separate train-then-test cycles that together cover many market conditions.

In-sample, out-of-sample and walk-forward windows on a timeline A single split trains on early data and tests once on later data. Walk-forward repeats a train-then-test pair, sliding both windows forward across the timeline so that many non-overlapping test blocks together span different market regimes. Rolling train-and-test windows Single split train (in-sample): develop and tune here test once (out-of-sample) Walk-forward train test train test train test earlier later Each test block is unseen when its own model was fitted; together they cover trends, ranges and falls, so a rule that only worked in one regime cannot hide behind a single lucky window.
Walk-forward turns one test into many. Because each gold test block was in the future relative to the green window that fitted it, the chain of tests behaves like a series of honest small live runs. A rule with a real, durable edge stays profitable across most of them; one that was curve-fitted to a single market lights up in one block and dies in the rest.

The metrics that matter, and how each one lies alone

Every metric compresses the outcome distribution into a number, and every compression throws information away. The skill is reading them as a panel, each one covering another's blind spot, with the trade count underneath as the thing that says how much to trust the rest.

Backtest metrics: what each measures, and how it misleads when read on its own
MetricWhat it measuresHow it misleads alone
CAGRCompound annual growth of equitySays nothing about the drawdown suffered to earn it; two identical CAGRs can hide wildly different pain
Maximum drawdownThe deepest peak-to-trough equity fallDepth without duration understates it: a shallow drawdown that lasts two years can end a strategy that a sharp brief one would not
Exposure-adjusted returnReturn relative to time actually in the marketIgnored, it flatters an always-invested rule over a selective one that only acts on its edge
Profit factorGross profit divided by gross lossA single outlier trade can inflate it; a high figure on ten trades is noise, not skill
Sharpe (intuition)Return per unit of volatilityPunishes upside volatility as if it were risk, and is easily gamed by leverage or by a short sample; useful, not sacred
Trade count (N)The sample size behind every figure aboveThe one number that cannot mislead by itself: a small N simply means none of the others can be trusted yet

Notice the deliberate demotion of the Sharpe ratio. It is a reasonable intuition, return earned per unit of wobble, and a terrible idol. A short sample, a dose of leverage, or a rule that happens to avoid volatility can all flatter it, which is why it belongs in a panel and never on a pedestal.

Reading an equity curve

The most information-dense output of a backtest is the equity curve itself, and the single most important lesson is that the same CAGR can draw two completely different curves. One climbs in a steady line you could hold through; the other reaches the identical endpoint through violent lunges and long, grinding drawdowns almost no one would actually survive. The endpoint is equal; the experience, and the odds you stay in the seat, are not.

Two equity curves with the same CAGR: smooth versus lumpy Both curves start and end at the same equity, so their compound growth rate is identical. The smooth curve rises steadily. The lumpy curve rallies hard, then falls into a deep drawdown that lasts a long time before recovering to the same endpoint. Brackets mark the drawdown depth and its duration. Same CAGR, two very different rides equity start end smooth: steady, holdable lumpy: same endpoint, brutal path drawdown depth drawdown duration (time underwater until a new high)
Depth and duration are two different wounds. Depth is how far the equity fell from its peak; duration is how long it stayed below that peak before making a new high. A curve can have a survivable depth but an unsurvivable duration, years underwater, during which most people abandon the rule at the worst moment. Judge a backtest by the ride, not just the destination.

From backtest to live: the honest bridge

A passed backtest is a hypothesis with supporting evidence, not a licence to deploy capital at size. The bridge from simulation to live money has three deliberate stages, and each exists because the backtest is evidence rather than proof.

First, paper trade the rule forward on live data before risking anything. This catches the gap between "the historical data said this bar filled here" and "the live market actually moved like this," including execution frictions a backtest cannot fully see. Paper trading is the forward-testing stage that no amount of historical fitting can replace, and its own mechanics and traps are covered in the paper-trading guide. Second, ramp size slowly: begin live at a small fraction of the intended position and scale up only as real fills confirm the paper result, so an unpleasant surprise costs a little rather than a lot. Third, hold the honest expectation that live will underperform the test.

Why live almost always trails the backtest. Four forces pull real results below the simulated curve. Slippage and market impact make your fills worse than assumed. Costs bite every trade. The market regime drifts away from the one the rule was fitted to. And if the edge is discoverable, crowding erodes it as others trade the same thing. A sound process does not treat the backtest curve as a promise; it expects decay and sizes for it. Structuring a whole strategy this way, from specification through the live ramp, is the subject of building a trading system.

FAQ

Frequently asked questions

Backtesting is running a fully specified set of rules over historical data to see how it would have behaved. Done honestly, it does not predict a single future return; it estimates the distribution of the rule's outcomes, its expectancy, the spread of results and the depth of drawdown. The deliverable is a distribution and a confidence, not one number. Its value is destroyed if the rules are ambiguous, the costs are omitted, or the same data is used to both build and judge the rule.

There is no fixed threshold, only the honest fact that confidence scales with the number of independent trades, not calendar years. A result built on twenty trades tells you almost nothing, however good it looks. You want enough trades to span at least one full up-trend, one down-trend and one range, because a rule that only ever met a rising market has not been tested, it has been flattered. Report the trade count next to every metric, because it is what governs whether the metric means anything.

You split the history into two parts. On the in-sample part you develop and tune the rules. The out-of-sample part is held back and never looked at during development, then the frozen rules are run on it once. If the edge survives on data the rule has never seen, it is more likely to be real and less likely to be a pattern you fitted to noise. If the result collapses out of sample, you overfitted. The discipline only holds if you do not peek and then quietly re-tune.

Walk-forward is the rolling, honest version of an out-of-sample test. You optimise on a window of history, test on the next unseen block, then roll both windows forward and repeat across the whole timeline. It mimics how a strategy is actually run, re-fitted periodically on recent data and then traded blind into the near future. Because it produces many separate out-of-sample segments across different regimes, it exposes a rule that only worked in one market far better than a single split can.

No single number is enough, which is the point. CAGR alone hides how much pain earned the return, so read it beside maximum drawdown, its depth and its duration. Add exposure-adjusted return, so a rule in the market ten percent of the time is not compared unfairly with one always invested, and profit factor, gross profit over gross loss. The Sharpe intuition, return per unit of volatility, is useful as long as you do not worship it. Above all, read the trade count: it is the sample size that decides how much any of the others can be trusted.

Live almost always underperforms the test, and the gap has structural causes. Real fills carry slippage and market impact a backtest rarely models fully. Costs bite on every trade. The market regime drifts away from the one the rule was fitted to. And if an edge becomes widely known, crowding erodes it. Expecting live to match a clean backtest is the mistake; a sound process expects decay and sizes for it, rather than treating the backtest curve as a promise.

Not necessarily, but you do need to be exact. The real requirement is that every rule is unambiguous enough to execute without human judgement: an entry, an exit, a stop and a position size that a machine could follow identically every time. Code makes that exactness natural and makes honest cost and lag modelling easy, which is why serious testing tends to be programmatic. A spreadsheet can validate a simple rule. A vague rule that needs you to eyeball a chart cannot be backtested at all, in any tool.

The full statutory stack plus friction. Securities Transaction Tax (0.1% each side on delivery, 0.025% on the intraday sell), exchange transaction charges (roughly 0.003% on NSE cash), the SEBI turnover fee (0.0001%), stamp duty on the buy (0.015% delivery, 0.003% intraday), 18% GST on brokerage and those charges, and depository charges on delivery sells. Then add slippage and market impact, the difference between the price your backtest assumed and the price you actually get. Omitting these is the single most common reason a paper edge does not exist in reality.

Never fully; a backtest raises or lowers confidence, it does not prove anything. What moves confidence upward is a large trade count, an edge that survives untouched out-of-sample and walk-forward data, stability across up, down and sideways regimes, and honest costs that still leave something over. Even then the correct posture is provisional: you carry the rule to paper trading and a slow live ramp precisely because the test is evidence, not a guarantee. Certainty is not on the menu; degrees of justified confidence are.

Where the facts come from

Sources

  • India survivorship evidence. Harjot Singh Ranse, "Survivorship Bias in Emerging Market Small-Cap Indices: Evidence from India's NIFTY Smallcap 250" (November 2025): survivor-only backtests overstated annualised return by 4.94 percentage points (about 23 percent relative) and Sharpe by roughly 9 percent, with about 82.5 percent of index entrants removed over nine years. This grounds the point-in-time-universe requirement. arxiv.org
  • Indian statutory cost stack. NSE India, "SEBI Turnover Fees, STT and Other Levies," sets out the Securities Transaction Tax, exchange transaction charges and the SEBI turnover fee (0.0001%) that a backtest must model on every trade. nseindia.com
  • Uniform stamp duty. The amended Indian Stamp Act, effective 1 July 2020, standardised stamp duty on securities nationally: 0.015 percent on delivery buys and 0.003 percent on intraday buys, charged on the buy side only, which is why the cost stack is asymmetric between the two legs.
  • STT and GST mechanics. Current STT rates (0.1 percent each side on delivery, 0.025 percent on the intraday sell) and the 18 percent GST applied to brokerage and exchange or regulatory charges, not to trade value or STT, define how each cost line is computed in the worked example.
Educational note. This guide explains how to design and validate a backtest and the costs it must model. It is not a recommendation to trade or invest, and it is not investment advice. Backtested or hypothetical results have inherent limitations and do not represent actual trading. Bharath Shiksha is an educational publisher, not a SEBI-registered investment adviser or research analyst.

Related guides

How a backtest lies: the bias treatise

Read →

Building a trading system in India

Read →

A costed, honest backtest is a skill. Learn to build one.

Educational reference only. No buy, sell or hold recommendations. Backtested results are hypothetical and have inherent limitations.