问题
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