假设我有条件 1 和条件 2。如果在最多 5 个柱内满足条件 1 和条件 2,那么我想要执行一些操作。举个例子,假设当前收盘价满足条件 1,并且 5 根柱前满足条件 2,那么我想执行一些操作。我如何在 Pine 中表述它?
condition1 = ...
condition2 = ...
if (condition1(close)==true or condition1(close-2)==true or
condition1(close-3)==true or condition1(close-4)==true or
condition1(close-5)==true)
and (condition2(close)==true or condition2(close-2)==true or
condition2(close-3)==true or condition2(close-4)==true or
condition2(close-5)==true)
then...
Run Code Online (Sandbox Code Playgroud)
也许可以这样表述:
if condition1(close:close-5)== true and condition2(close:close-5)== true then ...
Run Code Online (Sandbox Code Playgroud)
我读过例如这个帖子: 仅更改最后 5 个小节的背景:一个我无法破解的非常简单的问题 这听起来像是一个类似的问题,但我不确定如何实现它。