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

//@version=5
indicator("RSI Trend Detector PSAR Based")
rsilen=input.int(14,"RSI Length")
src=input.source(close,"Source")
rsi=ta.rsi(src,rsilen)

u=hline(60,display=display.none)
d=hline(40,display=display.none)
f=hline(50)
fill(u,d,color=color.rgb(80, 81, 83, 60))
sar=ta.sar(0.02,0.02,0.2)
//plot(sar, color=rsi>60?color.green:rsi<40?color.red:color.gray,linewidth=3)
r=plot(rsi, color=close>sar?color.rgb(0, 209, 7):color.rgb(252, 5, 5),linewidth=3)
rsim=ta.sma(rsi,14)
s=plot(rsim,color=color.yellow,linewidth=2)
fill(r,s,color=rsi>rsim?color.rgb(3, 243, 11, 81):color.rgb(243, 7, 7, 70))
up=ta.crossover(rsi,rsim)
dn=ta.crossunder(rsi,rsim)
alertcondition(up,title="RSI Cross Up",message="RSI Cross Up")
alertcondition(dn,title="RSI Cross Dn",message="RSI Cross Down")