// © l_lonthoff
//@version=5
indicator(title="MACD on RSI", shorttitle="MACD on RSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
rsiLengthInput = input.int(15, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
maLengthInput = input.int(14, title="MA Length (slow)", group="MA Settings", display = display.status_line)
ma2LengthInput = input.int(20, title="MA Length (fast)", group="MA Settings", display = display.status_line)
rsi = ta.rsi(rsiSourceInput,rsiLengthInput)
rsiMA = ta.ema(ta.ema(rsi,maLengthInput), maLengthInput)
rsiMA2 = ta.ema(ta.ema(rsi,ma2LengthInput), ma2LengthInput)
MACDh = rsiMA - rsiMA2
MACDhcolor = (MACDh >= 0 ? (MACDh[1] < MACDh ? #26A69A : #B2DFDB) : (MACDh[1] < MACDh ? #FFCDD2 : #FF5252))
plot(MACDh, color = MACDhcolor, style = plot.style_columns, display = display.pane + display.price_scale)
plot(rsiMA-50, "RSI-based MA", color=color.rgb(255, 59, 150), display = display.pane + display.price_scale)
plot(rsiMA2-50, "RSI-based MA", color=color.rgb(59, 105, 255), display = display.pane + display.price_scale)
midline = hline(50, "RSI Middle Band", color=color.new(#787B86, 50))