如何将条件设置为 %0.30 (Tradingview Pinescript)

发布于 2025-01-10 08:06:42 字数 2661 浏览 0 评论 0原文

我想在背离 %0.30 时获得信号。我收到不值得进入的信号,例如 RSI 40 - 价格 0.20,RSI 39 - 价格 0.2001 是的,这也是背离,但就像我说的不值得进入。我至少想要0.2006 剥头皮 (%0.30) 这个可以调整吗?

//@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")

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")

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文