如何在Pine Script中用字符串写变量?

问题描述 投票:0回答:1

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

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)

我希望输出的结果是这样的。

charts pine-script trading forex
1个回答
0
投票

要把 系列 (动态)文本在图表上,你将需要使用Pine v4和Pine v3。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)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.