StockFetcher Forums · General Discussion · Need to insert language into filter about broader market indices<< >>Post Follow-up
bullishjim
3 posts
msg #88191
Ignore bullishjim
2/12/2010 11:22:25 AM

How's that for a thread title?

Here's what I am getting at: I want to add language to some of my filters which will make them only pull stocks when something is true about a particular market index. In real life, I might not buy stocks from a particular filter (ie "pullback to a rising 50 day moving avg") unless the market as a whole is in a rising trend. Without being able to model that fact into my Stockfetcher filters I am unable to backtest the actual performance. Is there an easy solution to this question? I've looked around quite a bit but haven't found language that works.

For example, her'es a simple filter I use to pull stocks that have pulled back to a rising 50 day moving average:

show stocks where close is between 10 and 100
and average volume(60) > 500000
and close > ma(50)
and rsi(7) < 50
and close is less than 2% > ma(50)
and ma(50) is more than 5% > ma(50) 30 days ago
and ma(50) is more than 10% > ma(50) 60 days ago
and ma(50) is more than 15% > ma(50) 90 days ago

Is there a simple line or two I can add that adds the requirment, for instance, that the rsi(14) of ^SPX must be below 30? I feel like the answer should be easy but I can't seem to make anything I've tried work.




Venice
82 posts
msg #88204
Ignore Venice
modified
2/12/2010 12:58:52 PM

Maybe?

Fetcher[
show stocks where comparative relative strength(^SPX,15) is below 30
and compare with ^SPX
]




bullishjim
3 posts
msg #88207
Ignore bullishjim
2/12/2010 1:06:19 PM

Thanks for answering, Venice. Doesn't the language you provided require that stocks be outperforming the SPX for the past 45 days in order to be selected by the filter? What I'm trying to do is basically have the filter turn off entirely if the overall market is not trending the way I want it to. For instance, I might not want to buy stocks when the slow stochastic for the SPX as a whole is above a certain level, say 80.

In practice it's easy enough to simply not use a filter when the market is overbought (in my opinion). In order to backest a filter accurately, however, i need to be able to have Stockfetcher also not buy ANY stocks when that condition is true.

It seems like a simple question but I am totally stumped.

Kevin_in_GA
4,599 posts
msg #88217
Ignore Kevin_in_GA
2/12/2010 2:32:36 PM

Something like this?

Fetcher[
set{spx_close, ind(^SPX,close)}
set{spx_ma, cma(spx_close, 200)}

spx_close above spx_ma

]



This piece of code, when incorporated into your screening filter, will only return stocks if the S&P is above its MA(200). As you can see, the basic structure can be modified to incorporate other criteria as well

chetron
2,817 posts
msg #88220
Ignore chetron
modified
2/12/2010 3:06:11 PM

MY SPX LAZY VERSION, YOU CAN CLEAN IT UP.....


Fetcher[

/* ALL ENCOMPASSING SPX-O-LATER */

set{Vspx, ind(^SPX, close)}

Set{vMA10,CMA(Vspx,10)}
set{vSD,cstddev(Vspx,10)}
set{vSD10,2 * vSD}
set{vBOLU,vMA10 + vSD10}
set{vBOLD,vMA10 - vSD10}




/* TACHIKAWA 2 */


set{v1,Vspx 1 day ago}
set{vud,Vspx - v1}
set{vud1,count(vud above -0,1)}
set{vudf,vud * vud1}
set{vudema,cema(vudf,14)}

set{vdd,v1 - Vspx}
set{vdd1,count(vdd above -0,1)}
set{vddf,vdd * vdd1}
set{vddema,cema(vddf,14)}

set{myrsi1,vudema / vddema}
set{myrsi2,1 + myrsi1}
set{myrsi3,1 / myrsi2}
set{myrsi4,myrsi3 * 100}
set{SpxRSI,100 - myrsi4}

draw Vspx
draw vbold on plot Vspx
draw vbolu on plot Vspx
draw vma10 on plot Vspx

SpxRSI below 30
close above .1
volume above 1000000


]



StockFetcher Forums · General Discussion · Need to insert language into filter about broader market indices<< >>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.