Hello
I have three factors in a pipeline.
lower_band,
lower_band_tplus1,
lower_band_tminus2.
Note. The factor lower_band is calculated from past data that does not include t-1, so it is possible to plot it into the future t+1.
The 2nd and 3rd factors are just lagged copies of the 1st factor (lagged t+1 and t-1).
Use of factors in filters:
I use these factors in filters to determine if the value of today's lower_band is a maximum (greater than t+1 and t-1).
I have two questions please:
1) I currently achieve this by using three different factors , with three different "custom factors" which are identical apart from being lagged forward and backward 1 day. Is it possible to determine if today's value for lower_band is a maximum with just a single custom factor and the use of something like .shift()?
2) Later, in the logic of the pipeline, I'm trying to determine if is a max with the following statement:
Approach 1
arrows_up = lower_band >= max(lower_band_minus1, lower_band_plus1)
longs = arrows_up
However, when i check the output this is not behaving as expected.
When I break the statement down into two steps, I get the correct output:
Approach 2
arrows_up_step1 = lower_band >= lower_band_minus1
arrows_up_step2 = lower_band >= lower_band_plus1
longs = arrows_up_step1 & arrows_up_step2
I can't understand why Approach 1 and Approach 2 get such different results? Approach 1 gives incorrect results (the lower_band value is not the max).
Thanks in advance