2

this is code that works:

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

this is code that doesn't work:

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

Variable "label" here is true/false variable. It compiles without errors, but it just doesn't plot.

But it you use same logic on color, for example:

color=(label?blue:red)

It works without problems.

Did I made mistake in typing or logic anywhere or this is another one of pine bugs?

PineCoders-LucF
  • 8,288
  • 2
  • 12
  • 21
Mikeyy
  • 285
  • 1
  • 7
  • 4
    This has the same answer as your previous question. Pine-script just doesn't support that. https://stackoverflow.com/questions/52706791/how-to-use-different-string-literals-in-pine-plot-on-trading-view/52713798#52713798 – vitruvius Oct 09 '18 at 12:47
  • 1
    It's not same. In last question it was about string literals which is basicaly custom text. Here is about using build in functions, which work in example of "color" tag, but not in "style" tag. Was hoping I missed something and this can work in some fasion. :) – Mikeyy Oct 09 '18 at 12:56
  • 2
    Well the answer is pine-script doesn't support that :) After one point I stopped asking the developer team these questions. But you can create a support ticket and ask. I guess they are the only ones who can really answer why this is happening. However, I never got a real explanation on that. They just said there was no such feature or pine script didn't support that. – vitruvius Oct 09 '18 at 13:05
  • Not to start a discussion, but PS in TV was probably never *really* meant to become a proper scripting language for trading. But the exponential popularity of TV in recent years have put it in the stage light. Unfortunately, I think the limited skills of the TV developers simply do not dare to make any changes that could potentially corrupt or interrupt their entire multi-million $ business. – not2qubit Oct 11 '18 at 13:29

1 Answers1

3

It would be possible in the upcoming release of Pine Script v4. I work at Tradingview as QA engineer, and the support of this logic is now in the testing phase. We are planning to have a Beta release of v4 in the February, and after that users would be able to use ternary operators for the style arguments.

Just wanted to give an update.

UPD!
TV has released Pine v4, and now you an do this:

//@version=4 
study("STUDY", overlay = true) 
a = input(false) 
plotshape(close, location = location.abovebar, style = a ? shape.xcross : shape.circle, color = color.red, size = size.tiny, text = "Wow!")
  • How do you know? Are you the developer? Is there a bug report or changeset that you could link to here? What, specifically, is the fix? Please [edit] your answer to expand and provide more information. – Cody Gray - on strike Feb 06 '19 at 19:37