Triple RSI Indicator with Toggle
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Rginah1974

//@version=4
study("Triple RSI Indicator with Toggle", shorttitle="TRSI-T", overlay=false)

// Input parameters
rsi1Length = input(5, title="RSI1 Length", minval=1, group="short RSI")
rsi2Length = input(14, title="RSI2 Length", minval=1, group="main RSI")
rsi3Length = input(28, title="RSI3 Length", minval=1, group="long RSI")
overbought1 = input(80, title="RSI1 Overbought Level", group="short RSI")
overbought2 = input(70, title="RSI2 Overbought Level", group="main RSI")
overbought3 = input(70, title="RSI3 Overbought Level", group="long RSI")
oversold1 = input(20, title="RSI1 Oversold Level", group="short RSI")
oversold2 = input(30, title="RSI2 Oversold Level", group="main RSI")
oversold3 = input(30, title="RSI3 Oversold Level", group="long RSI")
use_rsi1 = input(true, title="Use RSI1 for OB/OS signals")
use_rsi2 = input(true, title="Use RSI2 for OB/OS signals")
use_rsi3 = input(true, title="Use RSI3 for OB/OS signals")

// Calculate RSI values
rsi1 = rsi(close, rsi1Length)
rsi2 = rsi(close, rsi2Length)
rsi3 = rsi(close, rsi3Length)

// Plot RSI values
plot(rsi1, title="RSI1", color=color.aqua, linewidth=1)
plot(rsi2, title="RSI2", color=color.white, linewidth=1)
plot(rsi3, title="RSI3", color=color.fuchsia, linewidth=1)


// Calculate bar color based on the enabled RSI values
overboughtCondition = ((use_rsi1 ? rsi1 > overbought1 : true) and (use_rsi2 ? rsi2 > overbought2 : true) and (use_rsi3 ? rsi3 > overbought3 : true))
oversoldCondition = ((use_rsi1 ? rsi1 < oversold1 : true) and (use_rsi2 ? rsi2 < oversold2 : true) and (use_rsi3 ? rsi3 < oversold3 : true))
barColor = overboughtCondition ? color.fuchsia : oversoldCondition ? color.aqua : na


// Plot continuous horizontal bar
bgcolor(barColor, transp=70)

/////////
// RSI
col_black = color.new(color.black, 100)

//Input
src = input(close, title="Source")
rsi_fast_len = input(5, minval=1, title="Fast RSI Length")
rsi_ema_len = input(14, minval=1, title="EMA Length")

//rsi2 = rsi(src, rsi2Length)
rsi_fast = rsi(src, rsi_fast_len)
rsi_ema = ema(rsi2, rsi_ema_len)

//View
color_short = #ff00ea
color_long = #00eeff
color_neutral = #dbd4b3

p_rsi_fast = plot(rsi_fast, title = "Fast RSI", style=plot.style_line, linewidth=1, transp=100, color=color_neutral)
p_rsi_ema = plot(rsi_ema, title = "RSI EMA", style=plot.style_line, linewidth=1, transp=20, color=color.orange)
fill (p_rsi_ema, p_rsi_fast, color = rsi_fast > rsi_ema ? color_long : color_short, transp=75, title = "RSI Cloud Fill")

 
//Grid
Ex_os =  hline(100, linestyle=plot.style_line, linewidth=1, color=color.fuchsia)
Ex_ob = hline(0, linestyle=plot.style_line, linewidth=1, color=color.aqua)

blue = color.new(#00f2ff, transp=80)
fuchsia = color.new(#e100ff,transp=80)
white = color.new(#FFFFFF,transp=95)


Grid_10 = hline(10, linestyle=plot.style_line, linewidth=2, color=blue)
Grid_20 = hline(20, linestyle=plot.style_line, linewidth=1, color=blue)
Grid_40 = hline(40, linestyle=plot.style_line, linewidth=1, color=white)
Grid_50 = hline(50, linestyle=plot.style_line, linewidth=1, color=white) 
Grid_60 = hline(60, linestyle=plot.style_line, linewidth=1, color=white) 
Grid_80 = hline(80, linestyle=plot.style_line, linewidth=1, color=fuchsia)
Grid_90 = hline(90, linestyle=plot.style_line, linewidth=2, color=fuchsia) 
/////