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.

オープンソーススクリプト

TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。

チャートでこのスクリプトを利用したいですか?
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)