|
Checking for a Sequence of Events If you wish to determine when a condition, such as close < open, is true over multiple bars, you can use an indicator such as Minimum Value from the Basic category instead of having to combine "ands" and "lags".
To see if the last 5 bars have had a closing price less then the open price, you could simply verify that the minimum value of Close < Open over the last 5 bars is True (i.e., 1). So for instance:
A=B( Min( A<B(Close,Open), 5 ), 1 )
The real power of this technique is that you can optimize the lookback of the Min indicator inside of a prediction or trading strategy, which allows the optimizer to determine whether 5 bars really is optimal or perhaps 3, 9, or some other number of bars is better.
If you are looking for a sequence of events that is not contained within a certain number of bars, another approach to this problem is to use the Followed By indicator from Advanced Indicator Set 3. You can even nest Followed By indicators if you use another copy of the Followed By indicator as the second condition in the indicator settings. This will enable you to search for a string of conditions.
|