在 Pine 4 Tradingview 的绘图线末尾添加标签

Add a label at the end of plot line in Pine 4 Tradingview

拜托,我有点迷茫,如果有熟练的程序员可以帮助我,我将不胜感激:

我正在将许多绘图线输出到一个新指标 window 中,我需要为它们命名。这个想法是在每条绘图线的末尾添加一个标签,显示每条绘图线代表的证券的名称(请参见所附示例)

知道 Pine4 是否可行吗?

请告诉我

非常感谢!

study("Label?")

Symbol1 = input(title="Sym 1", type=input.symbol, defval="eurusd")
Symbol1close = security(Symbol1, resolution="", expression=close)

Symbol2 = input(title="Sym 2", type=input.symbol, defval="euraud")
Symbol2close = security(Symbol2, resolution="", expression=close)


//the idea would be to add the labels at the end of every single 
 of these 2 plots. On the labels should appear "eurusd and euraud"
plot(Symbol1close)
plot(Symbol2close)```

[labels on plotlines][1]


  [1]: https://i.stack.imgur.com/gvPqS.jpg

你可以试试这样:

//@version=4
study("Label?")

Symbol1 = input(title="Sym 1", type=input.symbol, defval="eurusd")
Symbol1close = security(Symbol1, resolution="", expression=close)

Symbol2 = input(title="Sym 2", type=input.symbol, defval="euraud")
Symbol2close = security(Symbol2, resolution="", expression=close)

// define label variable persisted between bars, see more about var modifier
// also you can use different label styles as label.style_label_lower_left
var l1 = label.new(bar_index, Symbol1close, Symbol1, style=label.style_label_lower_left)
var l2 = label.new(bar_index, Symbol2close, Symbol2)

// set up new xy params to labels on new bar
label.set_xy(l1, bar_index, Symbol1close)
label.set_xy(l2, bar_index, Symbol2close)

plot(Symbol1close)
plot(Symbol2close)