SutraLipi — algorithmic trading platform
Strategies

Supertrend Strategy: How to Backtest It on Nifty & Bank Nifty

Published 9 July 2026 · 7 min read · SutraLipi

The Supertrend is a favourite of Indian intraday traders because it does one job well: it tells you which side of the trend you are on, and flips when that changes. Here is how the indicator works, a simple strategy built on it, and how to backtest that strategy on Nifty and Bank Nifty — with a runnable example.

What is the Supertrend indicator?

The Supertrend plots a single line that sits below price in an uptrend and above price in a downtrend. It is built from the Average True Range (ATR), so it adapts to volatility. Two inputs control it:

When price closes across the Supertrend line, the trend is considered to have flipped.

A simple Supertrend strategy

The classic rule set:

A runnable example

Here it is on the 15-minute Bank Nifty, using a 10-period, 3× multiplier Supertrend. It goes long on an upward flip and closes on a downward flip.

EquitySymbol nifty = NSE:IDX:"NIFTY BANK";
float[] st;

onTick {
    INDICATOR_SUPERTREND(st, nifty, M15, 10, 3, 1);
    float c1 = Close(nifty, M15, 1);
    float c0 = Close(nifty, M15, 0);

    // price closes ABOVE the Supertrend line -> go long
    if (c1 <= st[1] && c0 > st[0]) {
        OrderSend(nifty, BUY, 1, 0, 0, 0, INTRADAY, DAY, "supertrend up");
    }
    // price closes BELOW the Supertrend line -> exit
    if (c1 >= st[1] && c0 < st[0]) {
        OrderCloseBySymbol(nifty, INTRADAY, DAY, "supertrend down");
    }
}

The [1] versus [0] comparison detects the exact bar where price crosses the line. See the indicators reference for the full Supertrend signature.

How to backtest it

  1. Run it across several years of Bank Nifty data, including trending and ranging phases.
  2. Compare a couple of multiplier settings (2 vs 3) — but resist tuning until the curve looks perfect. That is overfitting.
  3. Validate on out-of-sample data you did not use to choose the settings.
  4. Include costs and slippage.

Realistic expectations

Like every trend-following tool, the Supertrend shines in trends and struggles in sideways markets, where price repeatedly closes back and forth across the line and generates whipsaw losses. Expect a moderate win rate carried by a few strong trend runs — not a high hit rate.

Traders often pair the Supertrend with a higher-timeframe filter (only take longs when the daily trend is up) or a time-of-day rule to cut whipsaws. Each filter is a trade-off you tune with backtesting.

Try it

Copy the script into the SutraLipi platform, backtest it on Bank Nifty, then add a trend filter and compare. See the moving average crossover for another trend approach.

Try it on SutraLipi — free

Build, backtest and paper-trade the ideas in this guide without writing code.

Get Started Free

This article is for education only and is not investment advice. Trading and investing in securities and derivatives carry risk of loss; past performance and backtested results do not guarantee future returns. Please read our Risk Disclosure Statement and consult a SEBI-registered adviser before trading.

Keep reading

Basics What Is Algo Trading? A Plain-English Guide for Indian Traders Regulation Is Algo Trading Legal in India? SEBI Rules Every Retail Trader Should Know Backtesting How to Backtest a Trading Strategy (Step by Step, No Coding)