繁体   English   中英

松树脚本条件/条件语句

[英]Pine script conditions / conditional-statements

我有6个条件:

c1 = ...
c2 = ...

然后,如果其中 4 个被填满(产生 15 个组合),我将执行一些命令。 这个怎么做?

例如:

cb1 = c1 and c2 and c3 and c4
cb2 = c1 and c2 and c3 and c5
cb3 = c1 and c2 and c3 and c6
cb4 = c1 and c2 and c4 and c5
cb5 = c1 and c2 and c4 and c6
cb6 = c1 and c2 and c5 and c6
cb7 = c1 and c3 and c4 and c5
cb8 = c1 and c3 and c4 and c6
cb9 = c1 and c3 and c5 and c6
cb10 = c1 and c4 and c5 and c6
cb11 = c2 and c3 and c4 and c5
cb12 = c2 and c3 and c4 and c6
cb13 = c2 and c3 and c5 and c6
cb14 = c2 and c4 and c5 and c6
cb15 = c3 and c4 and c5 and c6

// Set up alert
alertcondition(condition=cb1 or cb2 or cb3 or cb4 or cb5 or cb6 or cb7 or cb8 or cb9 or cb10 or cb11 or cb12 or cb13 or cb14 or cb15,
     message="cb")

您可以阅读本文以获取一些信息。

if (condition1 == true) and (condition2 == true) and (condition3 == true) and (condition4 == true)
    // Do something
else if (condition2 == true) and (condition3 == true) and (condition4 == true) and (condition5 == true)
    // Do something else

请注意缩进。

我们可以做积分系统吗? 例子

condition1 is ok X=1
condition2 is ok X=x+1
condition3 is ok X=x+3
condition4 is ok X=x+4

if x>0
do this
else if x>1
do this
else if x>2
do this    
...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM