我正在尝试通过Pinescript警报发送回自定义变量。
top = input(title="Top", type=input.float, defval=10000, minval=1)
bottom = input(title="Bottom", type=input.integer, defval=5000, minval=0)
failedmessage = " \"processing\":\"NONE\" "
basemessage = " \"processing\":\"COMPLETED\", \"top\":{{top}}, \"bottom\":{{bottom}} "
alertcondition( top > bottom, title="test", message=basemessage )
弹出警报条件时,“ top”和“ bottom”的值未填写。我也尝试过:
basemessage = " \"processing\":\"COMPLETED\", \"top\":{{\"Top\"}}, \"bottom\":{{\"Bottom\"}} "
但这也不起作用。
我在这里可以做什么?
谢谢!
答案 0 :(得分:0)
您不能在警报消息中使用动态文本。
如果使用其他数值来区分警报消息中的条件可以满足您的需要,请参阅该答案的第一个链接,以获取实现该技术的示例。
答案 1 :(得分:0)
现在,您可以通过strategy.entry发送动态警报消息。这是下面的示例代码。
buy_msg = "TYPE:LE "+" :SYMBOL: "+syminfo.ticker +" :PRICE: "+tostring(close)+" :QTY: "+tostring(quant)
sell_msg = "TYPE:Lx "+" :SYMBOL: "+syminfo.ticker +" :PRICE: "+tostring(close)+" :QTY: "+tostring(quant)
strategy.entry("Long", strategy.long, when = buy,comment="Buy",alert_message=buy_msg )
strategy.entry("Short", strategy.short, when = sell,comment="Sell",alert_message=sell_msg)