0

当他们宣布“我们的新警报允许动态消息”时,我在 tradingview.com 上找到了这个脚本。该脚本应该在 RSI 超买或超卖时触发警报。问题是它没有按预期工作。警报由您添加的交易品种的 RSI 触发。它似乎是在脚本底部的符号列表中随机选择符号。脚本的 RSI 数据也不正确,因为它发送的是您最初添加研究的品种的 RSI,而不是品种列表的 RSI。

这是显示错误示例的警告文本:

“纳斯达克:AMD,1:RSI (50.5282994084) 跨越 70 级”带有多个符号的警报():任何(警报)函数调用 Active NASDAQ:AMD,1m”这没有意义,因为 AMD 的 RSI 没有跨越在触发警报时超过 70,它显示 RSI 为 50,但在警报时它甚至不是 50,它低于 30。

我尝试将“_r = rsi (close, 7)”移动到“[_co, _cu]...”行下,但没有成功。我还尝试将数据转换为字符串以查看是否有任何作用,但它不起作用。我尝试转换为 Pine Script v5。还尝试了不同的符号和加密货币。有谁知道这种同时将指标/研究应用于多个符号的功能是否真的有效?或者,也许我错过了一些东西,并且由于我做错了什么而无法正常工作。

截图: 在此处输入图片描述

TradingView 的警报日志: |警报 ID|代码|名称|描述|时间| |--- |--- |--- |--- |--- | |358732201|"NASDAQ:TSLA, 1m"|alert() with multiple symbols: 任何 alert() 函数调用,"|=""session"":""extended"",""symbol"":""NASDAQ: TSLA""}, 1: RSI (72.6465706327) 突破 70 水平"|2021-12-23T14:49:00.000Z| |358732201,|"NASDAQ:TSLA, 1m",|alert() with multiple symbols: Any alert() 函数调用,|"NASDAQ:CFVI, 1: RSI (72.6465706327) 下穿 30 水平",|2021-12- 23T14:49:00.000Z| |358732201,|"NASDAQ:TSLA, 1m",|alert() with multiple symbols: Any alert() 函数调用,|"NASDAQ:TSLA, 1: RSI (72.6465706327) 突破 70 水平",|2021-12- 23T14:49:00.000Z| |358732201|"NASDAQ:TSLA, 1m",|alert() 带有多个符号:任何 alert() 函数调用,|"BINANCE:SOLUSDT, 1: RSI (72.6465706327) 下穿 30 水平",|2021-12-23T14:49:00.000Z| |358732201,|"NASDAQ:TSLA, 1m",|alert() with multiple symbols: Any alert() 函数调用,|"COINBASE:BTCUSD, 1: RSI (69.6339491527) 下穿 30 水平",|2021-12- 23T14:48:00.000Z| |358732201,|"NASDAQ:TSLA, 1m",|alert() 有多个符号:任何 alert() 函数调用,|"NYSE:PLTR, 1: RSI (69.6339491527) 突破 70 水平",|2021-12- 23T14:48:00.000Z| |358732201,|"NASDAQ:TSLA, 1m",|alert() with multiple symbols: Any alert() 函数调用,|"COINBASE:BTCUSD, 1: RSI (46.7458265403) 下穿 30 水平",|2021-12- 23T14:47:00.000Z| |358732201,|"NASDAQ:TSLA, 1m",|alert() 有多个符号:任何 alert() 函数调用,|"FTX:RAYUSD, 1: RSI (46.

我引用的脚本是: https ://www.tradingview.com/blog/en/our-new-alerts-allow-for-dynamic-messages-22588/

//@version=4
study("alert() with multiple symbols")
f_triggerRsi(_ticker)=>
    _r = rsi(close, 7)
    _x = crossover(_r,70)
    _y = crossunder(_r,30)
    [_co, _cu] = security(_ticker, timeframe.period, [_x, _y])
    _msg = _ticker + ", " + timeframe.period + ": "
    if _co
        _msg := _msg + "RSI (" + tostring(_r) + ") crossing up 70 level"
        alert(_msg,  alert.freq_once_per_bar_close)
    else if _cu
        _msg := _msg + "RSI (" + tostring(_r) + ")  crossing down 30 level"
        alert(_msg,  alert.freq_once_per_bar_close)

plot(rsi(close, 7), "RSI", color=#8E1599)
band1 = hline(70, "Upper Band", color=#C0C0C0)
band0 = hline(30, "Lower Band", color=#C0C0C0)
fill(band1, band0, color=#9915FF, transp=90, title="Background")

f_triggerRsi(syminfo.tickerid)
f_triggerRsi("NASDAQ:MSFT")
f_triggerRsi("FX:EURUSD")
f_triggerRsi("NASDAQ:TSLA")
f_triggerRsi("NASDAQ:PYPL")
4

1 回答 1

0

万一其他人遇到同样的问题并且对 Pine Script 不够了解(还)无法自己修复它(例如我自己),我将发布解决方案。我收到了 TradingView 支持的回复。他们非常乐于助人,友善并提供了更新的脚本。他们说有错误的博客文章将很快更新。

以下是多个符号的更新 Pine 脚本:

//@version=4

study("alert() with multiple symbols") 

f_triggerRsi(_ticker)=>
    _r = rsi(close, 14) 
    _x = crossover(_r,70)
    _y = crossunder(_r,30)
    _rt = barstate.isrealtime    

    [_rsi, _co, _cu, _rt_bar] = security(_ticker, timeframe.period, [_r, _x, _y, _rt])    
    _msg = _ticker + ", " + timeframe.period + ": "    

    if _co and _rt_bar  
        _msg := _msg + "RSI (" + tostring(_rsi) + ") crossing up 70 level"
        alert(_msg,  alert.freq_once_per_bar_close)    

    else if _cu and _rt_bar
        _msg := _msg + "RSI (" + tostring(_rsi) + ")  crossing down 30 level"
        alert(_msg,  alert.freq_once_per_bar_close) 

plot(rsi(close, 14), "RSI", color=#8E1599) 
band1 = hline(70, "Upper Band", color=#C0C0C0) 
band0 = hline(30, "Lower Band", color=#C0C0C0) 
fill(band1, band0, color=color.new(#9915FF,90), title="Background") 

f_triggerRsi(syminfo.tickerid) 
f_triggerRsi("NASDAQ:MSFT") 
f_triggerRsi("FX:EURUSD") 
f_triggerRsi("NASDAQ:TSLA") 
f_triggerRsi("NASDAQ:PYPL")
于 2021-12-24T15:45:34.027 回答