SutraLipi — algorithmic trading platform
Strategies

RSI Strategy Backtest: Testing Overbought and Oversold on Indian Stocks

Published 9 July 2026 · 7 min read · SutraLipi

The RSI is the go-to indicator for spotting when a market has run too far, too fast. Used as a mean-reversion signal, it is simple to code and simple to backtest — but easy to misuse. Here is how RSI works, a basic strategy, and how to test it honestly on Indian stocks and indices.

What is the RSI?

The Relative Strength Index (RSI) is a momentum oscillator that moves between 0 and 100. It measures how strong recent gains are relative to recent losses over a lookback period (commonly 14). The traditional reading:

A simple RSI mean-reversion strategy

The classic rules buy weakness and sell strength:

A runnable example

Here it is on a 15-minute chart, buying oversold dips and exiting on recovery:

EquitySymbol stock = NSE:EQ:"RELIANCE";
float[] rsi;

onTick {
    INDICATOR_RSI(rsi, stock, M15, 14, 1);

    // oversold -> buy
    if (rsi[0] < 30) {
        OrderSend(stock, BUY, 1, 0, 0, 0, INTRADAY, DAY, "rsi oversold");
    }
    // recovered -> exit
    if (rsi[0] > 55) {
        OrderCloseBySymbol(stock, INTRADAY, DAY, "rsi exit");
    }
}

The indicator fills the rsi array; rsi[0] is the latest value. See the indicators reference for the full RSI signature.

How to backtest it

  1. Test across many stocks and indices, not just one — an RSI edge that works on one symbol may vanish on another.
  2. Try different exit levels (50, 55, 60) but avoid tuning until it looks perfect.
  3. Validate on out-of-sample data.
  4. Include brokerage, taxes and slippage — mean-reversion trades are frequent, so costs add up.

The big pitfall: RSI in a strong trend

“Oversold” is not a buy signal in a downtrend — a falling market can stay oversold for a long time while it keeps falling. Naive RSI mean-reversion gets run over in strong trends. Most robust versions add a trend filter (only buy oversold when the longer-term trend is up) so you are buying dips within an uptrend, not catching a falling knife.

Variations worth testing

Try it

Build the RSI strategy in the SutraLipi platform, backtest it across a basket of stocks, then add a trend filter and compare. For a trend-following contrast, see the Supertrend strategy.

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)