SpreadEagle71

[RS]RSI Divergence V5

Thank You Richard Santos!!!

This is a great indicator guys.Its good for measuring divergence in an objective way.
The idea is to measure the high to high and the low to low (stock vs. indicator) with the low to high and high to low (stock vs. indicator). This is the basis of divergence.
I love this one.
I would also add you can draw angles on the indicator and the stocks. All in all a great indicator.

Richard Santos was nice enough to modify one of his scripts for this one. Credit goes to him.

You can also use this for measuring volatility when the lines narrow or widen.

Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. Du kan ange den som favorit för att använda den i ett diagram.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?
study(title='[RS]RSI Divergence V5')
length = input(5)

f_top_fractal(_src)=>_src[4] < _src[2] and _src[3] < _src[2] and _src[2] > _src[1] and _src[2] > _src[0]
f_bot_fractal(_src)=>_src[4] > _src[2] and _src[3] > _src[2] and _src[2] < _src[1] and _src[2] < _src[0]
f_fractalize(_src)=>f_top_fractal(_src) ? 1 : f_bot_fractal(_src) ? -1 : 0

rsi_high = rsi(high, length)
rsi_low = rsi(low, length)
fractal_top_rsi = f_fractalize(rsi_high) > 0 ? rsi_high[2] : na
fractal_bot_rsi = f_fractalize(rsi_low) < 0 ? rsi_low[2] : na

rsi_high_prev = valuewhen(fractal_top_rsi, rsi_high[2], 1) 
rsi_high_price = valuewhen(fractal_top_rsi, high[2], 1)
rsi_low_prev = valuewhen(fractal_bot_rsi, rsi_low[2], 1) 
rsi_low_price = valuewhen(fractal_bot_rsi, low[2], 1)

regular_bearish_div = fractal_top_rsi and high[2] > rsi_high_price and rsi_high[2] < rsi_high_prev
hidden_bearish_div = fractal_top_rsi and high[2] < rsi_high_price and rsi_high[2] > rsi_high_prev
regular_bullish_div = fractal_bot_rsi and low[2] < rsi_low_price and rsi_low[2] > rsi_low_prev
hidden_bullish_div = fractal_bot_rsi and low[2] > rsi_low_price and rsi_low[2] < rsi_low_prev

plot(title='RSI High', series=rsi_high, color=gray)
plot(title='RSI Low', series=rsi_low, color=gray)
plot(title='RSI H F', series=fractal_top_rsi, color=black, offset=-2)
plot(title='RSI L F', series=fractal_bot_rsi, color=black, offset=-2)
plot(title='RSI H D', series=fractal_top_rsi, style=circles, color=regular_bearish_div or hidden_bearish_div ? maroon : gray, linewidth=3, offset=-2)
plot(title='RSI L D', series=fractal_bot_rsi, style=circles, color=regular_bullish_div or hidden_bullish_div ? green : gray, linewidth=3, offset=-2)

plotshape(title='+RBD', series=regular_bearish_div ? rsi_high[2] : na, text='Regular', style=shape.labeldown, location=location.absolute, color=maroon, textcolor=white, offset=-2)
plotshape(title='+HBD', series=hidden_bearish_div ? rsi_high[2] : na, text='hidden', style=shape.labeldown, location=location.absolute, color=maroon, textcolor=white, offset=-2)
plotshape(title='-RBD', series=regular_bullish_div ? rsi_low[2] : na, text='Regular', style=shape.labelup, location=location.absolute, color=green, textcolor=white, offset=-2)
plotshape(title='-HBD', series=hidden_bullish_div ? rsi_low[2] : na, text='hidden', style=shape.labelup, location=location.absolute, color=green, textcolor=white, offset=-2)