首页 > 解决方案 > 将 3commas 信号放入 pine-script 中的 alert()

问题描述

我正在使用这个策略:

如果(不是 na(vrsi))

if (ta.crossover(vrsi, overSold) and ta.crossover(source, lower))
    strategy.entry("RSI_BB_L", strategy.long, comment="RSI_BB_L")
    alert("BUY alert", alert.freq_once_per_bar)       
    
else
    if (ta.crossunder(vrsi, overBought) and ta.crossunder(source, upper))
        strategy.close(id = "RSI_BB_L", comment="close")
        alert("SELL alert", alert.freq_once_per_bar)

我需要将此字符串放入购买警报消息中:

{“message_type”:“bot”,“bot_id”:6517352,“email_token”:“d106a1fc-6b41-410c-9532-38253f7273c5”,“delay_seconds”:0}

当我尝试这个时:

alert("{"message_type": "bot", "bot_id": 6517352, "email_token": "d106a1fc-6b41-410c-9532-38253f7273c5","delay_seconds": 0}", alert.freq_once_per_bar)

我得到:不匹配的输入'message_type'期待')'

任何建议都会很棒:)

标签: pine-script

解决方案


使用 '' 转义 ""。

alert('{ "message_type": "bot", "bot_id": 6517352, "email_token": "d106a1fc-6b41-410c-9532-38253f7273c5", "delay_seconds": 0 }')

推荐阅读