//@version=5 //Betatrader.ir indicator(title="Betatrader RSI Histogram", shorttitle="Betatrader RSI Histogram", format=format.price, precision=2, timeframe="", timeframe_gaps=true) ma(source, length, type) => switch type "SMA" => ta.sma(source, length) "Bollinger Bands" => ta.sma(source, length) "EMA" => ta.ema(source, length) "SMMA (RMA)" => ta.rma(source, length) "WMA" => ta.wma(source, length) "VWMA" => ta.vwma(source, length) rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings") rsiSourceInput = input.source(close, "Source", group="RSI Settings") maTypeInput = input.string("SMA", title="MA Type", options=["SMA", "Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings") maLengthInput = input.int(14, title="MA Length", group="MA Settings") bbMultInput = input.float(2.0, minval=0.001, maxval=50, title="BB StdDev", group="MA Settings") up = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput) down = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput) rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))- 50 c = rsi > 0 ? #12b004 : rsi < 0 ? #ff0000 : color.white rsiMA = ma(rsi, maLengthInput, maTypeInput) isBB = maTypeInput == "Bollinger Bands" // plot(rsi, "RSI", color=c,style=plot.style_columns) plot(rsiMA, "RSI-based MA", color=color.yellow) rsiUpperBand = hline(20, "RSI Upper Band", color=#787B86) hline(0, "RSI Middle Band", color=color.new(#787B86, 100)) rsiLowerBand = hline(-20, "RSI Lower Band", color=#787B86) fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill") bbUpperBand = plot(isBB ? rsiMA + ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Upper Bollinger Band", color=color.green) bbLowerBand = plot(isBB ? rsiMA - ta.stdev(rsi, maLengthInput) * bbMultInput : na, title = "Lower Bollinger Band", color=color.green) fill(bbUpperBand, bbLowerBand, color= isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill") //Betatrader.ir