似乎无法触发我设置的 RSI 警报?然而一切似乎都在使用 Pinescript

Can't seem to trigger the RSI alerts that I have set ? Yet everthing seems to be working with Pinescript

我正在使用 tradingview RSI 指标的原始源代码,我正在尝试对其进行调整,以便在 RSI 信号脱离超买或超卖时向我发送警报。我觉得我快到了,但我错过了一些让我调整警报的东西?老实说,我不知道我错过了什么,我需要一些帮助来度过这一重要时刻。

//@version=4
study(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2, resolution="")

//Get Values
len = input(10, minval=1, title="Length")
src = input(close, "Source", type = input.source)
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
overbought = input(title="OB",defval=70)
oversold = input(title="OS",defval=30)

//RSI Value
rsiValue = rsi(src, len)
rsiOverbought = barstate.isconfirmed and crossunder(rsiValue, overbought)
rsiOversold = barstate.isconfirmed and crossover(rsiValue, oversold)

//Alerts
alertcondition(rsiOverbought, title = "Overbought", message = "{{close}}")
alertcondition(rsiOversold, title = "Oversold", message = "{{close}}")
    
// Plotted Values    
plot(rsi, "RSI", color=#7E57C2)
band1 = hline(70, "Upper Band", color=#787B86)
bandm = hline(50, "Middle Band", color=color.new(#787B86, 50))
band0 = hline(30, "Lower Band", color=#787B86)
fill(band1, band0, color=color.rgb(126, 87, 194, 90), title="Background")

任何帮助都会非常棒,谢谢!

保罗

您还需要从提醒管理器创建提醒。您可以通过单击顶部或右侧工具栏上的警报按钮,或简单地按 ALT + A 来执行此操作。

https://www.tradingview.com/support/solutions/43000595315-how-to-set-up-alerts/

单击此 link 阅读有关如何设置它们的更多信息。

这应该可以解决问题。

rsiOverbought = barssince(rsiValue > overbought) == 1
rsiOversold = barssince(rsiValue < oversold) == 1

编辑 2:

//@version=4
study(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2, resolution="")

//Get Values
len = input(10, minval=1, title="Length")
src = input(close, "Source", type = input.source)
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
overbought = input(title="OB",defval=70)
oversold = input(title="OS",defval=30)

//RSI Value
rsiValue = rsi(src, len)
rsiOverbought = barssince(rsiValue > overbought) == 1
rsiOversold = barssince(rsiValue < oversold) == 1

bgcolor(rsiOverbought ? color.green : na)
bgcolor(rsiOversold ? color.blue : na)

//Alerts
alertcondition(rsiOverbought, title = "Overbought", message = "{{close}}")
alertcondition(rsiOversold, title = "Oversold", message = "{{close}}")
    
// Plotted Values    
plot(rsi, "RSI", color=#7E57C2)
band1 = hline(70, "Upper Band", color=#787B86)
bandm = hline(50, "Middle Band", color=color.new(#787B86, 50))
band0 = hline(30, "Lower Band", color=#787B86)
fill(band1, band0, color=color.rgb(126, 87, 194, 90), title="Background")