I want to get signals when divergence %0.30.I'm getting signals not worth to entering for example RSI 40 - price 0.20, RSI 39 - price 0.2001 yes this is divergence too but like I said not worth to enter.I want at least 0.2006 for scalping ( %0.30 ) is this adjustable ?
//@version=3
study(title="RSI Divergence", shorttitle="RSI Divergence")
len = 14
bearish_div_rsi = input(1, "Min Bearish RSI", integer, minval=50, maxval=100)
bullish_div_rsi = input(100, "Max Bullish RSI", integer, minval=0, maxval=50)
// RSI code
rsi = rsi(close, len)
plot(rsi, color=white, linewidth=1, transp=0)
// DIVS code
xbars = 14
hb = abs(highestbars(rsi, xbars)) // Finds bar with highest value in last X bars
lb = abs(lowestbars(rsi, xbars)) // Finds bar with lowest value in last X bars
// Defining variable values, mandatory in Pine 3
max = na
max_rsi = na
min = na
min_rsi = na
bearish_div = na
bullish_div = na
div_alert = na
// If bar with lowest / highest is current bar, use it's value
max := hb == 0 ? close : na(max[1]) ? close : max[1]
max_rsi := hb == 0 ? rsi : na(max_rsi[1]) ? rsi : max_rsi[1]
min := lb == 0 ? close : na(min[1]) ? close : min[1]
min_rsi := lb == 0 ? rsi : na(min_rsi[1]) ? rsi : min_rsi[1]
// Compare high of current bar being examined with previous bar's high
// If curr bar high is higher than the max bar high in the lookback window range
if close > max // we have a new high
max := close // change variable "max" to use current bar's high value
if rsi > max_rsi // we have a new high
max_rsi := rsi // change variable "max_rsi" to use current bar's RSI value
if close < min // we have a new low
min := close // change variable "min" to use current bar's low value
if rsi < min_rsi // we have a new low
min_rsi := rsi // change variable "min_rsi" to use current bar's RSI value
// Detects divergences between price and indicator with 1 candle delay so it filters out
repeating divergences
if (max[1] > max[2]) and (rsi[1] < max_rsi) and (rsi <= rsi[1]) and (rsi[1] >= bearish_div_rsi)
bearish_div := true
div_alert := true
if (min[1] < min[2]) and (rsi[1] > min_rsi) and (rsi >= rsi[1]) and (rsi[1] <= bullish_div_rsi)
bullish_div := true
div_alert := true
// Alerts
alertcondition(div_alert, title='RSI Divergence', message='RSI Divergence')
// Plots divergences with offest
plotshape((bearish_div ? rsi[1] + 3 : na), location=location.absolute, style=shape.triangledown,
color=#ff0000, size=size.tiny, transp=0, offset=-1)
plotshape((bullish_div ? rsi[1] - 3 : na), location=location.absolute, style=shape.triangleup,
color=#00ff01, size=size.tiny, transp=0, offset=-1)
hline(30, color=white, linestyle=solid, title = "30")
hline(70, color=white, linestyle=solid, title = "70")