Skip to main content

Options Strategy Backtesting for NIFTY and BANKNIFTY

Stolo's backtest tool replays a multi-leg options strategy over historical NIFTY and BANKNIFTY data and tells you how it would have done. You build the legs, set the strike selection, the stop loss, the re-entry and trailing rules, pick a date range, and the engine runs every session in that window and reports the full performance picture: equity curve, drawdown, win rate, profit factor and a trade-by-trade log.

The problem it solves

Most option strategies sound good in a WhatsApp group and fall apart in a drawdown you did not see coming. The only way to know how a rule set behaves is to run it over a few hundred sessions, including the bad ones. Doing that by hand in a spreadsheet is unrealistic for anything with re-entries and trailing stops. The backtest engine does it properly, with the same strike logic and exit rules you would trade live.

The concept

  1. Define the strategy, not a single trade. Legs, entry time, exit time, strike selection method, and the stop, target, trailing and re-entry rules.
  2. Replay every day. For each session in the date range, the engine enters at your entry time, applies your rules bar by bar, and closes at your exit time or when a stop fires.
  3. Aggregate the results. Every day becomes one row in a P&L series, which the engine turns into an equity curve and a set of risk statistics.
  4. Stress the parameters. A strategy that only works at one exact stop-loss value is curve-fitted. Grid Search, Heatmap and Walk-Forward test for robustness.

Building a strategy

The base

  • Underlying: NIFTY or BANKNIFTY.
  • Underlying source: cash or future, for strike and delta reference.
  • Entry and exit time: for example enter 09:20, exit 15:15.
  • Date range: the historical window to test.

Each leg (up to six)

  • Segment and position: options or futures, buy or sell.
  • Option type and expiry: CE or PE, weekly, next weekly, monthly or next monthly.
  • Strike selection: ATM, OTM, ITM, exact, percent of ATM, premium range, closest premium, premium greater than, straddle width, synthetic future, ATM straddle premium percent, closest delta, or delta range.
  • Lots.
  • Stop loss and target: in points, underlying points, premium percent, underlying percent, or delta.
  • Trailing stop: trigger and trail-by amount, in points, percent or delta.
  • Momentum entry: wait for a points or percent move before the leg goes on.
  • Re-entry: RE-ASAP, RE-COST or RE-MOMENTUM and their reverse variants, with a max count and a no-re-entry-after time.
  • Lazy legs: an entirely different leg that only activates when this leg's stop or target fires, for modelling adjustments. Lazy legs can cascade.

Overall (strategy-level)

  • Overall stop loss: MTM value or total premium percent.
  • Legwise settings: partial or complete square-off, trail remaining legs to breakeven.
  • Overall momentum, overall re-entry, and an overall trailing stop.
  • Range breakout entry: enter on a break of a defined opening range, high or low, on the instrument or the underlying, with its own stop and re-entry.

Key terms explained

TermWhat it means
LegOne option or futures position in the strategy.
Strike selection methodThe rule that picks each leg's strike, from ATM offsets to premium and delta targets.
RE-ASAP / RE-COST / RE-MOMENTUMRe-entry modes: re-enter immediately, re-enter at the original cost, or re-enter on a momentum trigger.
Lazy legA leg that activates only when another leg's stop or target fires.
MTM stopAn overall stop based on mark-to-market profit or loss for the whole strategy.
Profit factorGross profit divided by gross loss. Above 1 is profitable, above 1.5 is good.
Max drawdownThe largest peak-to-trough fall in the equity curve.
Sharpe / Sortino / CalmarRisk-adjusted return ratios, computed on the daily P&L series.
Walk-forwardOptimise on an in-sample window, measure on the next out-of-sample window, roll forward.

A worked example

You want to test a classic BANKNIFTY 9:20 short straddle with a stop.

  • Base: BANKNIFTY, cash reference, enter 09:20, exit 15:10, range 1 January 2025 to 1 June 2025.
  • Leg 1: sell CE, weekly, ATM, 1 lot, stop loss 30 percent of premium.
  • Leg 2: sell PE, weekly, ATM, 1 lot, stop loss 30 percent of premium.
  • Overall: MTM stop at minus 4,000, square-off complete.

Run it. The summary comes back: total P&L plus 82,000, 104 trading days, win rate 61 percent, profit factor 1.34, max drawdown minus 18,500, Sharpe 0.9. The equity curve rises steadily then gives back a chunk in the March expiry week. The trade table shows the worst day was a trending move where both stops hit.

Now open Grid Search and sweep the per-leg stop from 20 to 50 percent. You find that 25 to 35 percent all produce a similar profit factor while 20 percent stops out too often and 50 percent lets losers run. That flat region is the robust choice, not whichever single value scored highest.

How to use it in Stolo

Stolo backtest Strategy Builder with a two-leg short straddle and stop loss rules
  1. Log in to Stolo and open Backtest from the main menu.
  2. On the Strategy Builder tab, set the underlying, entry and exit time, and the backtest date range.
  3. Add your legs. For each, pick the strike selection method, lots, and any stop, target, trailing or re-entry rules.
  4. Add overall rules if you want an MTM stop or strategy-level trailing.
  5. Click Run. The job queues and the results appear when it finishes.
  6. Read the summary stats, then the equity curve, drawdown and monthly heatmap, then the trade table for the bad days.
  7. Use Grid Search and Heatmap to test parameter sensitivity, and Walk-Forward to check it holds out of sample.
  8. Save a working strategy to the Strategy Library for later.
info

Backtesting is historical only. It does not connect to your broker or place any trades. Once a strategy checks out, rebuild it in the Strategy Builder for live execution.

The other tabs

TabWhat it does
Strategy LibrarySave, organise in folders, and reload strategy configurations.
Grid SearchSweep one parameter across a range and compare the results.
HeatmapSweep two parameters at once, shown as a colour grid.
ComparisonPut several backtest runs side by side.
Walk-ForwardIn-sample and out-of-sample rolling validation.
PortfolioCombine multiple strategies into one equity curve.

There are also post-run panels on a finished backtest: a market regime overlay that splits results by trending versus range-bound periods, and a Monte Carlo panel that reshuffles the trade sequence to show a range of possible drawdowns.

Limitations to know

  • NIFTY and BANKNIFTY only for now.
  • One-minute bars, not ticks. Intrabar stop and target fills, and live-LTP momentum checks, are approximated from the bar high and low.
  • No costs modelled. Brokerage, slippage and market impact are not included, so live results will be lower.
  • BTST and positional range-breakout variants are not yet supported by the engine.

Frequently asked questions

What is options strategy backtesting?
Backtesting is running a defined strategy over historical market data to see how it would have performed. You specify the legs, the entry and exit times, and the stop loss and re-entry rules, then the engine replays every trading day in your date range and reports the profit and loss, win rate, drawdown and other statistics.
Which instruments can I backtest in Stolo?
The backtest engine currently supports NIFTY and BANKNIFTY. These are the two most liquid options markets in India and the ones with the cleanest historical data. Individual stock options and other indices are not covered yet.
What kinds of strategies can I build?
You can build any strategy of up to six legs, mixing buy and sell, calls and puts, options and futures, across weekly and monthly expiries. Common examples are short straddles and strangles, iron condors, iron flies, ratio spreads, calendar-style expiry mixes, and directional debit or credit spreads. Each leg has its own strike selection method, stop loss, target and trailing rules.
How does strike selection work?
Each leg picks its strike by a method you choose. The basic methods are ATM, OTM or ITM by a number of strikes, an exact strike, or a percentage of ATM. The premium-based methods select by a target premium, a premium range, a closest premium, straddle width or a straddle premium percentage. The delta methods select the strike closest to a target delta or within a delta band. This means the same rule set adapts as volatility changes day to day.
Can I add stop loss and re-entry rules?
Yes, at both the leg level and the overall level. Per leg you can set a stop loss and target in points, premium percent, underlying points or percent, or delta, plus a trailing stop and a momentum-based entry. Re-entry supports RE-ASAP, RE-COST and RE-MOMENTUM modes and their reverse variants, with a maximum re-entry count. At the overall level you can set an MTM or total-premium-percent stop, an overall trailing stop, and overall re-entry.
What are lazy legs?
A lazy leg is a leg that only activates when another leg's stop loss or target fires. It lets you model adjustment strategies, for example when the call side of a strangle is stopped out, a lazy leg re-sells a further strike. Lazy legs can themselves have lazy legs, so you can build cascading multi-stage adjustments.
What statistics does the backtest report?
The summary includes total profit and loss, total trades, win rate, profit factor, average profit and loss, best and worst trade, maximum drawdown, and the Sharpe, Sortino and Calmar ratios. Alongside that you get an equity curve, a drawdown chart, a daily profit and loss chart, a monthly returns heatmap, a win-loss breakdown, and a full trade-by-trade table with per-leg entry and exit prices.
What is the Grid Search tab for?
Grid Search sweeps one parameter across a range of values and runs a backtest for each, so you can see how sensitive the strategy is to that setting. The Heatmap tab does the same across two parameters at once and shows the result as a colour grid, which is how you find robust regions rather than a single fragile best value.
What is walk-forward testing?
Walk-forward splits your history into consecutive in-sample and out-of-sample windows. It optimises on the in-sample window, then measures the result on the untouched out-of-sample window, and rolls forward. It is a stronger test of whether a strategy actually works or was just curve-fitted to one period.
How accurate is the backtest?
The engine uses one-minute historical bars, not tick data, so intrabar stop and target fills are approximated from the bar high and low, and momentum checks on a live-LTP basis are estimated the same way. Results do not include brokerage, slippage or the impact of your own size on the market. Treat the output as a realistic guide to a strategy's behaviour and edge, not an exact prediction of live returns.
Can I save strategies to reuse?
Yes. The Strategy Library stores your strategy configurations in folders. You can load a saved strategy back into the builder, edit it, and re-run it over a new date range. The date range itself is a property of the backtest run, not the saved strategy.
Does backtesting place any live trades?
No. Backtesting is entirely historical and touches nothing in your broker account. To trade a strategy you have validated, rebuild it in the Strategy Builder for live execution or place it through the option chain and trade terminals.
What plan do I need to use the backtest tool?
The backtest tool is part of Stolo's paid access and can be tried on the Trial plan, which starts at 299 rupees. See the subscription plans page for the current tiers.

Test the strategy before you trade it

Backtest multi-leg NIFTY and BANKNIFTY options strategies over any date range in Stolo, with full stats and a trade log.

Start with the Trial Plan at just ₹299