BitCoin RSI Trend
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © marvixino

//@version=5
indicator("BitCoin RSI Trend", "BTC RSI", true)

string BTC_TREND = 'Config » BTC RSI Trend'

btcTF = input.timeframe("240", "BTC Timeframe", group=BTC_TREND,tooltip="Time in minutes.")
btcRsiLen = input.int(14, "BTC Length", step=1, minval=1, group=BTC_TREND)
btcTopRsi = input.int(70, "BTC Max Level", step=1, minval=3, group=BTC_TREND)
btcMinRsi = input.int(50, "BTC Min Level", step=1, minval=3, group=BTC_TREND)
enbaleBG = input.bool(true, "Color Background")
enbaleBarPlot = input.bool(true, "Show BTC RSI")
labelColor = input.color(color.white, "Label BG")
labelTextColor = input.color(color.black, "Label Text")

getRsi(sym, tf, src) =>
    request.security(sym, tf, src[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1]
    
btcRsi = getRsi("BINANCE:BTCUSD", btcTF, ta.rsi(close, btcRsiLen))
plot(btcRsi, "RSI", color=color.new(color.blue, 100))

rsiColor = btcRsi > btcMinRsi and btcRsi < btcTopRsi ? color.new(color.green,80) : color.new(color.red,80)
bgcolor(enbaleBG ? rsiColor : na)
if barstate.islast and barstate.isnew and enbaleBarPlot
    label.new(bar_index, high, str.tostring(math.round(btcRsi,1)), color =labelColor, textcolor =labelTextColor)



