【问题标题】:Can't seem to trigger the RSI alerts that I have set ? Yet everthing seems to be working with Pinescript似乎无法触发我设置的 RSI 警报?然而一切似乎都在使用 Pinescript
【发布时间】:2021-10-26 16:29:58
【问题描述】:

我正在使用 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")

任何帮助都会很棒,谢谢!

保罗

【问题讨论】:

    标签: pine-script alerts


    【解决方案1】:

    您还需要从警报管理器创建警报。您可以通过单击顶部或右侧工具栏上的警报按钮,或者简单地按 ALT + A 来完成。

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

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

    这应该可以解决它。

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

    【讨论】:

    • 感谢您的回复。我就是这么做的!我在警报管理器中创建了警报,它根本没有触发。代码中是否有遗漏或处理不当?
    • 编辑了我的答案,它应该修复它。
    • 太棒了,我正在尝试,现在只是等待它在 ES mini 上触发。当穿过超买线时,这段代码是否一定会触发警报?还是当它第一次越线时会触发?非常感谢!
    • 其实没查,可以改一下,用 bgcolor(barssince(rsiValue > overbought) == 1 ? color.green : na) 查
    • 是的,我试过了,它没有点亮任何东西?诡异的。但这是一个指标,而不是覆盖的整个脚本。也许这就是为什么?
    猜你喜欢
    • 1970-01-01
    • 2014-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-11
    • 2012-03-11
    • 1970-01-01
    相关资源
    最近更新 更多