问题
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?
回答1:
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!")
来源:https://stackoverflow.com/questions/52720653/why-is-true-false-logic-on-style-not-working