| kbadeau 2 posts
 msg #157706
 - Ignore kbadeau
 | 9/30/2021 4:05:42 AM 
 Hello folks,
 
 Looking for some basic help using the "within" filter.
 
 On a filter line such as:
 XXX is below -1 within the last 2 weeks
 
 I am able to see clearly that this is true for a given stock and if I remove the "within" clause and use the scroll back feature going back one day at a time in the filter dialog I can see my stock eventually meets the criteria by clicking back just a few days (i.e. less than 2 weeks).
 
 However, if I add the "within the last 2 weeks" criteria the stock does not appear as meeting the criteria.
 
 For a particular example I am working with the MACD and trying to flag stocks where the Fast Line was below -1
 
 In my script below I am using the stock BERY as it met the "below -1" criteria on Sep 22, 2021, which at time of writing on Sep 30, was just about 8 days ago (or less in trading days).
 
 If I use the below without the "within 2 weeks" filter and scroll back to Sep 22 the stock appears in the results. If I use that "within 2 weeks" filter as of today, Sep 30, the stock does not appear to meet the filter's criteria.
 
 Note: in my example I am using some user defined variables and displaying them as columns so I can see exactly what the values are for Fast, Slow, and Divergence for each day.
 
 I am using the variable in my criteria line but I've tried this with the basic function itself and also not having any luck, thus why I started using the variables so I could see for myself what the values really are.
 
 Any help is much appreciated!
 
 ------------------
 apply to symlist(BERY)
 
 set{Divergence,MACD Histogram(8,16)}
 add column Divergence
 
 set{MyDiv,MACD Fast Line(8,16,11) - MACD Slow Line(8,16,11)}
 add column MyDiv
 
 set{MyMFL,MACD Fast Line(8,16,11)}
 add column MyMFL
 
 set{MyMSL,MACD Slow Line(8,16,11)}
 add column MyMSL
 
 draw MACD Fast Line(8,16,11)
 MyMFL is below -1 within the last 2 weeks
 
 
 | 
| nibor100 1,099 posts
 msg #157710
 - Ignore nibor100
 | 9/30/2021 10:53:11 AM 
 @kbadeau,
 
 The following should work for you:
 
 MyMFL crossed below -1 within the last 2 weeks
 
 My guess is by replacing "is" with "crossed" SF understands it to be more of a temporary occurrence as opposed to a more permanent status.
 
 Which probably explains why when you went back to the actual day without the "within" it returns a result for that date....but this is only a guess on my part as nuances of SFs language and syntax processing occasionally create quite the mystery.
 
 Hope this helps,
 Ed S.
 
 
 
 
 |