StockFetcher Forums · General Discussion · Count times ticker was returned by filter<< >>Post Follow-up
fotchstecker
297 posts
msg #158639
Ignore fotchstecker
2/21/2022 2:23:28 PM

Howdy all.
Has anyone come up with a way to count the number of times a symbol was returned by that filter over the last X days?

It's helpful to see when a filter is producing a symbol for the first time.

I worked on this a long time ago but only came up with a limited solution.

fotchstecker
297 posts
msg #158641
Ignore fotchstecker
2/21/2022 3:35:08 PM

It was basically this time last year that I asked this.

Ask me what I had for breakfast.

set{myflag, count(CONDITION, 1)}
draw myflag
set{flagcount, count(myflag equals 1, 40)}
add column flagcount

fotchstecker
297 posts
msg #158642
Ignore fotchstecker
2/21/2022 3:49:01 PM

I remember what the next issue was. How do you do this method for two required conditions?

set{ext, Triggerline - EntryMID }
and ext has crossed above 0 within the last 40 days
and pp > entrylow

nibor100
937 posts
msg #158645
Ignore nibor100
2/22/2022 10:06:56 AM

One way is to set variables for a one day Count for each of your indicators, which will result in a Count of 1 if true, and Count of 0 if false.

Then set a variable that adds those 2 Count variables up and then filter for that variable being greater than 1; because if both are true then the sum is 2 which is greater than 1.

See crazy example below using what you had posted last:
Ed S.

Fetcher[
set{triggerline, close 1 day ago}
set{entrymid, close - triggerline}
set{ext, Triggerline - EntryMID }
set{entrylow, close 2 days ago}

set{var1, count(ext has crossed above 0 within the last 40 days,1)}
set{var2, count(pp > entrylow,1)}

set{true1, var1 + var2}
add column true1 > 1
]



fotchstecker
297 posts
msg #158654
Ignore fotchstecker
modified
2/22/2022 4:36:37 PM

Thanks, Ed. I tried that and it works logically of course but one potential issue is that it doesn't require that the count of either condition be non-zero. So while it accounts for both by summing them, it doesn't exclude a "hit" on a day when either condition was zero. The logic is AND for the second condition...

At least I think that's what's happening.

I used your helpful example for this version:

set{var1, count(ext has crossed above 0 within the last 40 days,1)}
set{var2, count(pp > entrylow,1)}
set{true1, var1 + var2}
set{hitcount, count(true1 > 0, 100)}

add column hitcount


fotchstecker
297 posts
msg #158656
Ignore fotchstecker
2/22/2022 4:49:31 PM

Hmm...

I wonder if this is correct.

Fetcher[
set{var3, count(ext has crossed above 0 within the last 40 days,1)}
set{then, var3 * 1}
set{var4, count(pp > entrylow,1)}
set{andthen, var4 * 1}
set{true2, then * andthen}
set{truecount, count(true2 above 0, 100)}
add column truecount
]



nibor100
937 posts
msg #158659
Ignore nibor100
2/23/2022 12:45:52 PM

@fotchstecker,

There are 2 ways I know of to do a logical AND in SF for 2 set variables that are tested each for True or False conditions using the 1 day Count command. (which returns 1 for True and 0 for False):

Add them together

or

Multiply them together

When we add them together we get 0 when both are False, 1 when either. one of them is True and the other is False, or 2 when both are True at the same time.

When we multiply them together we get 0 when both are False, 0 when either, one of them is True and the other is False, or 1 when both are True at the same time.

In that sample filter I posted I added them together and used the add column command to simulaneously show the result value of the addition and to limit the results to only those whose sum was greater than 1 which in that case was 2 which can be verified by scrolling down and seeing that all of the results have 2 in that column.

I did all of that assuming you only wanted stocks that met both conditions today at the same time.

Ed S.



fotchstecker
297 posts
msg #158747
Ignore fotchstecker
3/7/2022 6:42:46 PM

Ed, I got wrapped up in things recently. Just wanted to thank you for the replies.

StockFetcher Forums · General Discussion · Count times ticker was returned by filter<< >>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 2022 - 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


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.