Indicator · Pine Script v5 · Own pane

RSI Bar Chart v2

by regalouisei· code credited to fikira

This indicator plots multiple RSI oscillators calculated from various price sources and timeframes in a separate pane.

View on GitHub

Repaints

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code200
Settings29inputs
LicenceNone statedfile: MPL-2.0
Last update8 months ago25 Feb 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

200 lines of Pine Script v5 from pinescript/editors_picks/rsi-bar-chart.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

rsi-bar-chart.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © fikira
//@version=5
indicator('RSI Bar Chart v2', overlay=false, max_lines_count=500, max_labels_count=500)

src1 = input.source(close, '', group='RSI (source, length, TF)', inline='RSI 1')
len1 = input.int(7, '', group='RSI (source, length, TF)', inline='RSI 1')
tf1  = input.timeframe('', '', group='RSI (source, length, TF)', inline='RSI 1')

src2 = input.source(close, '', group='RSI (source, length, TF)', inline='RSI 2')
len2 = input.int(14, '', group='RSI (source, length, TF)', inline='RSI 2')
tf2  = input.timeframe('', '', group='RSI (source, length, TF)', inline='RSI 2')

src3 = input.source(close, '', group='RSI (source, length, TF)', inline='RSI 3')
len3 = input.int(20, '', group='RSI (source, length, TF)', inline='RSI 3')
tf3  = input.timeframe('', '', group='RSI (source, length, TF)', inline='RSI 3')

src4 = input.source(close, '', group='RSI (source, length, TF)', inline='RSI 4')
len4 = input.int(14, '', group='RSI (source, length, TF)', inline='RSI 4')
tf4  = input.timeframe('D', '', group='RSI (source, length, TF)', inline='RSI 4')

src5 = input.source(close, '', group='RSI (source, length, TF)', inline='RSI 5')
len5 = input.int(14, '', group='RSI (source, length, TF)', inline='RSI 5')
tf5  = input.timeframe('W', '', group='RSI (source, length, TF)', inline='RSI 5')

rsi1_  = ta.rsi(src1, len1)
rsi2_  = ta.rsi(src2, len2)
rsi3_  = ta.rsi(src3, len3)
rsi4_  = ta.rsi(src4, len4)
rsi5_  = ta.rsi(src5, len5)

rsi1   = barstate.islast ? request.security(syminfo.tickerid, tf1, rsi1_, lookahead=barmerge.lookahead_on) : na
rsi2   = barstate.islast ? request.security(syminfo.tickerid, tf2, rsi2_, lookahead=barmerge.lookahead_on) : na
rsi3   = barstate.islast ? request.security(syminfo.tickerid, tf3, rsi3_, lookahead=barmerge.lookahead_on) : na
rsi4   = barstate.islast ? request.security(syminfo.tickerid, tf4, rsi4_, lookahead=barmerge.lookahead_on) : na
rsi5   = barstate.islast ? request.security(syminfo.tickerid, tf5, rsi5_, lookahead=barmerge.lookahead_on) : na

buy_   = input.int(30, title='limit buy' , group='    ———~~~~~~~~~~~~~~~~~~~~~~~~~~~~———')
sel_   = input.int(70, title='limit sell', group='    ———~~~~~~~~~~~~~~~~~~~~~~~~~~~~———')

size   = input.string(size.small, title='Label Size', group='Labels', options=[size.tiny, size.small, size.normal, size.large, size.auto])
lb     = input.int(1, title='offset labels (right)', group='Labels')

plot   = input.string('line', title='Type RSI line', group='RSI line', options=['line', 'arrow'])
w      = input.int(2, title='RSI linewidth', group='RSI line')

colS   = input.color(color.red   , title=''        , group='rsi line colors', inline='col1')
col50H = input.color(color.green , title=' < SELL ', group='rsi line colors', inline='col1')
col50L = input.color(color.orange, title='< 50 >'  , group='rsi line colors', inline='col1')
colB   = input.color(color.lime  , title=' BUY > ' , group='rsi line colors', inline='col1')

left   = input.color(color.new(color.red  , 60), title='', group='bar colors', inline='bar colors')
middle = input.color(color.new(color.white, 80), title='', group='bar colors', inline='bar colors')
right  = input.color(color.new(color.lime , 60), title='', group='bar colors', inline='bar colors')

max    = input.int(20, minval=10, step=10, title='', group='size of indicator')

div    = 100 / max
buy    = buy_ / div
sel    = sel_ / div
mid    = max / 2

// functions

f_brst(index) =>
    barstate.islast ? bar_index - index : na

bi0  = f_brst( 0 )
bi5  = f_brst(buy)
bi10 = f_brst(mid)
bi15 = f_brst(sel)
bi20 = f_brst(max)

f_plot(rsi) =>
    bir = rsi > 50 ? mid + math.round((rsi - 50) / div) : math.round(rsi / div)
    bir

f_txt(rsi) =>
    bto = rsi > 50 ? bi10 + 1 : bi10 - 1
    bto

f_arrow(brsi) =>
    arrow = brsi > mid ? line.style_arrow_right : line.style_arrow_left
    arrow

f_col(rsi) =>
    col = rsi >= sel_ ? colS : rsi > 50 ? col50H : rsi < 50 ? col50L : colB
    col

//barstateIsReallyLast = barstate.isrealtime and not barstate.isconfirmed

f_htfLabel(_txt, _y, _color, _offsetLabels) =>
    var label lb = label.new(bar_index, close), label.delete(lb)
    if not barstate.isconfirmed
        lb := label.new(bar_index + _offsetLabels, _y, _txt, xloc.bar_index, yloc.price, _color, label.style_none, _color, size)

f_rsi(y, brsi, col, linar, bto, yt, rsi, text_1, len, tf) =>
    var line l1  = line.new (bar_index, close, bar_index, close), line.delete(l1)
    var line l2  = line.new (bar_index, close, bar_index, close), line.delete(l2)
    var line l3  = line.new (bar_index, close, bar_index, close), line.delete(l3)
    var line l4  = line.new (bar_index, close, bar_index, close), line.delete(l4)
    var line l5  = line.new (bar_index, close, bar_index, close), line.delete(l5)

    var label b1 = label.new(bar_index, close), label.delete(b1)

    l1 := line.new (x1=bi10, y1=y, x2=brsi, y2=y, color=col, style=linar, width=w)
    l2 := line.new (x1=bi0 , y1=y, x2=bi5 , y2=y, color=right , width=6)
    l3 := line.new (x1=bi5 , y1=y, x2=bi10, y2=y, color=middle, width=6)
    l4 := line.new (x1=bi10, y1=y, x2=bi15, y2=y, color=middle, width=6)
    l5 := line.new (x1=bi15, y1=y, x2=bi20, y2=y, color=left  , width=6)

    b1 := label.new(x=bto  , y=yt, text=str.tostring(math.round(rsi * 10) / 10), style=label.style_none, textcolor=col, size=size, textalign=text.align_center)
    f_htfLabel(text_1 + ' ' + ' (' + str.tostring(len) + ') ' + tf, yt + 0.15, col  , lb            )


bir1  = f_plot(rsi1)
bir2  = f_plot(rsi2)
bir3  = f_plot(rsi3)
bir4  = f_plot(rsi4)
bir5  = f_plot(rsi5)
bto1  = f_txt (rsi1)
bto2  = f_txt (rsi2)
bto3  = f_txt (rsi3)
bto4  = f_txt (rsi4)
bto5  = f_txt (rsi5)
brsi1 = f_brst(bir1)
brsi2 = f_brst(bir2)
brsi3 = f_brst(bir3)
brsi4 = f_brst(bir4)
brsi5 = f_brst(bir5)
col1  = f_col (rsi1)
col2  = f_col (rsi2)
col3  = f_col (rsi3)
col4  = f_col (rsi4)
col5  = f_col (rsi5)

linar1 = plot == 'line' ? line.style_solid : f_arrow(brsi1)
linar2 = plot == 'line' ? line.style_solid : f_arrow(brsi2)
linar3 = plot == 'line' ? line.style_solid : f_arrow(brsi3)
linar4 = plot == 'line' ? line.style_solid : f_arrow(brsi4)
linar5 = plot == 'line' ? line.style_solid : f_arrow(brsi5)

_0  = -0.25 // vertical line - bottom
_4  =  4.25 // vertical line - top

y_  = -1    // lower text (50,...) 


y1t =  3.5  // text ri (RSI 1 + length)
y1  =  4    // RSI 1 line

y2t =  2.5  // text ri (RSI 2 + length)
y2  =  3    // RSI 2 line

y3t =  1.5  // text ri (RSI 3 + length)
y3  =  2    // RSI 3 line

y4t =  0.5  // text ri (RSI 4 + length)
y4  =  1    // RSI 4 line

y5t = -0.5  // text ri (RSI 5 + length)
y5  =  0    // RSI 5 line


rsi_tf1 = request.security(syminfo.tickerid, tf1, rsi1_[1], lookahead=barmerge.lookahead_on) 
rsi_tf2 = request.security(syminfo.tickerid, tf2, rsi2_[1], lookahead=barmerge.lookahead_on) 
rsi_tf3 = request.security(syminfo.tickerid, tf3, rsi3_[1], lookahead=barmerge.lookahead_on) 
rsi_tf4 = request.security(syminfo.tickerid, tf4, rsi4_[1], lookahead=barmerge.lookahead_on) 
rsi_tf5 = request.security(syminfo.tickerid, tf5, rsi5_[1], lookahead=barmerge.lookahead_on) 

var line l1 = line.new(na, na, na, na, color=color.new(color.white, 30)) 
var line l2 = line.new(na, na, na, na, color=color.new(color.lime , 30)) 
var line l3 = line.new(na, na, na, na, color=color.new(color.white, 30)) 
var line l4 = line.new(na, na, na, na, color=color.new(color.red  , 30)) 
var line l5 = line.new(na, na, na, na, color=color.new(color.white, 30)) 

var label lb1 = label.new(na, na, style=label.style_none, size=size, textalign=text.align_center, textcolor=color.lime ) 
var label lb2 = label.new(na, na, style=label.style_none, size=size, textalign=text.align_center, textcolor=color.lime ) 
var label lb3 = label.new(na, na, style=label.style_none, size=size, textalign=text.align_center, textcolor=color.white) 
var label lb4 = label.new(na, na, style=label.style_none, size=size, textalign=text.align_center, textcolor=color.red  ) 
var label lb5 = label.new(na, na, style=label.style_none, size=size, textalign=text.align_center, textcolor=color.red  ) 

if not barstate.isconfirmed
    line.set_xy1(l1, bi0 , _0), line.set_xy2(l1, bi0  , _4)
    line.set_xy1(l2, bi5 , _0), line.set_xy2(l2, bi5  , _4)
    line.set_xy1(l3, bi10, _0), line.set_xy2(l3, bi10 , _4)
    line.set_xy1(l4, bi15, _0), line.set_xy2(l4, bi15 , _4)
    line.set_xy1(l5, bi20, _0), line.set_xy2(l5, bi20 , _4)

    f_rsi(y1, brsi1, col1, linar1, bto1, y1t, rsi1, 'RSI 1', len1, tf1)
    f_rsi(y2, brsi2, col2, linar2, bto2, y2t, rsi2, 'RSI 2', len2, tf2)
    f_rsi(y3, brsi3, col3, linar3, bto3, y3t, rsi3, 'RSI 3', len3, tf3)
    f_rsi(y4, brsi4, col4, linar4, bto4, y4t, rsi4, 'RSI 4', len4, tf4)
    f_rsi(y5, brsi5, col5, linar5, bto5, y5t, rsi5, 'RSI 5', len5, tf5)
    // text below
    label.set_xy(lb1, bi0 ,y_), label.set_text(lb1, text='0'               )
    label.set_xy(lb2, bi5 ,y_), label.set_text(lb2, text=str.tostring(buy_))
    label.set_xy(lb3, bi10,y_), label.set_text(lb3, text='50'              )
    label.set_xy(lb4, bi15,y_), label.set_text(lb4, text=str.tostring(sel_))
    label.set_xy(lb5, bi20,y_), label.set_text(lb5, text='100'             )

Overview

RSI Bar Chart v2 renders the RSIs as customizable lines with different colors, widths, and styles. Colored bars highlight overbought and oversold zones based on user-defined levels. Additional labels and bar size controls are available. Settings allow independent adjustment of source, length, and timeframe for each RSI instance. The indicator draws on the price chart but operates in a dedicated pane. A notable limitation is its lookahead behavior, which incorporates future data into current bar calculations.

Details

Published by

regalouisei on GitHub

Code credit

fikira, as written in the script's header

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

Oscillators & momentum

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Reads higher-timeframe data with lookahead on, so the history can show signals that were not there in real time

Settings

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

SettingTypeDefaultVariable
src1sourceclosesrc1
len1int7len1
tf1timeframetf1
src2sourceclosesrc2
len2int14len2
tf2timeframetf2
src3sourceclosesrc3
len3int20len3
tf3timeframetf3
src4sourceclosesrc4
len4int14len4
tf4timeframeDtf4
Show all 29 settings
SettingTypeDefaultVariable
src5sourceclosesrc5
len5int14len5
tf5timeframeWtf5
limit buyint30buy_
limit sellint70sel_
Label Sizestringsize.smallsize
offset labels (right)int1lb
Type RSI linestringlineplot
RSI linewidthint2w
colScolorcolor.redcolS
< SELL colorcolor.greencol50H
< 50 >colorcolor.orangecol50L
BUY > colorcolor.limecolB
leftcolorcolor.new(color.red , 60)left
middlecolorcolor.new(color.white, 80)middle
rightcolorcolor.new(color.lime , 60)right
maxint20max
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

Asymmetrical RSI

by everget
948 stars

Asymmetrical RSI is an indicator that computes a custom relative strength index from the rate of change of a user-selected source. It plots the resulting ARSI line in a separate pane with color coding that turns green above the overbought level and red below t

Indicator v4 Oscillators & momentum
Updated 10 days ago · GPL-3.0 GitHub repository of Asymmetrical RSI

This indicator calculates momentum setups based on the Relative Strength Index (RSI) and plots in a separate pane. It offers multiple scanning modes such as Continuous Break, Continuous Retracement, Flip Break, Flip Retracement, and both regular and hidden div

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

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop
261 stars

This indicator demonstrates an experimental graph-style scatter visualization within a separate pane using Pine Script arrays. It tracks two features across recent bars: the single-bar price change and a scaled 14-period Relative Strength Index. Values are loa

Indicator v4 Oscillators & momentum
Updated 4 years ago · None stated GitHub repository of Example: Graph Style - 4th Dimension RSI

KD指標

by TaichiS
219 stars

This script calculates and plots a Stochastic Oscillator (KD indicator) in a separate chart pane. It determines the fast stochastic value over a 9-period lookback, then applies a 3-period Simple Moving Average (SMA) to create the %K line, and a second 3-period

Indicator v4 Oscillators & momentum
Updated 5 years ago · None stated GitHub repository of KD指標

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