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)

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.