StockFetcher Forums · Filter Exchange · Logical Operator "OR" Revisited<< >>Post Follow-up
2,824 posts
msg #56947
Ignore nikoschopen
11/22/2007 7:49:20 PM

As a way to commemorate Thanksgiving, I would like to give back to the SF community something relatively small for many great things that I learned over the years.

As you may know, the logical disjunction "OR" isn't natively supported in SF language. However, we're able to get by this limitation using the method TRO introduced. I, on the other hand, wish to push this one step further by using it in conjunction with the "If-Then" conditional.

I have noticed that many of you write two filters of the same condition. For example, one filter is written for stocks that crosses above its 20-day moving average and another filter is written for stocks that crosses below its 20-day moving average. Why not just write one filter that would allow both conditions to be met but also informs you which is which. Here's how you write it.


set{condition 1, count(indicator 1, indicator 2,1) * 1}
set{condition 2, count(indicator 1, indicator 2,1) * -1}
set{both, condition 1 + condition 2}
set{result, 1 - count(both equals 0,1)}
result above 0
add column both{result}

Hence, taking the above example of 20-day moving average crossover:

set{up, count(price crossed above MA(20),1) * 1}
set{down, count(price crossed below MA(20),1) * -1}
set{both, up + down}
set{Xover, 1 - count(both equals 0,1)}
Xover above 0
add column both{Xover}

And once you run the filter, you would see in the fifth column either a "1", indicating a bullish crossover, or "-1", indicating a bearish crossover. Here's a screenie of what you can expect after you run this filter:

103 posts
msg #56949
Ignore bkhurana43
11/22/2007 8:02:00 PM

I hope SF community would appreciate your contribution.
I will attempt to identify stocks by their Candle Formation Patterns and post it when ready for your comments.

171 posts
msg #56950
Ignore drew9
11/22/2007 10:19:39 PM

Very nice work Niko! Thank you and Happy Thanksgiving!

6,362 posts
msg #56951
Ignore TheRumpledOne
11/22/2007 10:37:04 PM

set{E200b,days(close is above ma(20),100)}
set{E200a,days(close is below ma(20),100)}
set{CxM20, E200a - E200b}

Add column CxM20

sort column 5 descending

martket is nasdaq 100

Sometimes you want to know how many days since the cross occurred.

I took this out of my BASIC FILTER FOR NEWBIES.

88 posts
msg #91668
Ignore sbuck143
4/26/2010 11:29:33 AM

bump for something very helpful for newbies.

StockFetcher Forums · Filter Exchange · Logical Operator "OR" Revisited<< >>Post Follow-up

*** Disclaimer *** 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. does not recommend particular securities., 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 2018 - 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