RicardoSantos

[RS]RSI Divergence V4

EXPERIMENTAL: experimental setup, hard coded rsi lengths, hardcoded level limits, testing new aproach to the reflections, added extra rsi's
main rsi's length 13/55, smooth option will affect all rsi's

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
study(title="RSI Divergence V4", shorttitle="RSID.V4", overlay=false)
buylimit1 = 10
buylimit2 = 20
buylimit3 = 30
buylimit4 = 40
selllimit1 = 90
selllimit2 = 80
selllimit3 = 70
selllimit4 = 60
smooth = input(4)
src = sma(input(type=source, defval=close), smooth)

rsi1 = rsi(src, 5)
rsi2 = rsi(src, 8)
rsi3 = rsi(src, 13)
rsi4 = rsi(src, 21)
rsi5 = rsi(src, 34)
rsi6 = rsi(src, 55)

rcolor1 = rsi1 >= rsi2 ? silver : gray
rcolor2 = rsi2 >= rsi3 ? silver : gray
rcolor3 = rsi3 >= rsi4 ? silver : gray
rcolor4 = rsi4 >= rsi5 ? silver : gray
rcolor5 = rsi5 >= rsi6 ? silver : gray
plot(rsi1, color=rcolor1)
plot(rsi2, color=rcolor2)
plot(rsi3, color=black)
plot(rsi4, color=rcolor4)
plot(rsi5, color=rcolor5)
plot(rsi6, color=black, linewidth=2)
//  ||-------------------------------------------------------------------------------------
dif1 = rsi6-rsi1
dif2 = rsi5-rsi2
dif3 = rsi4-rsi3

topdiv1 = dif1 < 0 ? selllimit4 - dif1 : selllimit4
topdiv2 = dif2 < 0 ? selllimit3 - dif2 : selllimit3
topdiv3 = dif3 < 0 ? selllimit2 - dif3 : selllimit2
botdiv1 = dif1 > 0 ? buylimit4 - dif1 : buylimit4
botdiv2 = dif2 > 0 ? buylimit3 - dif2 : buylimit3
botdiv3 = dif3 > 0 ? buylimit2 - dif3 : buylimit2

plot(topdiv1, style=area, color=teal, transp=80, histbase=selllimit4)
plot(topdiv2, style=area, color=teal, transp=80, histbase=selllimit3)
plot(topdiv3, style=area, color=teal, transp=80, histbase=selllimit2)
plot(botdiv1, style=area, color=teal, transp=80, histbase=buylimit4)
plot(botdiv2, style=area, color=teal, transp=80, histbase=buylimit3)
plot(botdiv3, style=area, color=teal, transp=80, histbase=buylimit2)
//----------------------------------------------------------
hidelimits = input(true)
hline(0, color=black)
plot(hidelimits ? na : buylimit1, color=green)
plot(hidelimits ? na : buylimit2, color=lime)
plot(hidelimits ? na : buylimit3, color=olive)
plot(hidelimits ? na : buylimit4, color=teal)
hline(50, color=black)
plot(hidelimits ? na : selllimit1, color=maroon)
plot(hidelimits ? na : selllimit2, color=red)
plot(hidelimits ? na : selllimit3, color=orange)
plot(hidelimits ? na : selllimit4, color=teal)
hline(100, color=black)