Indicator · Pine Script v6 · Own pane

Multi-Timeframe RSI [Agent Example]

by shubhamtaywade82

Calculates Relative Strength Index (RSI) across four configurable timeframes using security calls with lookahead disabled.

View on GitHub

Archived by its author

GitHub stars1on the repository
Pine versionv6current
Lines of code110
Settings15inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago31 May 2026

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

110 lines of Pine Script v6 from indicators/agent-examples/multi-timeframe-rsi.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

multi-timeframe-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/
// Ported from pinescript-agents/examples/intermediate/multi-timeframe-rsi.pine for local testing in pinescripts-collections.

//@version=6
indicator("Multi-Timeframe RSI [Agent Example]", "MTF RSI · AE", overlay=false)

rsiLength = input.int(14, "RSI Length", minval=1, group="RSI")
rsiSource = input.source(close, "Source", group="RSI")

tf1 = input.timeframe("", "Timeframe 1 (Current)", group="Timeframes")
tf2 = input.timeframe("15", "Timeframe 2", group="Timeframes")
tf3 = input.timeframe("60", "Timeframe 3", group="Timeframes")
tf4 = input.timeframe("240", "Timeframe 4", group="Timeframes")

lookbackBars = input.int(50, "Divergence Lookback", minval=10, group="Divergence")

oversold = input.int(30, "Oversold Level", group="Levels")
overbought = input.int(70, "Overbought Level", group="Levels")

showTable = input.bool(true, "Show MTF Table", group="Display")
showDivergence = input.bool(true, "Show Divergence", group="Display")
showConfluence = input.bool(true, "Show Confluence Score", group="Display")
bullColorInput = input.color(#089981, "Bullish Color", group="Colors")
bearColorInput = input.color(#f23645, "Bearish Color", group="Colors")
neutralColorInput = input.color(color.new(#2a2e39, 0), "Neutral Color", group="Colors")

rsi_tf1 = tf1 == "" ? ta.rsi(rsiSource, rsiLength) : request.security(syminfo.tickerid, tf1, ta.rsi(rsiSource, rsiLength), lookahead=barmerge.lookahead_off)
rsi2 = request.security(syminfo.tickerid, tf2, ta.rsi(rsiSource, rsiLength), lookahead=barmerge.lookahead_off)
rsi3 = request.security(syminfo.tickerid, tf3, ta.rsi(rsiSource, rsiLength), lookahead=barmerge.lookahead_off)
rsi4 = request.security(syminfo.tickerid, tf4, ta.rsi(rsiSource, rsiLength), lookahead=barmerge.lookahead_off)

rsi1 = rsi_tf1

pivotHigh = ta.pivothigh(high, 5, 5)
pivotLow = ta.pivotlow(low, 5, 5)

var float lastPivotHighPrice = na
var float lastPivotHighRSI = na
var int lastPivotHighBar = na

var float lastPivotLowPrice = na
var float lastPivotLowRSI = na
var int lastPivotLowBar = na

if not na(pivotHigh)
    lastPivotHighPrice := high[5]
    lastPivotHighRSI := rsi1[5]
    lastPivotHighBar := bar_index - 5

if not na(pivotLow)
    lastPivotLowPrice := low[5]
    lastPivotLowRSI := rsi1[5]
    lastPivotLowBar := bar_index - 5

var bool bullishDiv = false
var bool bearishDiv = false
bullishDiv := false
bearishDiv := false
if not na(pivotLow) and not na(lastPivotLowPrice) and bar_index - lastPivotLowBar < lookbackBars and low[5] < lastPivotLowPrice and rsi1[5] > lastPivotLowRSI
    bullishDiv := true
if not na(pivotHigh) and not na(lastPivotHighPrice) and bar_index - lastPivotHighBar < lookbackBars and high[5] > lastPivotHighPrice and rsi1[5] < lastPivotHighRSI
    bearishDiv := true

confluenceScore = (rsi1 < oversold ? 1.0 : 0.0) + (rsi2 < oversold ? 0.75 : 0.0) + (rsi3 < oversold ? 0.5 : 0.0) + (rsi4 < oversold ? 0.25 : 0.0) - (rsi1 > overbought ? 1.0 : 0.0) - (rsi2 > overbought ? 0.75 : 0.0) - (rsi3 > overbought ? 0.5 : 0.0) - (rsi4 > overbought ? 0.25 : 0.0) + (bullishDiv ? 2.0 : 0.0) - (bearishDiv ? 2.0 : 0.0)

rsiColor = rsi1 > overbought ? bearColorInput : rsi1 < oversold ? bullColorInput : color.new(neutralColorInput, 0)
plot(rsi1, "RSI", rsiColor, linewidth=2)

plot(rsi2, "RSI TF2", color.new(color.orange, 50), linewidth=1)
plot(rsi3, "RSI TF3", color.new(color.purple, 50), linewidth=1)
plot(rsi4, "RSI TF4", color.new(color.gray, 50), linewidth=1)

h_ob = hline(overbought, "Overbought", bearColorInput, hline.style_dashed)
h_os = hline(oversold, "Oversold", bullColorInput, hline.style_dashed)
hline(50, "Middle", color.new(neutralColorInput, 40), hline.style_dotted)

h_top = hline(100, "Top", color.new(bearColorInput, 100))
h_bot = hline(0, "Bottom", color.new(bullColorInput, 100))
fill(h_ob, h_top, color.new(bearColorInput, 92))
fill(h_os, h_bot, color.new(bullColorInput, 92))

plotshape(showDivergence and bullishDiv, "Bullish Divergence", shape.triangleup, location.bottom, bullColorInput, size=size.small)
plotshape(showDivergence and bearishDiv, "Bearish Divergence", shape.triangledown, location.top, bearColorInput, size=size.small)

plot(showConfluence ? confluenceScore * 10 + 50 : na, "Confluence Score", color.yellow, linewidth=1, style=plot.style_stepline)

var table mtfTable = table.new(position.top_right, 2, 5, bgcolor=color.new(#0b0e14, 25), border_color=color.new(neutralColorInput, 70))
if showTable and barstate.islast
    table.cell(mtfTable, 0, 0, "Timeframe", bgcolor=color.new(neutralColorInput, 65), text_color=color.white, text_size=size.small)
    table.cell(mtfTable, 1, 0, "RSI", bgcolor=color.new(neutralColorInput, 65), text_color=color.white, text_size=size.small)
    table.cell(mtfTable, 0, 1, tf1 == "" ? timeframe.period : tf1, text_color=color.white, text_size=size.small)
    rsi1Color = rsi1 > overbought ? bearColorInput : rsi1 < oversold ? bullColorInput : color.new(#ffd166, 0)
    table.cell(mtfTable, 1, 1, str.tostring(rsi1, "#.#"), text_color=rsi1Color, text_size=size.small)
    table.cell(mtfTable, 0, 2, tf2, text_color=color.white, text_size=size.small)
    rsi2Color = rsi2 > overbought ? bearColorInput : rsi2 < oversold ? bullColorInput : color.new(#ffd166, 0)
    table.cell(mtfTable, 1, 2, str.tostring(rsi2, "#.#"), text_color=rsi2Color, text_size=size.small)
    table.cell(mtfTable, 0, 3, tf3, text_color=color.white, text_size=size.small)
    rsi3Color = rsi3 > overbought ? bearColorInput : rsi3 < oversold ? bullColorInput : color.new(#ffd166, 0)
    table.cell(mtfTable, 1, 3, str.tostring(rsi3, "#.#"), text_color=rsi3Color, text_size=size.small)
    table.cell(mtfTable, 0, 4, tf4, text_color=color.white, text_size=size.small)
    rsi4Color = rsi4 > overbought ? bearColorInput : rsi4 < oversold ? bullColorInput : color.new(#ffd166, 0)
    table.cell(mtfTable, 1, 4, str.tostring(rsi4, "#.#"), text_color=rsi4Color, text_size=size.small)

strongBullish = confluenceScore > 2
strongBearish = confluenceScore < -2

alertcondition(strongBullish, "Strong Bullish Signal", "Multiple timeframes oversold with bullish divergence")
alertcondition(strongBearish, "Strong Bearish Signal", "Multiple timeframes overbought with bearish divergence")
alertcondition(bullishDiv, "Bullish Divergence", "RSI Bullish Divergence Detected")
alertcondition(bearishDiv, "Bearish Divergence", "RSI Bearish Divergence Detected")

Overview

Multi-Timeframe RSI [Agent Example] identifies regular bullish and bearish divergences between price pivots and the primary RSI over a user-defined lookback window. A weighted confluence score aggregates overbought and oversold conditions across all timeframes alongside divergence signals. The script plots the multi-timeframe RSI lines in a separate indicator pane and optionally displays a status table. Users can customize RSI length, calculation source, timeframes, threshold levels, and visual display options.

Details

Published by

shubhamtaywade82 on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Oscillators & momentum, Divergence, Screeners & dashboards

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.

Settings

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

SettingTypeDefaultVariable
RSI Lengthint14rsiLength
SourcesourceclosersiSource
Timeframe 1 (Current)timeframetf1
Timeframe 2timeframe15tf2
Timeframe 3timeframe60tf3
Timeframe 4timeframe240tf4
Divergence Lookbackint50lookbackBars
Oversold Levelint30oversold
Overbought Levelint70overbought
Show MTF TablebooltrueshowTable
Show DivergencebooltrueshowDivergence
Show Confluence ScorebooltrueshowConfluence
Show all 15 settings
SettingTypeDefaultVariable
Bullish Colorcolor#089981bullColorInput
Bearish Colorcolor#f23645bearColorInput
Neutral Colorcolorcolor.new(#2a2e39, 0)neutralColorInput
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

This indicator scans a pasted list of symbols for RSI directional momentum and shows matching long and short signals in a table in a separate pane. The user chooses continuous break, continuous retracement, flip break, flip retracement, divergence, or hidden d

Indicator v6 Oscillators & momentumDivergence
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - RSI Directional Momentum Scanner
218 stars

This indicator calculates the Relative Strength Index (RSI) across four user-selected timeframes and plots the results in a separate pane. It identifies regular bullish and bearish divergences between price pivot points and the primary timeframe RSI value. Add

Indicator v6 Oscillators & momentumDivergence
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe RSI with Divergence

Oscillator Suite

by TamaraKGreen
46 stars

Oscillator Suite plots a normalised price oscillator in a separate pane and overlays a signal line that can use SMA, EMA, WMA, HMA, RMA, VWMA, T3, ZEMA, KAMA, or GKEMA. It marks bullish and bearish divergences, a smoothed money-flow series, confluence areas an

Indicator v5 Oscillators & momentumDivergence
Updated 7 weeks ago · None stated GitHub repository of Oscillator Suite
11 stars

This indicator plots a smoothed Z-score of cumulative volume delta in a separate pane, showing whether buying or selling pressure is dominant and when the reading enters extreme zones. It marks spot accumulation, climax or exhaustion, and pivot-based price-vol

Indicator v6 Oscillators & momentumVolume Repaints
Updated 7 weeks ago · MIT GitHub repository of CVD Z-Score [NeuNue]
9 stars

This indicator plots a heuristic volume-balance oscillator in a separate pane. It estimates signed volume from the close location inside each bar, multiplies that by volume, and sums the proxy over a rolling window. The sum is scaled between minus one and plus

Indicator v6 VolumeOscillators & momentum
Updated yesterday · MIT GitHub repository of CVD Bias [WavesUnchained]

KARPUZLU-RSI

by Kalumur
4 stars

Calculates a custom-period Relative Strength Index alongside an Exponential Moving Average of the RSI in a separate pane. It identifies pivot highs and lows directly on the RSI plot to highlight trendlines and potential divergence patterns. The area between th

Indicator v5 Oscillators & momentumMoving averages
Updated 2 years ago · None stated GitHub repository of KARPUZLU-RSI

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