Volume RSI
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © peacefulLizard50262

//@version=5
indicator("Volume RSI")

ema(src, len) => //{
    alpha = 2 / (len + 1)
    sum   = 0.0
    sum  := na(sum[1]) ? src : alpha * src + (1 - alpha) * nz(sum[1])
tma(src, int len) => //{
    ema1 = ema(src, len)
    ema2 = ema(ema1, len)
    ema3 = ema(ema2, len)
    tma  = 3 * (ema1 - ema2) + ema3


back   = input.int(14, 'Length')
smooth = input.bool(true, "Smoothing")
cum = ta.cum(open > close ? -float(volume) : float(volume)) 
rsi = ta.rsi(smooth ? (cum + (cum[1] * 2) + (cum[2] * 2) + cum[3])/6 : cum, back)

plot(rsi, "RSI", color=#7E57C2)

rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86)
hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86)
fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")

