Indicator · Pine Script v4 · Own pane

Relative Strength of Volume Indicators by DGT

by amico1234· code credited to dgtrd

This indicator calculates the Relative Strength Index (RSI) applied to various volume-weighted indicators, including Accumulation/Distribution, Elder's Force Index, Money Flow Index, On Balance Volume, and Price Volume Trend.

View on GitHub

GitHub stars1on the repository
Pine versionv4older, still runs
Lines of code133
Settings8inputs
LicenceNone statedfile: MPL-2.0
Last update2 years ago2 Mar 2024

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

133 lines of Pine Script v4 from rsidgt.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

rsidgt.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © dgtrd

//@version=4
study("Relative Strength of Volume Indicators by DGT", shorttitle="RSI(VOLx) ʙʏ DGT ☼☾", format=format.price, max_bars_back=252)

// -Input ======================================================================================= //

length  = input(13, minval=1, title="Length")

// Relative Strength application on Volume Indicators
addRsiX = input(title = "► Relative Strength of" , options=["Accumulation/Distribution", "Elders Force Index", "Money Flow Index", "On Balance Volume","Price Volume Trend"], defval="On Balance Volume")
smooth  = input(2,      "Smooth RSI, with Least Squares Method", minval=2)

// Volume Histogram/MA/OSC
volHist = input(title = "► Volume Histogram, and", options=["Moving Average", "Volume Oscillator", "Just Volume Histogram", "Remove Both"], defval="Moving Average")
relVol  = input(true, "Relative Volume Histogram (4 Color)")
size    = input(10, title="Change Plotting Size of Volume Histogram")

// Volume Based Colored Bars
vbcb    = input(true, title = "► Volume Based Colored Bars")

// Labels 
lables  = input(false,  "Display Labels (RSI & Volume)")

// -Calculation ================================================================================= //

// RSI
rsi  = rsi(close, length)
srsi = linreg(rsi, smooth, 0)

var rsiText = ""
rsix = if addRsiX == "Accumulation/Distribution"
    rsiText := "rsi(ad,"
    rsi(cum(close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume), length)
    
else if addRsiX == "Elders Force Index"
    rsiText := "rsi(efi,"
    rsi(ema(change(close) * volume, length), length)
    
else if addRsiX == "Money Flow Index"
    rsiText := "mfi(hlc3,"
    rsi(sum(volume * (change(hlc3) <= 0 ? 0 : hlc3), length), sum(volume * (change(hlc3) >= 0 ? 0 : hlc3), length))
    
else if addRsiX == "On Balance Volume"
    rsiText := "rsi(obv,"
    rsi(cum(sign(change(close)) * volume), length)
    
else if addRsiX == "Price Volume Trend"
    rsiText := "rsi(pvt,"
    rsi(cum(change(close)/close[1] * volume), length)

srsix = linreg(rsix, smooth, 0)

// Volume Histogram
mean = sma(volume, length)

volx = if volHist == "Moving Average"
    sma(volume/mean * size, length)
    
else if volHist == "Volume Oscillator"
    (ema(volume, 5) - ema(volume, 10))/ema(volume, 10) * 100

gColor = color.new(color.gray, 25)

volSma = if relVol
    sma(volume/mean * size, length)

// Volume Based Colored Bars by KIVANÇ ÖZBİLGİÇ

vbcbColor = if close < open
    if volume > mean * 1.5
        #910000
    else if volume >= mean * 0.5 and volume <= mean * 1.5
        color.red 
    else 
        color.orange
else
    if volume > mean * 1.5
        #006400
    else if volume >= mean * 0.5 and volume <= mean * 1.5
        color.green 
    else 
        #7FFFD4

    
// -Plot ======================================================================================== //

// Volume
plot(nz(volume) and volHist != "Remove Both" ? volume/mean * size : na, color=relVol ? open > close ? volume/mean * abs(size) > abs(volSma) ? color.red : gColor : volume/mean * abs(size) > abs(volSma) ? color.green : color.gray : open > close ? color.red : color.green, style=plot.style_columns, title="Volume, normalized to fit the Scale", transp=55)
plot(nz(volume) ? volx : na, title="Volume MA/OCS", color=color.teal)

// Threshold Lines
p1 = hline(75, color=color.red, title="Overbought Higher Theshold Level", linestyle=hline.style_dotted)
p2 = hline(65, color=color.red, title="Overbought Lower Theshold Level" , linestyle=hline.style_dotted)
fill(p1, p2,   color=color.red, title="Overbought Background")

hline(50, color=color.gray, title="Middle Line (Bull/Bear Border Line)" , linestyle=hline.style_dotted, linewidth=2)

p3 = hline(35, color=color.green, title="Oversold Higher Theshold Level", linestyle=hline.style_dotted)
p4 = hline(25, color=color.green, title="Oversold Lower Theshold Level" , linestyle=hline.style_dotted)
fill(p3, p4,   color=color.green, title="Oversold Background")

// RSI
plot(srsi, title="Relative Strength of Price", color=#8E1599)
plot(nz(volume) ? srsix : na, title="Relative Strength of Volume X", color=color.aqua) 

// Volume Based Colored Bars by KIVANÇ ÖZBİLGİÇ
barcolor(nz(volume) and vbcb ? vbcbColor : na, title = "Volume Based Colored Bars by [KıvançÖZBİLGİÇ]")

// Labels
volval = if volume > 1000000
    tostring(volume/1000000, "#.##") + "M"
else if volume > 1000
    tostring(volume/1000   , "#.##") + "K"

if lables
    label rsiLabel = label.new(bar_index, 65, text="Relative Strength Index"
     ,tooltip="rsi(close, " + tostring(length) + ") value : " + tostring(rsi, "#.##")
     ,color=#8E1599, style=label.style_label_left, textcolor=color.white)
    label.delete(rsiLabel[1])
    
    if nz(volume)
        label rsixLabel = label.new(bar_index, 35, text=addRsiX
         ,tooltip=rsiText + tostring(length) + ") value : " + tostring(rsix, "#.##")
         ,color=color.aqua, style=label.style_label_left, textcolor=color.white)
        label.delete(rsixLabel[1])
        
        if volHist != "Remove Both"
            label volLabel = label.new(bar_index, 10, text="Volume, source " + syminfo.prefix + " exchange"
             ,tooltip="Current Volume value : " + volval
             ,color=color.teal, style=label.style_label_left, textcolor=color.white)
            label.delete(volLabel[1])

Overview

The resulting volume-RSI values are smoothed using least squares linear regression and plotted in a separate pane alongside normalized volume histograms or volume oscillators. Inputs allow users to adjust the smoothing period, select the volume metric, and toggle volume-based bar coloring.

Details

Published by

amico1234 on GitHub

Code credit

dgtrd, as written in the script's header

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Oscillators & momentum, Volume

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
Lengthint13length
► Relative Strength ofstringOn Balance VolumeaddRsiX
Smooth RSI, with Least Squares Methodint2smooth
► Volume Histogram, andstringMoving AveragevolHist
Relative Volume Histogram (4 Color)booltruerelVol
Change Plotting Size of Volume Histogramint10size
► Volume Based Colored Barsbooltruevbcb
Display Labels (RSI & Volume)boolfalselables
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

Money Flow Index

by everget
948 stars

Calculates the standard Money Flow Index (MFI) oscillator alongside an exponential moving average signal line in a separate pane. The script visually highlights trend conditions through dynamic ribbon filling, optional difference histogram bars, and overbought

Indicator v4 Oscillators & momentumVolume
Updated 10 days ago · GPL-3.0 GitHub repository of Money Flow Index

Commitment Gauge

by harryguiacorn
219 stars

This indicator measures directional momentum by evaluating candlestick body proportions and volume over a user-defined lookback window. It computes the ratio of candle body to total range, weights the cumulative value by volume and absolute body size, and dete

Indicator v4 VolumeCandlestick patterns
Updated 1 year ago · None stated GitHub repository of Commitment Gauge

Aggregate Signal

by capissimo
114 stars

This indicator builds an aggregate oscillator in a separate pane. It scales open, high, low, close, and volume into a 0 to 1 range, then averages scaled readings from MACD, a MACD histogram, RSI, stochastic, CCI, momentum, OBV, a directional index, volume-weig

Indicator v4 Oscillators & momentumVolume Repaints
Updated 1 year ago · None stated GitHub repository of Aggregate Signal

This indicator calculates the Bill Williams Market Facilitation Index as the high-low range divided by volume, or zero when volume is zero. It compares the index and volume with the previous bar and assigns one of four zones: green for both rising, fade for bo

Indicator v6 VolumeOscillators & momentum
Updated 4 weeks ago · Apache-2.0 GitHub repository of Bill Williams Market Facilitation Index

PPO ATR Bands

by cryptorife
75 stars

PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l

Indicator v4 Oscillators & momentumMoving averages
Updated 3 years ago · GPL-3.0 GitHub repository of PPO ATR Bands

Chaikin Oscillator

by be-thomas
65 stars

Calculates the Chaikin Oscillator by taking the difference between a fast exponential moving average and a slow exponential moving average of the Accumulation/Distribution line. It plots the resulting line in a separate pane alongside a dashed zero reference l

Indicator v4 Oscillators & momentumVolume
Updated 4 days ago · GPL-3.0 GitHub repository of Chaikin Oscillator

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