RSI-ROC Momentum Alert
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jumpr

//@version=5
indicator("RSI-ROC Momentum Alert")

// ROC
length = input.int(21, minval=1, title="ROC Length")
roc = ta.roc(close,length)
rocMA = ta.sma(roc, length)

// RSI
rsiLength = input(14, title="RSI Length")
source = input(close, "Source")
rsi = ta.rsi(source, rsiLength)
rsiLow = input(30, title="RSI Oversold")
rsiLowExtended = input(25, title="RSI Extended Oversold")
rsiHigh = input(70, title="RSI Overbought")
rsiHighExtended = input(75, title="RSI Extended Overbought")

// Buy and Sell Signals
rsiBuy = rsi < rsiLow
rsiSell = rsi > rsiHigh

currentColor = roc > rocMA ? color.green : color.red
rocMAColor = rocMA >= 0 ? color.green : color.red
plot(roc, title="ROC line", color=currentColor, linewidth=1)
plot(rocMA,title="ROC MA line", color=rocMAColor, linewidth=1)

bgcolor(rsiBuy ? color.new(color.green, 90) : rsiSell ?color.new(color.red, 90) : na, title='RSI Background Color')
bgcolor(rsi < rsiLowExtended ? color.new(color.green, 90) : rsi > rsiHighExtended ?color.new(color.red, 90) : na, title='RSI Extended Background Color')

lineZero = hline(0, color=color.new(color.gray, 50),linestyle=hline.style_solid, linewidth=2)