Double RSI & SMA
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Evgenyc111
// Double RSI for trend detection
//@version=5
indicator("Double RSI & SMA", "Double RSI&SMA", false)

period1 = input(25, "First RSI lenght")
period2 = input(100, "Second RSI lenght")
period3 = input(150, "First RSI SMA lenght")
th = input(1.5, "Signal treshold")
day = input(true, "Day theme?")
showLabels = input(true, "Show buy/sell labels?")
data = input(close, "Данные")
h1 = hline(70)
h2 = hline(30)
labelcolor = color.gray
buy = ta.crossover(ta.rsi(data, period1), math.min(ta.rsi(data, period2),ta.sma(ta.rsi(data, period1),period3))+th)
strongbuy = ta.crossover(ta.rsi(data, period1), math.max(ta.rsi(data, period2),ta.sma(ta.rsi(data, period1),period3))+th)
sell = ta.crossunder(ta.rsi(data, period1), math.max(ta.rsi(data, period2),ta.sma(ta.rsi(data, period1),period3))-th)
strongsell = ta.crossunder(ta.rsi(data, period1), math.min(ta.rsi(data, period2),ta.sma(ta.rsi(data, period1),period3))-th)
plot(ta.rsi(data, period1), title="RSI1", color = (day?color.orange:color.red), linewidth=2)
plot(ta.rsi(data, period2), title="RSI2", color = (day?color.navy:color.yellow), linewidth=2)
plot(ta.sma(ta.rsi(data, period1),period3), title="SMA1", color = color.blue, linewidth=2)
graph = ta.rsi(data, period1)
plotshape((buy or strongbuy) and showLabels ? graph-5 : na, title="StrongBuy/Buy Label", text="B", location=location.absolute, style=shape.labelup, size=size.tiny, color=strongbuy?color.green:labelcolor, textcolor=color.white)
plotshape((sell or strongsell) and showLabels ? graph+5 : na, title="StrongSell/Sell Label", text="S", location=location.absolute, style=shape.labeldown, size=size.tiny, color=strongsell?color.red:labelcolor, textcolor=color.white)
fill(h1,h2, color = color.new(color.purple, 90))
alertcondition(buy or strongbuy, title="Alert: RSI Buy", message="Double RSI Buy!")
alertcondition(sell or strongsell, title="Alert: RSI Sell", message="Double RSI Sell!")
alertcondition(buy or sell or strongbuy or strongsell, title="Alert: RSI Signal", message="Double RSI Signal!")
