Why is true / false logic on “style=” not working?

余生颓废 提交于 2021-02-10 12:34:45

问题


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

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