Supertrend and RSI strategies: how to backtest them
How Supertrend and RSI are calculated, what their signals mean, and how to backtest Supertrend flips, RSI reversals and a combined rule on NIFTY options.
- By
- Veloce team
- Published
- Reading time
- 9 min read
On this page
- Supertrend, step by step
- A flip, candle by candle
- Why your chart may show different numbers
- RSI, step by step
- The reversal rule
- Reversal versus trend filter
- Setting up the tests in Veloce
- Supertrend flip option buyer
- Supertrend with an RSI filter
- What to vary, and how to read it
- Indicator-specific traps
- Try it in Veloce
To backtest a Supertrend or RSI strategy, compute the indicator only from candles that have closed, trade on the candle where the signal changes (a Supertrend flip, or RSI crossing back through a level), fill at the next candle’s open, charge every fill, and compare a few settings on one period before confirming the best on a later one. Supertrend is a trend-following rule built on the average true range; the common RSI reversal rule is the opposite, a bet that a stretched move will turn. This guide shows how each is calculated in Veloce’s code, walks through a flip and a reversal candle by candle, and sets up both, and a combination, as testable NIFTY option strategies.
Supertrend, step by step
Supertrend draws a single line under price in an uptrend and over it in a downtrend. Veloce computes it on each closed candle like this:
- True range. The largest of the candle’s high minus low, the distance from the previous close to the high, and the distance from the previous close to the low.
- Average true range (ATR). Wilder’s average: the first value is the simple average of the first n true ranges; after that, ATR = (previous ATR × (n − 1) + true range) ÷ n.
- Basic bands. Midpoint = (high + low) ÷ 2. Upper = midpoint + multiplier × ATR; lower = midpoint − multiplier × ATR.
- Ratchet. While the previous close was below the previous upper band, the upper band can only move down. While the previous close was above the previous lower band, the lower band can only move up.
- Direction. In an uptrend, the trend turns down when a close falls below the lower band. In a downtrend, it turns up when a close rises above the upper band. The first direction is up if the close is at or above the midpoint.
- The line. The lower band in an uptrend, the upper band in a downtrend.
A flip, candle by candle
Here is a series of 3-minute candles run through Veloce’s Supertrend code with the default 10-period ATR and multiplier 3. The prices are illustrative; the values are what the code produces.
| Candle closes at | Close | Supertrend | Direction | Signal |
|---|---|---|---|---|
| 09:42 | 25,852 | warming up | ||
| 09:45 | 25,846 | 25,889.20 | down | first reading, no trade |
| 09:48 | 25,840 | 25,883.38 | down | |
| 10:03 | 25,810 | 25,854.04 | down | |
| 10:06 | 25,812 | 25,850.94 | down | |
| 10:09 | 25,830 | 25,850.94 | down | band holds |
| 10:12 | 25,856 | 25,808.80 | up | flip up |
| 10:15 | 25,884 | 25,814.59 | up | |
| 10:18 | 25,910 | 25,836.93 | up |
The first value appears on the tenth candle, once the ATR has ten true ranges. That first reading is a state, not a flip, so it does not trade. Through the decline the upper band only steps down. At 10:09 the basic upper band would have risen, but the ratchet holds it at 25,850.94. At 10:12 the close of 25,856 is above that band, the trend flips up, and the line jumps to the lower band at 25,808.80. From there the lower band rises with price.
Why your chart may show different numbers
Wilder’s ATR remembers every candle since it started, and the first direction has to be assumed. A charting platform that began its calculation months earlier, or seeds the first direction differently, can show slightly different values for a while. After a few dozen candles the differences shrink. Compare values after a warm-up period rather than on the first day of a backtest.
RSI, step by step
The relative strength index compares recent gains with recent losses:
- For each closed candle, the change from the previous close is a gain if positive and a loss if negative.
- Average gain and average loss use Wilder’s smoothing over n candles (14 by default): seeded with the simple average of the first n, then (previous × (n − 1) + new) ÷ n.
- RS = average gain ÷ average loss, and RSI = 100 − 100 ÷ (1 + RS).
Two edge cases matter in code: if there were no losses at all RSI is 100, and if price did not move at all it is 50.
The reversal rule
Veloce’s RSI signal is a reversal: bullish when RSI was below the oversold level (30) on the previous candle and is at or above it now, and bearish when it was above the overbought level (70) and is at or below it now. Being oversold is not a signal; climbing back out is.
| Candle closes at | Close | RSI (14) | Signal |
|---|---|---|---|
| 10:09 | 25,781 | 0.00 | |
| 10:12 | 25,790 | 8.65 | |
| 10:15 | 25,800 | 17.22 | |
| 10:18 | 25,812 | 26.17 | |
| 10:21 | 25,830 | 37.15 | bullish: back above 30 |
| 10:24 | 25,845 | 44.55 |
In this illustrative series NIFTY fell on every candle for over 45 minutes, so RSI sat at 0: there were no gains to average. As the bounce starts, RSI climbs, and the signal fires on the candle where it crosses 30, the 10:21 close. An option buyer would buy the call at the open of the option’s next candle.
Reversal versus trend filter
RSI is used in two opposite ways, and it is worth being clear which one you are testing:
| Use | Rule | Assumes |
|---|---|---|
| Reversal | Buy when RSI climbs back above 30; sell when it falls back below 70 | Stretched moves revert |
| Trend filter | Only take longs while RSI is above 50, shorts while below | Momentum persists |
They can both work in different markets and both fail in others, which is a reason to test them separately rather than assume.
Setting up the tests in Veloce
Supertrend flip option buyer
The built-in Supertrend buyer runs on 5-minute candles: on a flip up it buys the at-the-money NIFTY call, on a flip down it sells the call and buys the at-the-money put, entries are allowed for candles closing from 09:15 to 15:00, index candles closing after 15:15 are ignored, and everything is squared off at 15:15. As a spec:
{
"name": "nifty-supertrend-buyer",
"candle_minutes": 5,
"entry": {
"signal": { "kind": "supertrend_flip", "period": 10, "multiplier": "3" },
"signal_cutoff": "15:15",
"last_entry": "15:00"
},
"legs": [{ "kind": "option", "option_type": "call", "side": "buy" }],
"bearish_legs": [{ "kind": "option", "option_type": "put", "side": "buy" }],
"square_off": "15:15",
"risk": { "rules": [{ "kind": "cash" }] }
}
The RSI version is the same with { "kind": "rsi_reversal", "period": 14, "oversold": "30", "overbought": "70" } as the signal; it is also a built-in strategy.
Supertrend with an RSI filter
Your own rules can combine indicators. Here a bullish signal needs the close to cross above the Supertrend line and RSI to be above 50 on the same candle; a bearish one needs the opposite.
{
"name": "supertrend-with-rsi-filter",
"candle_minutes": 5,
"entry": {
"signal": {
"kind": "rules",
"indicators": [
{ "name": "close", "kind": "close" },
{ "name": "st", "kind": "supertrend", "period": 10, "multiplier": 3 },
{ "name": "rsi", "kind": "rsi", "period": 14 }
],
"bullish": [
{ "left": "close", "comparison": "crosses_above", "right": "st" },
{ "left": "rsi", "comparison": "above", "right": 50 }
],
"bearish": [
{ "left": "close", "comparison": "crosses_below", "right": "st" },
{ "left": "rsi", "comparison": "below", "right": 50 }
]
},
"signal_cutoff": "15:15",
"last_entry": "15:00"
},
"legs": [{ "kind": "option", "option_type": "call", "side": "buy" }],
"bearish_legs": [{ "kind": "option", "option_type": "put", "side": "buy" }],
"square_off": "15:15",
"risk": { "rules": [{ "kind": "cash" }] }
}
Two details of how rules are evaluated:
- “Crosses above” compares two candles. It holds when the left value was at or below the right one on the previous candle and is above it now. Because the Supertrend line jumps from the upper to the lower band on a flip, “close crosses above st” is true exactly on an upward flip.
- Numbers are numbers. Write
"right": 50, not"right": "50". A quoted value is read as the name of an indicator, and Veloce rejects the spec with “condition refers to unknown indicator ‘50’” rather than guessing.
A filter changes which flips are traded, not when the position closes. With this rule, a flip up while RSI is 48 is skipped; and a held call is closed only by a bearish signal (a flip down with RSI below 50), the 15:15 square off, or an exit rule. If you want every flip down to close the call regardless of RSI, add a stop or test the plain Supertrend version alongside.
What to vary, and how to read it
The settings that matter most:
| Strategy | Settings worth a sweep |
|---|---|
| Supertrend | ATR period (7, 10, 14), multiplier (2, 3), candle (3, 5, 15 minutes) |
| RSI reversal | Period (9, 14), oversold and overbought (25/75, 30/70) |
| Combined | Keep Supertrend at its plain best; vary only the RSI threshold |
Published Supertrend studies on Indian markets often report different “best” settings for different periods and candle sizes. One well-known MarketCalls write-up found a multiplier of 2 and ATR of 11 did better than 3 and 10 on 5-minute NIFTY futures over its test period. That is the pattern you should expect from any sweep: the best setting moves when the period moves. Run the sweep with a check period and prefer settings whose neighbours also work. The overfitting guide explains why.
When you read the results:
- Trades per day. A multiplier of 2 on 3-minute candles can flip several times a day; each flip on an option buyer is a sell and a buy, with charges and two ticks of slippage on each.
- Exit reasons. How many trades ended on the opposite signal versus the 15:15 square off. A Supertrend strategy that mostly exits at 15:15 is riding a single daily trend.
- Time decay on option buys. A late flip buys an option with little time to work. Compare a last entry of 15:00 with 14:00.
- Overnight behaviour. These built-ins square off at 15:15, so there is no overnight gap risk. A version without a square off carries positions across sessions and expiries; test it as a different strategy.
Indicator-specific traps
- Repainting higher timeframes. A 15-minute Supertrend shown on a 1-minute chart is often drawn from the 15-minute candle that is still forming. Veloce computes every indicator on the strategy’s own candle size, once per closed candle, and never revises it. If you want a 15-minute Supertrend, use 15-minute candles.
- Warm-up. A 14-period RSI on 5-minute candles needs 15 candles (75 minutes) before its first value, and Wilder smoothing keeps converging after that. Start the backtest a few days before the period you want to judge, or ignore the first day.
- Signals in the closing auction. NIFTY index candles after 15:15 reflect the cash market’s closing auction since August 3, 2026. The
signal_cutoffkeeps them out of the indicator. - Lot size. Rupee results scale with the lot size, which for NIFTY went from 75 to 65 for weekly contracts from January 6, 2026 (NSE/FAOP/70616). Veloce sets each contract’s lot size from the exchange’s dated schedule, so a backtest that spans the change trades 75 a lot for contracts expiring before January 6, 2026 and 65 after;
--lot-sizeoverrides it for the whole run.
Try it in Veloce
Veloce includes Supertrend and RSI option buyers among its built-in strategies, and its rule builder combines Supertrend, RSI, moving averages, Bollinger and Keltner bands, Donchian channels, stochastics, Williams %R, CCI, rate of change, ATR, ADX and MACD. Every backtest runs on one-minute data for NIFTY 50 weekly, BANK NIFTY monthly and SENSEX weekly options, or MCX gold and gold mini futures, with next-open fills and itemised charges. Sweeps vary the settings with a held-back check period.
Create a free Veloce account and test a Supertrend flip on your own period. For a slower trend rule, see the moving average crossover guide; for terms such as ATR and Wilder smoothing, see the glossary.
Frequently asked questions
- What are the usual Supertrend settings?
- A 10-period average true range with a multiplier of 3 is the common default, and it is Veloce's default too. Smaller multipliers flip more often; larger ones flip later and less often. Treat the settings as something to test on your candle size and market.
- How is Supertrend calculated?
- Take the midpoint of each candle's high and low, add and subtract the multiplier times the average true range to get an upper and lower band, and let each band move only towards price while price stays on its side. The trend flips up when a close goes above the upper band and down when a close goes below the lower band.
- What is an RSI reversal signal?
- A signal taken when RSI turns back from an extreme: bullish when it climbs back above the oversold level, such as 30, and bearish when it falls back below the overbought level, such as 70. It is a mean-reversion rule, the opposite of using RSI above 50 as a trend filter.
- Why do my Supertrend values differ from my chart?
- Average true range uses Wilder smoothing, which remembers every candle since it started, and the first trend direction has to be assumed. A chart that started months earlier can show slightly different values for a while. Compare after a warm-up of a few dozen candles.
- Can I combine Supertrend and RSI in one rule?
- Yes. In Veloce you can write your own rules, such as close crosses above Supertrend and RSI above 50 for a bullish signal. Every condition must hold on the same candle close. Each added condition is another setting to test, so check the combination on a held-back period.
Sources
- J. Welles Wilder Jr., New Concepts in Technical Trading Systems (1978), via Investopedia's RSI entryinvestopedia.com, accessed
- MarketCalls: Optimized Supertrend trading system and FAQmarketcalls.in, accessed
- NSE circular NSE/FAOP/70616: revision in market lot of derivative contracts on indices (October 3, 2025)nsearchives.nseindia.com, accessed