fotchstecker 304 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 304 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 304 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 1,010 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.
|
fotchstecker 304 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 304 posts msg #158656 - Ignore fotchstecker |
2/22/2022 4:49:31 PM
Hmm...
I wonder if this is correct.
|
nibor100 1,010 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 304 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.
|