RSI BGCOLOR indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Maboko
//@version=5

indicator("RSI BGCOLOR indicator", overlay=true)

//User Inputs
rsilen = input.int(title="RSI Lenght", defval=14)
rsiob  = input.int(title="RSI Bullish",defval=51)
rsios  = input.int(title="RSI Bearish",defval=49)

//Get RSI value
rsi = ta.rsi(close, rsilen)

//RSI Conditions 
rsilong  = rsi > rsiob 
rsishort = rsi < rsios 
rsi50    = rsi <= rsiob and rsi >= rsios

//Plot RSI background direction
bgcolor(rsilong? color.new(color.green,85) : na)
bgcolor(rsishort? color.new(color.red,85) : na)
bgcolor(rsi50? color.new(color.black,85) : na)