// © 2021 4xDev Development Company, support@4xdev.com //@version=4 study(title="RSI + MA", shorttitle="RSI + MA", resolution="") lengthRSI = input(14, minval=1, title="RSI Length") sourceRSI = input(close, "RSI Source", type = input.source) showMA = input(true, title="Show MA") lengthMA = input(9, minval=1, title="MA Length") offsetMA = input(title="MA Offset", type=input.integer, defval=0, minval=-500, maxval=500) up = rma(max(change(sourceRSI), 0), lengthRSI) down = rma(-min(change(sourceRSI), 0), lengthRSI) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down)) ma = sma(rsi, lengthMA) plot(showMA ? ma : na, "MA", color=color.blue, linewidth=2, style=0, offset=offsetMA) plot(rsi, "RSI", color=#9915FF, linewidth=1, style=0) band1 = hline(70, "Upper Band", color=#C0C0C0, linestyle=2, linewidth=1) band0 = hline(30, "Lower Band", color=#C0C0C0, linestyle=2, linewidth=1) fill(band1, band0, color=color.new(#9915FF,95), title="Background")