PineScript:基于输入的条形颜色
完整的新手寻求帮助。
目前,我使用简单的代码为条上色。
barclr = input(false, title='(Off) Color2 or (On) Color1')
barcolor(barclr ? barcolor2 : barcolor1)
我现在只想在另一个切换说“是”
时才为bar上色,
bar = input.string("Yes", title="Colored Bars", options=["Yes", "No"]) == "Yes"
所以我想发生的事情是当bar
下拉设置为“是” 然后颜色条,否则根本不着色。
另外,bar ==“是”
然后使用barclr
在两个选项之间切换。
(如果是一个切换或下拉列表,我不偏爱它,但仅仅是因为我尝试使用下拉菜单的差异化感。)
我不知道如何将其放在一起。请帮忙。
Complete newbie looking for help.
Currently I color my bars using a simple code.
barclr = input(false, title='(Off) Color2 or (On) Color1')
barcolor(barclr ? barcolor2 : barcolor1)
I now want to color bars only if another toggle says "Yes"
and so I created,
bar = input.string("Yes", title="Colored Bars", options=["Yes", "No"]) == "Yes"
So now what I want to happen is when the bar
dropdown is set to "Yes"
then color bars otherwise don't color bars at all.
Also while bar == "Yes"
then use barclr
to switch between two options.
(I don't have a preference if it's a toggle or dropdown but just for my limited sense of differentiation I tried using a dropdown.)
I don't know how to put this together. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您几乎已经完成了一个目标,为 bar 输入添加新的三元检查,并将现有的三元条件嵌套在
barcolor()
函数中:You have almost accomplished a goal, add a new ternary check for the bar input and nest the existing ternary condition inside
barcolor()
function: