RSI c/w MA, ADX and ATR data 
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5

indicator('RSI c/w ADX and ATR data', overlay=false, max_bars_back=4000)
Src = input(defval=close, title='Source')
rsilen = input.int(defval=14, title='RSI Length', minval=1)
length = input.int(defval=20, title='CMF Length', minval=1)

ad = close == high and close == low or high == low ? 0 : (2 * close - low - high) / (high - low) * volume
mf = math.sum(ad, length) / math.sum(volume, length)

//-------- ADX ----
showadx = input(defval=false, title='Show ADX')
adxlen = input(14, title='ADX Smoothing')
dilen = input(14, title='DI Length')

dirmov(len) =>
    up = ta.change(high)
    down = -ta.change(low)
    plusDM = na(up) ? na : up > down and up > 0 ? up : 0
    minusDM = na(down) ? na : down > up and down > 0 ? down : 0
    truerange = ta.rma(ta.tr, len)
    plus = fixnan(100 * ta.rma(plusDM, len) / truerange)
    minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
    [plus, minus]
adx(dilen, adxlen) =>
    [plus, minus] = dirmov(dilen)
    sum = plus + minus
    adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
    adx
adxcol = color.gray
sig = adx(dilen, adxlen)
plot(showadx ? sig : na, linewidth=1, transp=20)

Rsi = ta.rsi(Src, rsilen)

//src = Rsi

h3 = hline(70, color=color.red, linewidth=2, linestyle=hline.style_solid)
h4 = hline(30, color=color.green, linewidth=2, linestyle=hline.style_solid)
h1 = hline(55, color=#9915ff)
h2 = hline(45, color=#9915ff)
hline(50, color=color.gray)

fill(h1, h2, color=color.new(#9915ff, 95), title='Background')

plot(Rsi, linewidth=2, transp=20)



attt = ta.atr(14)

showrsma = input(defval=false, title='Show RSI MA')
malen = input.int(defval=20, title='RSI SMA Length', minval=2)
rsma = ta.sma(Rsi, malen)
plot(showrsma ? rsma : na, linewidth=1, color=color.new(color.orange, 10))

var testTable = table.new(position = position.bottom_right, columns = 1, rows = 3, bgcolor = color.red, border_width = 1)
if barstate.islast
    table.cell(table_id = testTable, column = 0, row = 0, text = "RSI is " + str.tostring(math.round(Rsi,1)), text_color=color.white)
    table.cell(table_id = testTable, column = 0, row = 1, text = "ADX is " + str.tostring(math.round(sig,1)), text_color=color.white)
    table.cell(table_id = testTable, column = 0, row = 2, text = "ATR is " + str.tostring(math.round(attt,2)), text_color=color.white)

