Pinescript在警报消息中未显示有关我的地块的信息

问题描述

我正在使用占位符,也尝试过使用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的值和一些内置变量,例如占位符中的closevolume。在此处查看更多信息: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参数中。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...