4

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.

PineCoders-LucF
  • 8,288
  • 2
  • 12
  • 21
Mikeyy
  • 285
  • 1
  • 7

1 Answers1

3

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.

not2qubit
  • 14,531
  • 8
  • 95
  • 135
  • 1
    So only workaround is to polute code with more redudant code which will default to "na" when variable is false. :) Thank you. – Mikeyy Oct 09 '18 at 12:52