Pine script Pinescript警报变量

Pine script Pinescript警报变量,pine-script,Pine Script,我正在寻找一种在webhook消息中发送用户标识的方法。用户应该能够输入他们的ID,并在触发webhook警报时将其发送到消息中。到目前为止,我还不能在消息中使用自定义变量,这似乎是不受支持的 myID = input(title="myID", type=input.string, defval="1000") //=============================== // Alert to trigger Buy //===========

我正在寻找一种在webhook消息中发送用户标识的方法。用户应该能够输入他们的ID,并在触发webhook警报时将其发送到消息中。到目前为止,我还不能在消息中使用自定义变量,这似乎是不受支持的

myID = input(title="myID", type=input.string, defval="1000")

//===============================
// Alert to trigger Buy
//===============================
alertcondition([YourAlertCondition], title = "Buy", message = "{\"side\": \"Buy\", \"symbol\": \"ASSETNAME\", \"type\": \"Market\", \"amount\": \"20\", \"takeProfit\": \"1\", \"stopLoss\": \"1\", \"trailingStop\": \"None\", \"new_trailing_active\": \"None\", \"Leverage\": \"1\", \"TelegramID\":"+{{myID}}}+"")
预期产出:

{"side": "Sell", "symbol": "ASSETNAME", "type": "Market", "amount": "20", "takeProfit": "1", "stopLoss": "1", "trailingStop": "None", "new_trailing_active": "None", "Leverage": "1", "myID": "1000" }

上面的方法是我尝试过的一些变化。如果无法使用变量,是否有办法在消息中输出用户的TradingView用户名?如果可能,TradingView用户名可以用作接收服务器上的ID。

您可以使用
警报
功能,而不是
警报条件
,在您的情况下,您可以使用:

msg = '{' + str.format('\"side\": \"Buy\", \"symbol\": \"ASSETNAME\", \"type\": \"Market\", \"amount\": \"20\", \"takeProfit\": \"1\", \"stopLoss\": \"1\", \"trailingStop\": \"None\", \"new_trailing_active\": \"None\", \"Leverage\": \"1\", \"TelegramID\":"{0}"',myID) + '}'

if YourAlertCondition
    alert(msg,alert.freq_once_per_bar_close)
请看电视上的裁判