StockFetcher Forums · General Discussion · Problem using 'has been below' & 'within the last X days'<< >>Post Follow-up
tylercabral
14 posts
msg #118687
Ignore tylercabral
3/20/2014 10:55:29 PM

Hi I have been trying to make a filter that checks to see if a value has been below a certain threshold within the last number of days or week. This is my example code:

....
set{var1, expression1 (e.g., MA(50) / expression2 (e.g., Price)}
and var1 has been below -2 within the last 2 weeks
....

This does not seem to work properly, because when I run this expression compared to this one

....
set{var1, expression1 (e.g., MA(50) / expression2 (e.g., Price)}
and var1 has been below -2
....

It provides me less results. There is no reason it should ever provide less results since this essentially ask has been below within the last day to my understanding, where as the other asks for multiple days which includes this so it should always be equal to or greater than in results.

What is wrong here?

mahkoh
894 posts
msg #118688
Ignore mahkoh
modified
3/21/2014 4:51:15 AM

In your 2nd filter you don't provide syntax for how long var1 has been below-2. Possibly SF in such cases disregards 'has been'
and only returns stocks where var1 currently is below-2. Add a column 'var1' and check whether there are values greater than -2
in that column.

Kevin_in_GA
4,553 posts
msg #118689
Ignore Kevin_in_GA
modified
3/21/2014 8:13:40 AM

You could also code it like this:

set{var1, expression1 (e.g., MA(50) / expression2 (e.g., Price)}
and
set{var1count, count(var1 below -2,10)}

var1count above 0.5
add column var1
add column var1count
sort on column 6 descending

the new variable var1count just counts the number of times within the last ten trading sessions that var1 has been below -2. Then I just added new columns for var1 and var1count, and had SF sort the results from highest var1count to lowest.

tylercabral
14 posts
msg #118711
Ignore tylercabral
3/24/2014 9:17:32 AM

"3/21/2014 4:51:15 AM

In your 2nd filter you don't provide syntax for how long var1 has been below-2. Possibly SF in such cases disregards 'has been'
and only returns stocks where var1 currently is below-2. Add a column 'var1' and check whether there are values greater than -2
in that column."

Yes, the second filter was not meant to do this. It was meant to point out how the first filter is working.

Do these two functions not work together?

The third posts' work around is one solution, but not really ideal.

Kevin_in_GA
4,553 posts
msg #118717
Ignore Kevin_in_GA
3/24/2014 10:33:10 AM

....
set{var1, expression1 (e.g., MA(50) / expression2 (e.g., Price)}
and var1 has been below -2 within the last 2 weeks

....
The third posts' work around is one solution, but not really ideal.


++++++++++++++++++

Actually it gives you EXACTLY what you have asked for - a list of stocks where var1 has been below -2 at some time within the last two weeks. How is that a "work around"?

tylercabral
14 posts
msg #118719
Ignore tylercabral
3/24/2014 10:42:04 AM

Hi Kevin,

Sorry if I misunderstood, but since this is a count, couldn't the count be 0? And in turn this just return stocks that never have been below?

Kevin_in_GA
4,553 posts
msg #118721
Ignore Kevin_in_GA
3/24/2014 11:10:14 AM

No - the count() function returns a "1" every time the specific criterion is met. Therefore, for any time that var1 was below -2 in the past 10 trading sessions the function would return a "1". So when I set var1count to be above 0.5, it only selects those stocks which have met your criterion at least once within the last 10 days, and excludes all others.

There might be stocks that have met this every day over the past 10 days, and they would recieve a count of 10. So by adding a column for var1count and then sorting on that column from highest to lowest, you will see stocks that have met your criterion most often at the top.

tylercabral
14 posts
msg #118727
Ignore tylercabral
3/24/2014 1:40:41 PM

Thanks for the clarification.

StockFetcher Forums · General Discussion · Problem using 'has been below' & 'within the last X days'<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2016 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus