如何在Pine脚本中用字符串编写变量?

Lab*_*ces 2 forex pine-script

我尝试用变量编写文本,但不能

aaaa = 121.150
bbbb = 120.100
target = "TP = " + ( aaaa * 0.9 ) + "\n SL = " + bbbb*1.01
plotshape(data , style=shape.triangledown,location=location.abovebar, color=red, text=target)
Run Code Online (Sandbox Code Playgroud)

我希望输出看起来像这样:

Pin*_*ucF 6

要将系列(动态)文本放在图表上,您需要使用 Pine v4 和label.new(). 您只会看到最后创建的约 50 个标签:

//@version=4
study("", "", true)
aaaa = 121.150
bbbb = 120.100
target = "TP = " + tostring(aaaa * 0.9) + "\n SL = " + tostring(bbbb*1.01)
cond = rising(close, 1)[1] and falling(close, 1)
if cond
    label.new(bar_index, high, target, yloc = yloc.abovebar, color = color.red, style = label.style_triangledown)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述