OPEN-SOURCE SCRIPT

Divergence Finder

129
//version=5
indicator("Divergence Finder", overlay=true)

// Parameter
length = input(14, title="RSI Length")
source = close
rsi = ta.rsi(source, length)

// Mencari Titik High dan Low
ph = ta.pivothigh(high, 5, 5)
pl = ta.pivotlow(low, 5, 5)
rsi_ph = ta.pivothigh(rsi, 5, 5)
rsi_pl = ta.pivotlow(rsi, 5, 5)

// Bearish Divergence
bearishDivergence = na(ph[5]) == false and na(rsi_ph[5]) == false and ph[5] > ph and rsi_ph[5] < rsi_ph

// Bullish Divergence
bullishDivergence = na(pl[5]) == false and na(rsi_pl[5]) == false and pl[5] < pl and rsi_pl[5] > rsi_pl

// Plot Divergence
plotshape(bearishDivergence, location=location.abovebar, color=color.red, style=shape.labeldown, title="Bearish Divergence")
plotshape(bullishDivergence, location=location.belowbar, color=color.green, style=shape.labelup, title="Bullish Divergence")

// Menampilkan RSI pada Subwindow
hline(70, "Overbought", color=color.red)
hline(30, "Oversold", color=color.green)
plot(rsi, title="RSI", color=color.blue)

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.