StockFetcher Forums · Filter Exchange · Alternate Gap Statistics Report<< >>Post Follow-up
lctrcbddha
28 posts
msg #68667
Ignore lctrcbddha
modified
10/22/2008 10:26:02 AM

Many ways to skin a "gap"...

This is just a re-implementation of TRO's excellent "Fade the Gap Statistics" report, with some bells a whistles added.

I set out to add some modifications of my own to TRO's original. Eventually I started from scratch, re-engineering the internal logic as to how the statistics are derived. But the end result is not the filter I wanted it to be. My initial implementation turned out to have significant logic issues, and was scrapped. This version is inelegant and, frankly, not as good as TRO's original.

Along the way I added a couple of user-adjustable knobs in order to get statistics for more cases than just open-to-previous-close. The gap offset tuneable, such that a gap must be of a certain size to be considered. Also tuneable is how far within the previous close the stock must reach to be considered a successful fill. These can be combined, for example to show the success rate of gaps of at least 1.00 that filled to within .50 of the previous close. See the notes within the filter for details.

Hopefully some will find this report useful. Many thanks to TRO for the inspiration and the original filter.

Fetcher[
/*

GAPS FILLED REPORT
Inspired by TRO's Gap Fill Statistics

NOTES:

min_gap_up
min_gap_down

Specifies that the gap must be of at least a certain size. For example if set to +/- .50, the report would show how many gaps of at least .50 filled. Default is + 0.00 and - 0.00 respectively.

min_up_fill
min_down_fill

Specifies how close the price must come to the previous close to be considered successful gap fill. For example if set to + 0.50 and - 0.50 respectively, the gap would be reported as filled if the price came within .50 of the previous close. Could also be used to specify that the price must exceed the previous close. Default is 0.00, meaning the price must reach the previous close.

EXAMPLE:

min_gap_up set to "close 1 day ago + 1.00"
min_gap_down set to "close 1 day ago - 1.00"
min_up_fill set to "close 1 day ago + 0.50"
min_down_fill set to close 1 day ago - 0.50"

The resulting report would show gaps of at least 1.00 which filled to at least .50 of the previous close.

EXAMPLE:

min_gap_up set to "close 1 day ago + 0.50"
min_gap_down set to "close 1 day ago - 0.50"
min_up_fill set to "close 1 day ago - 0.50"
min_down_fill set to close 1 day ago + 0.50"

The resulting report would show gaps of at least .50 which filled to beyond .50 of the previous close.

Another interesting exercise is to apply the report to a single stock, setting min_gap_up and min_gap_down to its average gap.

*/


/* VARIABLES - see notes above */

apply to symlist( )

set{MIN_GAP_UP, close 1 day ago + 0.00}
set{MIN_GAP_DOWN, close 1 day ago - 0.00}

set{MIN_UP_FILL, close 1 day ago + 0.00}
set{MIN_DOWN_FILL, close 1 day ago - 0.00}

/* CALCULATIONS */

set{GAP_UP_NET, open - MIN_GAP_UP}
set{GAP_UP_SIGN, sign(GAP_UP_NET)}

set{GAP_DOWN_NET, MIN_GAP_DOWN - open}
set{GAP_DOWN_SIGN, sign(GAP_DOWN_NET)}

set{FILL_UP_NET, MIN_UP_FILL - low}
set{FILL_UP_SIGN, sign(FILL_UP_NET)}

set{FILL_DOWN_NET, high - MIN_DOWN_FILL}
set{FILL_DOWN_SIGN, sign(FILL_DOWN_NET)}

set{GAP_UP_FILLED, GAP_UP_SIGN + FILL_UP_SIGN}
set{GAP_DOWN_FILLED, GAP_DOWN_SIGN + FILL_DOWN_SIGN}

set{GAPPED_UP, count(GAP_UP_SIGN above 0,100)}
set{GAPPED_DOWN, count(GAP_DOWN_SIGN above 0,100)}

set{GAP_UP_FILLS, count(GAP_UP_FILLED above 1, 100)}
set{GAP_DOWN_FILLS, count(GAP_DOWN_FILLED above 1, 100)}

set{GAP_UP_WIN_PCT, GAP_UP_FILLS / GAPPED_UP}
set{GAP_DOWN_WIN_PCT, GAP_DOWN_FILLS / GAPPED_DOWN}

set{GAPS_FILLED, GAP_UP_FILLS + GAP_DOWN_FILLS}

set{NET_GAP, open - close 1 day ago}
set{ABS_GAP, abs(NET_GAP)}

/* SELECTION */

market is nasdaq
close above 40
average volume(30) above 1000000

/* RESULTS */

add column GAPS_FILLED {Gaps Filled}
add column cema(ABS_GAP,100) {Avg Gap}
add column separator
add column GAPPED_UP {Gapped Up}
add column GAP_UP_FILLS {Filled}
add column GAP_UP_WIN_PCT {Win %}
add column separator
add column GAPPED_DOWN {Gapped Down}
add column GAP_DOWN_FILLS {Filled}
add column GAP_DOWN_WIN_PCT {Win %}
add column separator
sort by column 5 descending

/* DISPLAY */
chart type is ohlc
chart-time is 100 days
]



lctrcbddha
28 posts
msg #68710
Ignore lctrcbddha
modified
10/23/2008 10:44:52 AM

Bugs fixed by starting from scratch again. This one works accurately, but the internal logic is awfully inelegant.

Another knob I'd like to add, but am not up to at the moment, is to report how many times the stock moved at least x.xx in the direction of the gap from the open. This is different than the "to within x.xx of the previous close" knob already in the report.

lctrcbddha
28 posts
msg #68856
Ignore lctrcbddha
modified
10/28/2008 12:42:53 PM

Version 2:

* Added a "minimum profit" knob.

* Combined knobs such that gaps down and up don't have to be defined separately.

* Reports display both fill successes and minimum profit successes.

* Renamed variables, hopefully they will make more sense to anyone modifying, reverse engineering or troubleshooting.


Fetcher[
/*

GAPS FILLED REPORT, version 2

Inspired by TRO's Gap Fill Statistics

NOTES:

min_gap

Specifies that the gap must be of at least a certain size to be considered. For example if set to 0.50, the report would only consider days in which the the price gapped up or down by .50 as having gapped at all. Default is 0.00, meaning any gap up or down is considered a gap day.

min_fill

Specifies how close the price must come to the previous close to be considered successful gap fill. For example if set to 0.50, the gap would be reported as successfully filled if the price came within .50 of the previous close. Could also be used to specify that the price must exceed the previous close by setting to a negative number. Default is 0.00, meaning the price must reach the previous close to be considered a successful fill.

min_profit

Specifies a minimum fill from the opn to be considered profitable. This differs from min_fill, which considers how close the price comes to the previous close. Rather, min_profit considers how far from the opening the price must go to be considered profitable. For example if set to 1.00, the gap would considered profitable if the price moved in the direction of the gap by at least 1.00 regardless of whether the gap actually filled or not. Default is 0.00, meaning any movement from the open is considered profitable.

These two, min_fill and min_profit, are independent of each other, meaning that one does not have to be successful for the other to considered successful. However, each day must still satisfy min_gap.

EXAMPLE A:

min_gap set to 0.00
min_fill set to 0.00
min_profit set to 0.00

The resulting report would show all gaps of any size which filled to the previous close. Since min_profit is set to 0, all gaps are reported as profitable.

EXAMPLE B:

min_gap set to 1.00
min_fill set to 0.50
min_profit set to 0.00

The resulting report would show gaps of at least 1.00 which filled to at least within .50 of the previous close.

EXAMPLE C:

min_gap set to 1.00
min_fill set to 0.00
min_profit set to 1.00

The resulting report would show gaps of at least 1.00 which filled to the previous close, and also gaps of at least 1.00 which moved at least 1.00 in the direction of the gap. Keep in mind that the two success rates may differ, since a gap of 1.50 which fills to within .25 of the previous close would not be considered a successful fill but would be considered a successful profit.

EXAMPLE D:

min_gap set to 1.00
min_fill set to 0.50
min_profit set to 0.50

The resulting report would show gaps of at least 1.00 which filled to within .50 of the previous close, and also gaps of at least 1.00 which moved at least .50 in the direction of the gap. Again, the two success rates may differ.

*/


/* TUNEABLE VARIABLES - see notes above */

set{MIN_GAP, 0.00}
set{MIN_FILL, 0.00}
set{MIN_PROFIT, 0.00}

apply to symlist( )
market is nasdaq
close above 40
average volume(30) above 1000000


/* TARGETS */

set{MIN_OPEN, close 1 day ago + MIN_GAP}
set{MAX_OPEN, close 1 day ago - MIN_GAP}

set{SHORT_FILL, close 1 day ago + MIN_FILL}
set{LONG_FILL, close 1 day ago - MIN_FILL}

set{SHORT_PROFIT, open - MIN_PROFIT}
set{LONG_PROFIT, open + MIN_PROFIT}

/* GAPS UP */

set{GAP_UP_NET, open - MIN_OPEN}
set{GAPPED_UP, sign(GAP_UP_NET)}
set{GAPS_UP, count(GAPPED_UP > 0, 100)}

set{SHORT_FILL_NET, SHORT_FILL - low}
set{SHORT_PROFIT_NET, SHORT_PROFIT - low}

set{LOW_BELOW_FILL, sign(SHORT_FILL_NET)}
set{LOW_BELOW_PROFIT, sign(SHORT_PROFIT_NET)}

set{GAP_UP_AND_FILL, GAPPED_UP + LOW_BELOW_FILL}
set{GAP_UP_AND_PROFIT, GAPPED_UP + LOW_BELOW_PROFIT}

set{GAPS_UP_WITH_FILLS, count(GAP_UP_AND_FILL > 1, 100)}
set{GAPS_UP_WITH_PROFITS, count(GAP_UP_AND_PROFIT > 1, 100)}

/* GAPS DOWN */

set{GAP_DOWN_NET, MAX_OPEN - open}
set{GAPPED_DOWN, sign(GAP_DOWN_NET)}
set{GAPS_DOWN, count(GAPPED_DOWN > 0, 100)}

set{LONG_FILL_NET, high - LONG_FILL}
set{LONG_PROFIT_NET, high - LONG_PROFIT}

set{HIGH_ABOVE_FILL, sign(LONG_FILL_NET)}
set{HIGH_ABOVE_PROFIT, sign(LONG_PROFIT_NET)}

set{GAP_DOWN_AND_FILL, GAPPED_DOWN + HIGH_ABOVE_FILL}
set{GAP_DOWN_AND_PROFIT, GAPPED_DOWN + HIGH_ABOVE_PROFIT}

set{GAPS_DOWN_WITH_FILLS, count(GAP_DOWN_AND_FILL > 1, 100)}
set{GAPS_DOWN_WITH_PROFITS, count(GAP_DOWN_AND_PROFIT > 1, 100)}

/* OVERALL */

set{TOTAL_GAPS, GAPS_UP + GAPS_DOWN}

set{GAPS_WITH_FILLS, GAPS_UP_WITH_FILLS + GAPS_DOWN_WITH_FILLS}
set{GAPS_WITH_PROFITS, GAPS_UP_WITH_PROFITS + GAPS_DOWN_WITH_PROFITS}

set{GAP_UP_FILL_PCT, GAPS_UP_WITH_FILLS / GAPS_UP}
set{GAP_UP_PROFIT_PCT, GAPS_UP_WITH_PROFITS / GAPS_UP}

set{GAP_DOWN_FILL_PCT, GAPS_DOWN_WITH_FILLS / GAPS_DOWN}
set{GAP_DOWN_PROFIT_PCT, GAPS_DOWN_WITH_PROFITS / GAPS_DOWN}

set{NET_GAP, open - close 1 day ago}
set{ABS_GAP, abs(NET_GAP)}


/* RESULTS */

add column TOTAL_GAPS {Gaps}
add column GAPS_WITH_FILLS {Fills}
add column GAPS_WITH_PROFITS {Profit}
add column cema(ABS_GAP,100) {Avg Gap}
add column separator
add column GAPS_UP {Gaps Up}
add column GAPS_UP_WITH_FILLS {Fill}
add column GAP_UP_FILL_PCT {F %}
add column GAPS_UP_WITH_PROFITS {Prof}
add column GAP_UP_PROFIT_PCT {P %}
add column separator
add column GAPS_DOWN {Gaps Down}
add column GAPS_DOWN_WITH_FILLS {Fill}
add column GAP_DOWN_FILL_PCT {F %}
add column GAPS_DOWN_WITH_PROFITS {Prof}
add column GAP_DOWN_PROFIT_PCT {P %}
add column separator
sort by column 6 descending


/* DISPLAY */

chart type is ohlc
chart-time is 100 days

draw gapped_up
draw gap_up_and_fill
draw gap_up_and_profit

draw gapped_down
draw gap_down_and_fill
draw gap_down_and_profit
]



chetron
2,817 posts
msg #68857
Ignore chetron
10/28/2008 12:54:52 PM

thanx for sharing.

TheRumpledOne
6,411 posts
msg #68858
Ignore TheRumpledOne
modified
10/28/2008 12:59:24 PM

Thanks for sharing.

What NEW information does this show?

I can't seem to figure it out.

I look at AAPL and don't see anything new.

Not busting your chops, just asking for clarification.

Thanks.





lctrcbddha
28 posts
msg #68859
Ignore lctrcbddha
10/28/2008 1:17:40 PM

By default, there is no new information. It mimics your report, and will show the same information.

But if you edit any or all of the variables min_gap, min_fill, min_profit you'll get a whole new world of statistics.

StockFetcher Forums · Filter Exchange · Alternate Gap Statistics Report<< >>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.