Monday, August 11, 2008

The Gap Stat calculator

Is it possible to predict gaps in advance? I’ve been working on this question for a while. Although there are many gap filters on Stockfetcher, none of them are useful in my opinion. What I want to know is how the stock I’m currently holding performs historically on gaps or how the stock I’m looking to buy into the close performs under a given set of conditions. Well thanks to my friend SlowPoke I now have a Gap Stat calculator. This filter is used as a calculator to check an individual stock's performance rather than scanning for stocks that meet the criteria. To use it just put in the stock symbol that you are interested in and the percent gain and loss for performance in the first and second lines of code.
Here is the code using RDN and 10% gain/loss as an example:

symlist (rdn)

set {gain_threshold, 0.10}  /* 20% gain */

set {drop_threshold, 0.10}  /* 20% drop */

set {ClOp , close  - open}

set {ClOpPct , ClOp / open}

set {OpCl , open - close}

set {OpClPct , OpCl / close}

set {met_threshold_Yesterday , count(ClOpPct 1 day ago >= gain_threshold,1)}

set {met_down_threshold_Yesterday , count(OpClPct 1 day ago >= drop_threshold,1)}

set {gapped_up_today , count(open > close 1 day ago,1)}

set {gapped_down_today , count(open is below close 1 day ago,1)}

set {met_threshold_then_gapped_up_today , met_threshold_yesterday * gapped_up_today}

set {met_threshold_then_gapped_down_today , met_threshold_yesterday * gapped_down_today}

set {met_down_threshold_then_gapped_up_today , met_down_threshold_yesterday * gapped_up_today}

set {met_down_threshold_then_gapped_down_today , met_down_threshold_yesterday * gapped_down_today}

set {met_threshold ,count(met_threshold_yesterday >= 1,100)}

set {then_gapped_up , count(met_threshold_then_gapped_up_today >= 1,100)}

set {then_gapped_down , count(met_threshold_then_gapped_down_today >= 1,100)}

add column met_threshold

add column then_gapped_up

add column then_gapped_down

set {met_down_threshold , count(met_down_threshold_yesterday >= 1,100)}

set {down_then_gapped_up , count(met_down_threshold_then_gapped_up_today >= 1,100)}

set {down_then_gapped_down , count(met_down_threshold_then_gapped_down_today >= 1,100)}

add column met_down_threshold

add column down_then_gapped_up

add column down_then_gapped_down

chart-time 105 day

draw met_threshold_yesterday

draw met_down_threshold_yesterday


We can see from these results that RDN gapped up 8 out of 10 times it gained 10% in the past 100 days. Interestingly, it lost 10% 23 times and still gapped up 17 times and only gapped down 5 times on a 10% loss. RDN is a gap upper. On the other hand a stock like DAL is much less reliable. In the past 100 days it has gained 10% 6 times and only gapped up 2 of those times and gapped down 4. Hopefully you will find this filter as useful as I do in your end of market decision making.

**UPDATE

This has been the source of some technical difficulties. If you cannot successfully cut and paste this into StockFetcher then email me at johnnyvento@gmail.com

11 comments:

Unknown said...

Johnny V thank you so much for your dedication, hard work and blog page. You took the time e-mailing me and explaing things I didnt understand. You guided me from filters to chart help books to shorting or going long. Without you, I would be lost. You put me on tract, and will be looking forward to all your furture blogs and input when your around!

Thanks a million

Raymond B aka AntonellaB

johnnyvento said...

thanks raymond,
I hope you caught ABK and RDN in the afternoon. They were boring in the morning but they picked up! Heard the chat was going nuts on RDN

Unknown said...

typos, Grrrr... explaining*, track*,

James Krieger said...

Johnny,

I tried this filter in Stockfetcher but I didn't get any numbers or results or anything. When I ran debug, it said Unable to process due to set{} errors for the 1st line of code.

dilimanrepublic said...

this filter is brilliant! thank you johnnyvento.

cheers,
dilimanrepublic

Rollover said...

jv, even though I wrote this filter, the original idea for this type of filter was by The Rumpled One -- Avery Horton. The fact that I had studied so much of TRO's work is why I was able to whip this out in <= 2 minutes. I hope it's still making $s for you!

-Chip

CABeachBum said...

Johnny-
Like Yngvai, I couldn't get this to work either. Does it still work for you? Any idea why it's returning that set{} error? Thanks!

johnnyvento said...

I don't know why it's not working for you guys. I provided the update to attempt to solve this situation because I thought the problem resided with not copying all of the text properly. However if this does not solve the situation please email me at johnnyvento@gmail.com and I will send you the text copied straight from my email or from Stockfetcher. I would like to solve this problem because I am getting hits from all over on this and would like it to be working!

DaveH said...

JV sent me the Stockfetcher code by e-mail and it worked. I can see that some code was left out of the above post. I see that the blog allows HTML tags such as a less than sign followed by a b followed by a greater than signs to make bold text. I think that it is interpreting some of the Stockfetcher code as HTML tags and going off in the weeds and losing the code. One could make a version of the code that does not have any less than or greater than signs, but it is probably easier to pass the code via e-mail.

CABeachBum said...

DaveH or JV-
Would one of you mind emailing the code over to me?

Paul said...

What a nice piece of scripting. To help others download without the html problems, just copy the text and take it to a html stripper, I used http://www.zubrag.com/tools/html-tags-stripper.php and then take that text for stockfetcher filter. Thanks for the post.