打开/关闭复合条件

发布于 2025-01-10 06:41:58 字数 559 浏览 0 评论 0原文

我可以将多个条件添加到一个信号中,但由于我缺乏编程经验,我无法弄清楚如何在选项中打开/关闭不同的条件。

IncludeC1 = input(true)

IncludeC2 = input(false)

条件 1 = 交叉

条件 2 = 船体方向

信号 = 交叉和船体方向

我需要实现此目的 Signal = crossover and (hull (if selected))

基本上这样我就可以在输入部分添加、删除单个条件。

BoxCrossover = ta.crossover(close, boxHigh)
BoxCrossunder = ta.crossunder(close, boxLow)

hull_green = hullma > hullma[1]
hull_red = hullma < hullma[1]

Buy = BoxCrossover and hull_green
Sell = BoxCrossunder and hull_red

我尝试了 if 函数,但无法使其工作。非常感谢任何帮助。

I'm able to add multiple conditions into one signal, but because of my lack of experience programming I can't figure out how could I toggle on/off different conditions in the options.

IncludeC1 = input(true)

IncludeC2 = input(false)

Condition 1 = crossover

Condition 2 = hull direction

Signal = crossover and hull direction

I would need to achieve this
Signal = crossover and (hull (if selected))

Basically so I can add, remove single conditions in the input section.

BoxCrossover = ta.crossover(close, boxHigh)
BoxCrossunder = ta.crossunder(close, boxLow)

hull_green = hullma > hullma[1]
hull_red = hullma < hullma[1]

Buy = BoxCrossover and hull_green
Sell = BoxCrossunder and hull_red

I tried if functions but I can't manage to make it work. Would really appreciate any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

缱倦旧时光 2025-01-17 06:41:58

尝试三元条件运算符

类似的东西

i_hullOnOff = input.bool(true, 'Hull On/Off')

hull_green = hullma > hullma[1]

Buy = BoxCrossover and (i_hullOnOff ? hull_green : true)

Try a Ternary Conditional Operator.

Something like that

i_hullOnOff = input.bool(true, 'Hull On/Off')

hull_green = hullma > hullma[1]

Buy = BoxCrossover and (i_hullOnOff ? hull_green : true)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文