OPEN-SOURCE SCRIPT

POB RSI Bullish Divergence

//version=5
indicator("RSI Bullish Divergence", overlay=true)

// RSI Settings
rsiLength = input(14, title="RSI Length")
rsiSource = input(close, title="RSI Source")
rsiLevel = input(30, title="RSI Bullish Threshold")

// Calculate RSI
rsiValue = ta.rsi(rsiSource, rsiLength)

// Detecting Bullish Divergence
// We check if the price is making a lower low but the RSI is making a higher low

// Price lows
priceLow = ta.lowest(low, 10)

// RSI lows
rsiLow = ta.lowest(rsiValue, 10)

// Check for Bullish Divergence (price low < previous low, RSI low > previous low)
bullDiv = (priceLow < priceLow[1]) and (rsiLow > rsiLow[1])

// Plot the Bullish Divergence signal on the chart
plotshape(bullDiv, title="Bullish Divergence", location=location.belowbar, color=color.green, style=shape.labelup, text="BULL")

// Optional: Plot the RSI line for reference
plot(rsiValue, title="RSI", color=color.blue, linewidth=1, offset=-1)
hline(30, title="RSI Threshold", color=color.red, linestyle=hline.style_dotted)

כתב ויתור