StockFetcher Forums · General Discussion · Combining filters as unions and intersections of results...<< 1 2 >>Post Follow-up
siliconhippy
37 posts
msg #32253
Ignore siliconhippy
6/3/2004 3:53:28 PM

I was wondering how one might be able to use some filter functionality (besides apply watchlist that can give you results from all included filters), that mimics the OR (union) of all filter results. Currently, with chaining, we seem to have the AND (intersection, or common to all) functionality implemented. And the apply watchlist can only do an OR (union.)

With both OR and AND features, one could do a number of runs all at once, with great time savings.

I know an OR feature will considerably simplify my filter and watchlist space !

siliconhippy


siliconhippy
37 posts
msg #32255
Ignore siliconhippy
6/3/2004 5:00:38 PM

I must also mention here my experimentation with AutoFill set to 1-2 filters when the whole list is say 8 filters attached to a particular Watchlist you want to fill.

You could think of creating the above OR (union) function by setting the AutoFill to 1 filter while it scans the whole filter list attached to the Watchlist you are filling. This way, the watchlist then contains all symbols that match at least 1 filter (looks like 0 filter matches are thankfully ignored or you could get filled to the entire stock universe population !)

The above method works until you realize that one of your filters attached could simply be a charting filter that is convenient when you want to display a certain indicator set on your stock plot. Then the 1 filter strategy doesn't work !! Setting the AutoFill menu to 1 filter, I got a 200+ symbol list that had nothing to do with my stock screening filters.

So I then selected 2 filters on the AutoFill menu. Somehow, 1 of the filters selected is always the charting filter, hence you are back to the correct list (union of all stock filters.) But this may just be a random exception...when I tried more than 1 filter run in case all the attached filters were stock filters, the stocks displayed were all at least matched to the number of filters selected.

However, I did not seem to have control of exactly which filters to match all the time...

So I think SF should look into this AutoFill bug, and then give us some inkling of how to implement actual OR (union of all) and AND (common to all) features. Best would be to have filter phrases that could do OR and AND over entire sets of statements enclosed by braces, for instance.

siliconhippy


cegis
235 posts
msg #32261
Ignore cegis
6/4/2004 9:35:54 AM

siliconhippy,

Please allow me to make some comments and observations.

First, if your "charting filters" have an always-met condition (e.g., price is greater than 0), then you can get the OR result by using the watchlist autofill functionality, requiring the autofill to match "n + 1" filters, where "n" is the number of charting filters in your watchlist. If you have several watch lists, put the number of required matches in the watchlist name to remind you. (In other words, make your "charting filters" simply draw statements, with the always-met condition.)

Second, and perhaps more to what you are looking to accomplish, you CAN "program" an OR function in a filter, albeit in a "round about" way. By using the count() function (see Announcements forum, Occurrences thread), you can set{} a variable to one or zero based on a condition. Do this for each of your conditions, then add the variables together. If the result is greater than zero, then your OR is true. Here's an illustrative filter (not intended for finding tradable stocks):

Fetcher[
set{p,count(price is between 5 and 6,1)}
set{v,count(volume 30 day low is greater than 1000000,1)}
set{or,p + v}
or is greater than 0
add column p
add column v
add column or
]



This should give stocks whose price is between 5 and 6, OR volume 30 day low is greater than a million.

HTH,

C


siliconhippy
37 posts
msg #32263
Ignore siliconhippy
6/4/2004 11:14:26 AM

cegis,

Thanks for the answer. I was just hoping SF could come up with a more direct implementation :)

cheers,

siliconhippy


cegis
235 posts
msg #32268
Ignore cegis
6/4/2004 2:41:25 PM

I have to agree that a more direct implementation would be nice :-)

C


defghca
150 posts
msg #32279
Ignore defghca
6/6/2004 9:04:50 AM

lets hear it for the "OR" conjonction


TheRumpledOne
6,411 posts
msg #32280
Ignore TheRumpledOne
6/6/2004 1:00:21 PM

see my post on BOOLEAN LOGIC for AND, OR, NOT


siliconhippy
37 posts
msg #32295
Ignore siliconhippy
6/7/2004 12:20:33 PM

Avery,

Thanks for mentioning. Below I am reproducing your post.

Questions:
1. Shouldn't you move the "close above/below 100" to a much higher value? many stocks are making 100s in price. Probably not mnay in the 1000s.

2. Is there a simple way to use your filters when the objective is to combine filter results as unions/interesections without having to modify the actual stock filters?

siliconhippy


--------------------------------------------
TheRumpledOne 8/24/2003 1:30:55 PM

I have implemented OR, NOT and AND using SF set and count functions. Now we have a complete logic system within SF. THERE IS NOTHING YOU CAN'T DO NOW!
This should revolutionize SF Filter writing.

Fetcher[/* OR Implementation */ /* by definition OR is TRUE IF A is TRUE, B is TRUE, or A AND B is TRUE*/ /* THEREFORE by counting and adding, if the sum is greater than 0 the OR condition is TRUE. */ /* Copyright 2003 by Avery T. Horton, Jr. */ /* Permission to use OR Implementation withing StockFetcher Granted */ /* Permission to publish or post on any other forum DENIED */ /* ----------------------------------------------------------------*/ set{A, count(close above 100, 1)} set{B, count(volume above 50,000,000, 1)} set{OR1, A + B} show stocks where OR1 above 0]



Fetcher[* NOT Implementation */ /* by definition NOT A is TRUE IF A is FALSE*/ /* THEREFORE by counting and adding, if the sum is equal to 0 the NOT condition is TRUE. */ /* Copyright 2003 by Avery T. Horton, Jr. */ /* Permission to use NOT Implementation withing StockFetcher Granted */ /* Permission to publish or post on any other forum DENIED */ /* ----------------------------------------------------------------*/ set{NOT, count(close below 100, 1)} show stocks where NOT equal 0]



Fetcher[/* AND Implementation */ /* by definition A AND B is TRUE IF A is TRUE and B is TRUE*/ /* THEREFORE by counting and adding, if the sum is equal to 2 the AND condition is TRUE. */ /* Copyright 2003 by Avery T. Horton, Jr. */ /* Permission to use NOT Implementation withing StockFetcher Granted */ /* Permission to publish or post on any other forum DENIED *//* ----------------------------------------------------------------*/ set{A, count(close above 100, 1)} set{B, count(volume above 1000000, 1)} set{X, A + B} show stocks where X equal 2]



Ok, first, before you BLAST me with "SF already has AND", just sit back, relax and OPEN you mind...

Using these functions, you have a complete logic system. You can implement a complete SET THEORY.

OR is greater than 0
AND is equal 2
NOT is equal 0

So by putting each condition you are filtering in a COUNT and then using SET to sum the condition pair, you can test for the OR, AND or NOT condition.

If you don't understand LOGIC or SET THEORY, I suggest you do a www.google.com search.

Those who understand will see the simple elegance of this.

GOOD LUCK WITH YOUR FILTERS!
--------------------------------------------



mslattery@dc.rr.com
91 posts
msg #32335
Ignore mslattery@dc.rr.com
6/13/2004 7:27:51 PM

To: TheRumpledOne!

How about "IF", "THEN".


cegis
235 posts
msg #32353
Ignore cegis
6/15/2004 3:42:39 PM

mslattery@dc.rr.com,

NOT A PROBLEM!!!

For example:

Fetcher[
set{hi10, count(price reached a new 10 day high,1)}
set{hi25, count(price reached a new 25 day high,1)}
set{hi52w, count(price reached a new 52 week high,1)}

set{hd1, hi10 * 10}
set{hd2, hi25 * 15}
set{hd3, hi52w * 340}

set{hdsum, hd1 + hd2}
set{HiDays, hdsum + hd3}

price between 3 and 4

add column price 10 day high
add column hi10
add column price 25 day high
add column hi25
add column price 52 week high
add column hi52w
add column HiDays
]



In a nutshell, this filter sets HiDays to 10, 25, or 365, depending on if the stock's price reached a new 10 day, 25 day, or 52 week high.

Here are the details:

The first group (3 lines) of set{} commands set "conditional" variables that have the value of zero or one, depending on if the condition is true (1=true).

The next group (3 lines) of set{} commands takes these conditional variables and multiplies them by the values we want to see. Since zero times anything is zero, and one times anything is anything, we get the "then" part of our "if/then" via the multiplication! (We multiply by 10, *15* and *340*, because a new 52 week high will ALSO be a new 25 day and 10 day high, so all three conditional variables will be true. 10+15+340 = 365.)

The last 2 set{} commands sum up our results, giving a column that's "365" when a new 52 week high is reached, "25" for a new 25 day high, "10" for a new 10 day high, or "0" if it's not a new high (in one of the three periods).

So, the bottom line is, to get the "then" part of an "if/then", multiply by the conditional variable. You can slao get an "else" part of an "if/then/else" by multiplying by the difference between one and the conditional variable (i.e., "(1 - var)").

The filter above shows the HiDays column equal to all four possible values when run for EOD 6/14...

HTH,

C


StockFetcher Forums · General Discussion · Combining filters as unions and intersections of results...<< 1 2 >>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.