How to use different string literals in PINE plot on trading view?

北城余情 提交于 2019-12-10 20:46:56

问题


I have plot defined like this:

plotshape(xvalue, location=location.absolute, style=shape.labeldown, color=red, size=size.tiny, text ="Upper")

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.

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?

Thank you.


回答1:


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.



来源:https://stackoverflow.com/questions/52706791/how-to-use-different-string-literals-in-pine-plot-on-trading-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!