StockFetcher Forums · General Discussion · A how-to query for you SF geniuses<< >>Post Follow-up
betyerbottomdollar
169 posts
msg #54654
Ignore betyerbottomdollar
9/8/2007 9:00:34 PM

Can SF filters handle "if, then" type of statements?

I want to buy when the close crosses below the EMA(20)
and sell if the high crosses the Upper Bollinger Band(20, 2)

unless...

the price keeps dropping past the EMA(20) and the close crosses the Lower Bollinger Band (20, 2), then I want to buy again...

and sell when the high crosses up the EMA (20)

and on and on and on n on n on forever.


guru_trader
485 posts
msg #54660
Ignore guru_trader
9/9/2007 3:22:11 AM

Yes, thanks for TRO and others ...

Currently StockFetcher does not support conditional boolean logic directly. This is due to the potentially enormous computational impact it might have on StockFetcher's servers. There are, however, some work-arounds which may accomplish any boolean logic (or/if conditions). See the following forum posts for some solutions:

http://www.stockfetcher.com/stockdb/fetcher?p=forum&sub=view&fid=1001&tid=28017

http://www.stockfetcher.com/stockdb/fetcher?p=forum&sub=view&fid=1003&tid=28019


TheRumpledOne
6,407 posts
msg #54670
Ignore TheRumpledOne
modified
9/9/2007 2:47:29 PM

Fetcher[
set{xBB1, count(HIGH crossed above the upper bollinger band (20),1) - count(LOW crossed below the lower bollinger band (20),1)}

set{xBB2, count(close above the upper bollinger band (20),1) - count(close below the lower bollinger band (20),1)}

set{xBB, xBB1 + xBB2}

set{E20b,days(close is above ema(20),100)}
set{E20a,days(close is below ema(20),100)}
set{CxE20, E20a - E20b}


add column CxE20
add column xBB

close above 20
volume above 5000000

market is nasdaq
]



xBB tells you the number of days the price has been above/below the upper/lower Bollinger bands.

CxE20 tells you the number of days the price has been above/below the EMA(20).

Check out the BASIC FILTER DISPLAY I wrote years ago.

nikoschopen
2,824 posts
msg #54672
Ignore nikoschopen
modified
9/9/2007 3:10:41 PM

C'mon guys, the chap is asking for a "if, then" CONDITIONAL statement, not a BOOLEAN function. Gggrrrrr!!

Here's one way to get around the If..Then conditional. Suppose I'm looking for stocks with a weekly return greater than 5% or less than -5%. That is, I'm screening for stocks like ABC that ran up more than 5% within a week and XYZ that plummeted more than 5% within a week. Basically, I want to exclude from my filter any stocks that are in between -4.99 and 4.99. What I want are the ones in the extreme.

Fetcher[
set{rtn,price / price 5 days ago}
set{rtn2,rtn - 1}
set{if,rtn2 * 100}
set{then, 1 - count(if is between 5 and -5,1)}
then equals 1
add column if{weekly%}
]

At any rate, TRO deserves the credit for bringing the Boolean formula here at SF. Way to go, bro!

:)

guru_trader
485 posts
msg #54708
Ignore guru_trader
9/11/2007 3:22:02 AM

Well, I'd love an actual if/then/else function, but I'll keep dreaming :)

betyerbottomdollar
169 posts
msg #54728
Ignore betyerbottomdollar
9/11/2007 7:19:33 PM

Hmmm....yeah....

Thanks for yall's input. The links helped a bit...I learned some things I didn't know. But as for the actual if then else function I guess I can do it on paper. Or set up multiple backtests and try to add em up and average them out somehow.

Oh, here is a joke I heard the other day...

How do you kill a circus?

Go for the juggler.

StockFetcher Forums · General Discussion · A how-to query for you SF geniuses<< >>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.