问题描述
我正在使用占位符,也尝试过使用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
您需要将带有+
的每个变量连接到具有固定文本的字符串。
另外,回车符是\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
的值和一些内置变量,例如占位符中的close
,volume
。在此处查看更多信息:https://www.tradingview.com/blog/en/introducing-variables-in-alerts-14880/
要能够将动态字符串传递给message参数,您必须绘制该值,然后将该图形链接到占位符。如果您不希望在图表上看到该图,则可以使用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,杠杆long,posperclong等)创建一个单独的图,并将该图包含在带占位符的message参数中。