如何在交易视图的 PINE 图中使用不同的字符串文字? [英] How to use different string literals in PINE plot on trading view?
问题描述
我有这样定义的情节:
plotshape(xvalue, location=location.absolute, style=shape.labeldown, color=red, size=size.tiny, text ="Upper")
这里的问题是部分 text="Upper".我想让用户缩短标签,以便它可以是上"或U".这通常可以通过这样的事情来完成:
Problem here is with part text="Upper". I wanted to allow user to shorten label so it can be "Upper" or "U". This usualy can be done with something like this:
text = label ? "U" : "Upper"
对于较短的字符串,标签"为真/假.
Where "label" is true/false for shorter strings.
问题是 PINE 不接受它,错误类似于您必须使用带有 'text='"的字符串文字.https://www.tradingview.com/wiki/Literals#String_Literals
Problem is PINE isn't accepting it and error is something like "You must use string literals with 'text='". https://www.tradingview.com/wiki/Literals#String_Literals
有没有办法让用户可以即时更改情节文本?
Is there a way around it so user can change plot text on fly?
谢谢.
推荐答案
问题在于 pine-script 不接受字符串变量作为绘图标签.所以答案是您不能从脚本更改标签.它必须是硬编码.唯一的解决方法是使用其中的另一个标签定义另一个完全不同的图.
The problem is that pine-script does not accept string variables as plot labels. So the answer is that you cannot change the label from a script. It has to be hard-coded. The only workaround is to define another completely different plot using the other label in it.
这篇关于如何在交易视图的 PINE 图中使用不同的字符串文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!