Pinescript 未在警报消息中显示有关我的情节的信息

Pinescript not displaying info about my plot in alert message

我正在使用占位符并尝试使用 tostring 但它没有在警报消息中显示信息,我错过了什么?

它只是按原样显示..

entry_long_message = 'key = XXX
     pair=adausdt /n
     //stoplossPercentage=tostring(stopperclong) /n
     stoplosspercentage =  {{plotchar("stop_long")}} + "/n"
     exchange=binance /n
     type=entry /n
     leverage=tostring(leveragelong) /n
     exchangeAccountType=futures /n
     side=long /n
     positionSizePercentage=tostring(posperclong) /n
     orderType=market /n
     signalId = adalongfutures '

谢谢

Combining strings with TradingView's addition operator

您需要将每个带有 + 的变量连接到具有固定文本的字符串。
此外,马车 return 是 \n 而不是 /n.

例子

var int myValue = 20
var string myText = na
myText := "Fixed text " + tostring(myValue) + " more fixed text \n" + "this will be on another line " + tostring(myValue)

它不会像您预期的那样工作。

message alertcondition 函数的参数接受一个 常量字符串 plot 的值和一些 built-in变量,例如closevolume占位符中。在此处查看更多信息:https://www.tradingview.com/blog/en/introducing-variables-in-alerts-14880/

为了能够将动态字符串传递给消息参数,您必须绘制该值,然后 link 该绘制到占位符。如果您不想在图表上看到它,您可以使用 display 参数隐藏该图。

例如:

plot(someVariable, "someVariablePlotName", display = display.none)

alertcondition(someCondition, "alertName", message = 'constant string plus dynamic value from the plot function: {{plot("someVariablePlotName")}}, current price : {{close}}')

因此您必须为每个动态变量(stopperclong、leveragelong、posperclong 等)创建一个单独的图,并将该图包含在带有占位符的消息参数中。