Indicator · Pine Script v5 · Own pane

Supertrended RSI [AlgoAlpha]

by nersent· code credited to AlgoAlpha

The Supertrended RSI [AlgoAlpha] indicator plots the Relative Strength Index combined with a Supertrend overlay in a separate indicator pane.

View on GitHub

GitHub stars29on the repository
Pine versionv5runs as is
Lines of code109
Settings8inputs
LicenceCustom licencefile: MPL-2.0
Last update11 months ago24 Nov 2025

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

109 lines of Pine Script v5 from suite/algoalpha/supertrended_rsi.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

supertrended_rsi.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlgoAlpha

//@version=5
indicator("Supertrended RSI [AlgoAlpha]", overlay = false, timeframe = "")

// Input parameters
relativeStrengthIndexLength = input.int(14, title="RSI Length", group="RSI Settings")
smoothingLength = input.int(21, title="RSI Smoothing Length", group="RSI Settings")
rsiInputSource = input.source(close, title="RSI Source", group="RSI Settings")
isSmoothed = input.bool(false, "Smooth RSI?", group="RSI Settings")

movingAverageLength = input.int(14, title="MA Length", group="MA Settings") // , display = display.data_window
movingAverageType = input.string("HMA", title="MA Type", options=["SMA", "HMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings") // , display = display.data_window
// showMovingAverage = input.bool(true, "Show RSI MA?", group="MA Settings")

trendFactor = input.float(0.8, title="Factor", group="Super Trend Settings")
averageTrueRangeLength = input.int(10, title="ATR Length", group="Super Trend Settings")

// colorUp = input.color(#00ffbb, title="Up Color")
// colorDown = input.color(#ff1100, title="Down Color")

// MA Selection
calculateMA(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "HMA" => ta.hma(source, length)
        "EMA" => ta.ema(source, length)
        "SMMA (RMA)" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)

// Function to calculate ATR
calculateATR(source, atrLength) =>
    highestHigh = ta.highest(source, atrLength)
    lowestLow = ta.lowest(source, atrLength)
    trueRange = na(highestHigh[1]) ? highestHigh - lowestLow : math.max(highestHigh - lowestLow, math.abs(highestHigh - source[1]), math.abs(lowestLow - source[1]))
    ta.rma(trueRange, atrLength)

// Function to calculate Supertrend
calculateSupertrend(factor, atrPeriod, source) =>
    priceSource = source
    atr = calculateATR(source, atrPeriod)
    upperBand = priceSource + factor * atr
    lowerBand = priceSource - factor * atr
    prevLowerBand = nz(lowerBand[1])
    prevUpperBand = nz(upperBand[1])
    lowerBand := lowerBand > prevLowerBand or source[1] < prevLowerBand ? lowerBand : prevLowerBand
    upperBand := upperBand < prevUpperBand or source[1] > prevUpperBand ? upperBand : prevUpperBand
    int trendDirection = na
    float supertrendValue = na
    prevSupertrend = supertrendValue[1]
    if na(atr[1])
        trendDirection := 1
    else if prevSupertrend == prevUpperBand
        trendDirection := source > upperBand ? -1 : 1
    else
        trendDirection := source < lowerBand ? 1 : -1
    supertrendValue := trendDirection == -1 ? lowerBand : upperBand
    [supertrendValue, trendDirection]

// Calculating RSI
var float rsiValue = na
rsiValue := isSmoothed ? ta.hma(ta.rsi(rsiInputSource, relativeStrengthIndexLength), smoothingLength) : ta.rsi(rsiInputSource, relativeStrengthIndexLength)

var float rsiMovingAverage = na
rsiMovingAverage := calculateMA(rsiValue, movingAverageLength, movingAverageType)

// Calculating Supertrend based on RSI values
[_rsiSupertrend, _trendDirection] = calculateSupertrend(trendFactor, averageTrueRangeLength, rsiValue)

// --------------------- EXPORTED ---------------------
var float rsiSupertrend = na
rsiSupertrend := _rsiSupertrend
var int trendDirection = na
trendDirection := _trendDirection

// var float rsi_value = na
// rsi_value := rsiValue
// var float rsi_moving_average = na
// rsi_moving_average := rsiMovingAverage
// var float rsi_supertrend = na
// rsi_supertrend := rsiSupertrend
// var int trend_direction = na
// trend_direction := trendDirection
// ----------------------------------------------------

// Plotting
// supertrendPlot = plot(rsiSupertrend, color = trendDirection == -1 ? colorUp : colorDown, title="Supertrend")
// rsiPlot = plot(rsiValue, color = color.new(color.gray, 100), title="RSI")
// overboughtLine = plot(70, color = color.from_gradient(rsiValue, 50, 70, color.new(color.gray, 70), color.new(colorDown, 0)), title="Overbought Line", linewidth = 3)
// oversoldLine = plot(30, color = color.from_gradient(rsiValue, 30, 50, color.new(colorUp, 0), color.new(color.gray, 70)), title="Oversold Line", linewidth = 3)
// plot(rsiMovingAverage, color = color.gray, title = "RSI MA", display = showMovingAverage ? display.all : display.none, linewidth = 1)
// plot(50, color = color.gray, title="Mid Line")

// // Filling
// fill(overboughtLine, oversoldLine, color = color.new(color.gray, 90), title="Overbought/Oversold Fill")
// fill(supertrendPlot, rsiPlot, color = trendDirection == 1 ? color.new(colorDown, 90) : color.new(colorUp, 90), title="Trend Fill")
// fill(supertrendPlot, rsiPlot, rsiValue, rsiSupertrend, color.new(chart.bg_color, 1000), trendDirection == 1 ? colorDown : colorUp)

// // Char plotting for crossover and crossunder
// plotshape(ta.crossover(rsiSupertrend, rsiValue) and rsiSupertrend > 70 ? 85 : na, style=shape.triangledown, location=location.absolute, color=colorDown, size=size.tiny, title="Crossover Down")
// plotshape(ta.crossunder(rsiSupertrend, rsiValue) and rsiSupertrend < 30 ? 15 : na, style=shape.triangleup, location=location.absolute, color=colorUp, size=size.tiny, title="Crossunder Up")

// //Alerts
// alertcondition(ta.crossover(rsiValue, rsiSupertrend), "RSI Bullish Supertrend")
// alertcondition(ta.crossunder(rsiValue, rsiSupertrend), "RSI Bearish Supertrend")
// alertcondition(ta.crossover(rsiSupertrend, rsiValue) and rsiSupertrend > 70, "RSI Bullish Reversal")
// alertcondition(ta.crossunder(rsiSupertrend, rsiValue) and rsiSupertrend < 30, "RSI Bearish Reversal")

Overview

Supertrended RSI [AlgoAlpha] first computes standard RSI, with an optional Hull Moving Average smoothing step, and computes a secondary moving average of the oscillator across multiple selectable types. It then applies a customized Supertrend algorithm directly to the RSI values using an adapted Average True Range calculation. The indicator tracks oscillator direction shifts when the RSI crosses its upper or lower dynamic bands.

Details

Published by

nersent on GitHub

Code credit

AlgoAlpha, as written in the script's header

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

Oscillators & momentum, Trend, Moving averages, Volatility & bands

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

backtestindicatorjavascriptpandas-tapinescriptpythontata-libtradingviewvectorized

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
RSI Lengthint14relativeStrengthIndexLength
RSI Smoothing Lengthint21smoothingLength
RSI SourcesourceclosersiInputSource
Smooth RSI?boolfalseisSmoothed
MA Lengthint14movingAverageLength
MA TypestringHMAmovingAverageType
Factorfloat0.8trendFactor
ATR Lengthint10averageTrueRangeLength
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

MultiIndicator

by capissimo
114 stars

MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a

Indicator v4 Oscillators & momentumTrend
Updated 1 year ago · None stated GitHub repository of MultiIndicator

This indicator computes and plots multiple technical analysis features on a separate pane. It calculates EMA-based trend indicators including fast and slow EMAs along with their slope, momentum oscillators such as RSI, Stochastic RSI, and MACD histogram, WaveT

Indicator v6 TrendOscillators & momentum
Updated yesterday · MIT GitHub repository of Vein Feature Exporter Core 4H [WavesUnchained]
56 stars

Double Screened Decision is a multi-timeframe trend and momentum indicator overlaid directly on the price chart. It dynamically selects a higher timeframe based on the active chart resolution to evaluate higher-timeframe MACD, Bollinger Bands, RSI, and Stochas

Indicator v5 TrendMoving averages Repaints
Updated 4 months ago · None stated GitHub repository of Double Screened Decision
24 stars

This indicator plots Bollinger Bands on the price chart alongside a baseline moving average to identify trend-aligned swing setups. It calculates trend bias by comparing the Bollinger Bands basis to a customizable moving average, such as a 200 EMA. Trade signa

Indicator v5 Volatility & bandsOscillators & momentum
Updated 4 years ago · MPL-2.0 GitHub repository of Bollinger Band Swing

Index Intraday Analyst

by chris-c-thomas
14 stars

Index Intraday Analyst overlays CBOE cash indices such as SPX, NDX, RUT, and DJX. It plots a multi-EMA ribbon, a session-anchored TWAP with standard-deviation bands, and session levels such as prior-day high, low, and close, the opening range, and the high and

Indicator v6 TrendOscillators & momentum
Updated 6 months ago · MIT GitHub repository of Index Intraday Analyst

RePaNoCHa V4

by wocclyl
9 stars

RePaNoCHa V4 is an overlay alert indicator that plots a Tillson T3 moving average on the price chart and colors it by whether the line is rising or falling. It combines that slope with a range filter, ADX, parabolic SAR, RSI, and MACD to mark long and short si

Indicator v4 TrendOscillators & momentum
Updated 7 years ago · MIT GitHub repository of RePaNoCHa V4

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers