Skip to main content
No. of Recommendations: 42
In post 261672, TopLineFirst (Eric) wrote:
Also, when I attempted to verify your BCCs back to the 1920s, 1930s and 1940s, I discovered lots of cases when the NHNL denominator was zero and I had to go with a difference instead of a ratio.

I'm embarrassed that I never looked at this closely before. Eric is right: When the number of strict new 252-day lowest closes (see http://boards.fool.com/Message.asp?mid=31878464) is zero for nine market days in a row, the denominator of the NHNL Ratio is zero. Since the GTR1 field function ratio defines a division by zero as zero, this means that the mathematically undefined ratio is treated as zero by the backtester, putting the indicator in a bearish state (since zero is less than 1, and less than any other threshold one might use)! This is clearly a bug in the GTR1 formulation of the indicator, which I am correcting in this post.

My excuse for overlooking the possibility of this degenerate case in the NHNL Ratio computation is that I originally formulated the indicator for just the Russell-eligible NASDAQ exchange, which only has the required one-year price history from 19731217 forward. (Russell-eligible stocks are those of security types 10, 11, 18 and 48, that is, ordinary common shares of domestic corporations and REITs.) It so happens that there has never been a case where this universe went nine market days in a row with zero strict new 252-day lowest closes.

Much later I extended the NHNL Ratio back from 19731214 to 19261230 using all Russell-eligible NYSE/AMEX-listed stocks. Over this period, there are 717 market days with degenerate NHNL Ratios, definitely warranting a re-formulation of the BCII indicator in GTR1 code. While I'm at it, I also (1) make a technical change to the universe the indicator is applied to and (2) optimize the cut-off value in BCII.


Share Classes

Before presenting my solution for the bug just described, I ought to explain another step I'll be adding to the new GTR1 formulation of the indicator. There is a previously undocumented (except for the WERResearcher Yahoo! Group) field file called permco.a containing permanent company/issuer numbers. These numbers mostly correspond one-to-one with CUSIP issuer codes (i.e., the first six digits of security CUSIP codes), but they go back to the beginning of the database, before CUSIP existed. Use of permco.a requires a special password, except when it is used as the "group by" argument of an aggregate field function like sum or rank. This exception is made to allow anyone to use the field file for its primary purpose: Screening out secondary share classes for companies with multiple listings within the GTR1 universe.

Another previously undocumented field file, class.a, contains share class numbers (counting up from 1) assigned by the GTR1 backtester. The URL that generates the values in class.a is this: http://gtr1.backtest.org/2013/?!!QlpoMTFBWSZTWQJVqBgAAIifgCI... (A special password is required to run in either backtest or screening mode.) The values of the field labeled "Class" are saved to class.a. As you may be able to tell from the GTR1 code, "Class" is essentially a ranking of a company's issues by 252-day average market value (closing price times security-specific shares outstanding), with a few twists. One of the twists is that ETFs and CEFs always have a class rank of 1. Another twist is that any of a company's share classes that have been trading within the GTR1 universe for a full 252 market days are always ranked higher (with a lower rank number) than any of its share classes that have not.

The following table illustrates some share class assignments:

Ticker Symbol  Company Name                             CUSIP      dspo  permco.a          sho.a       aprc           MktVal           AMV252  Class          cso.a  MktCap = aprc * cso.a
LBTYK LIBERTY GLOBAL PLC CL C G5480U120 2654 45301 581,036,032 35.91 20,865,005,568 26,850,768,896 1 896,491,008 32,192,995,328
LBTYA LIBERTY GLOBAL PLC CL A G5480U104 2969 45301 252,806,000 36.82 9,308,316,672 11,617,287,168 2 874,334,976 32,193,013,760
LBTYB LIBERTY GLOBAL PLC CL B G5480U112 2969 45301 10,474,000 38.20 400,106,816 480,212,448 3 842,748,992 32,193,011,712
LILAK LIBERTY GLOBAL PLC LILAC CL C G5480U153 183 45301 30,774,000 37.75 1,161,718,528 1,183,304,448 4 852,795,008 32,193,011,712
LILA LIBERTY GLOBAL PLC LILAC CL A G5480U138 183 45301 13,000,000 35.22 457,860,000 477,373,632 5 914,054,976 32,193,017,856
OSGB OVERSEAS SHIPHOLDING GROUP INC COM CL B 69036R400 366 225697 7,388,000 2.23 16,475,978 22,868,400 1 280,119,008 624,693,376
OSG OVERSEAS SHIPHOLDING GROUP INC CL A 69036R301 65 225697 311,905,984 1.95 608,216,704 745,644,608 2 320,355,008 624,692,288
BRK-B BERKSHIRE HATHAWAY INC CL B 084670702 5002 540 1,253,479,936 140.11 175,625,076,736 169,192,013,824 1 2,467,585,024 345,733,332,992
BRK-A BERKSHIRE HATHAWAY INC CL A 084670108 9948 540 808,000 210530.00 170,108,239,872 168,181,858,304 2 1,642,000 345,690,275,840


The first thing to notice from the table is that share class letters are irrelevant in the ranking of share classes. For example, Liberty Global's Class C is ranked 1 due to it having the greatest average daily market value of approximately $26.9 billion.

Overseas Shipholding is an interesting case where the primary share class is the one with the smaller market value because the one with the overwhelmingly larger market value lacks 252 market days of price history. The company appears to have gone public for the first time in 2014 with its stock initially trading OTC as OGSRB before it was uplisted to AMEX as OSGB shortly thereafter. It appears to have had a wildly more successful secondary public offering in December with OSG, which will become the primary share class once it has traded for 252 market days.

Berkshire Hathaway is an example where it is essentially a toss-up (perhaps by design) as to which share class is "primary" and which is "secondary", with the slight edge in market value currently making BRK-B primary.

The table also illustrates another previously undocumented field file, cso.a, which contains common shares outstanding figures used for calculating total company market capitalizations. It is designed so that multiplying the actual share price (aprc) of any share class by its value in cso.a produces the company's total market capitalization. The small discrepancies you see in the last column are due to both rounding errors and deliberate "freezing" of the values in cso.a to prevent minor daily fluctuations.

Besides the latter issue, there are a few shortcomings in cso.a to keep in mind:

1. The market values for any OTC common stock are excluded.

2. It is zero for foreign companies with only ADRs listed in the GTR1 universe.

3. I have no way of identifying subsidiary tracking stocks like LILA and LLIAK, and in such (very rare) cases, the total market capitalization calculated from cso.a double counts equity in these subsidiaries. Thus the current market capitalization of Liberty Global is closer to $30.7B than $32.2B.

Also note that cso.a is set equal to sho.a for ETFs and CEFs.

Generally speaking, users on this message board have no reason to either worry about share classes or use cso.a. This is because data providers like SI Pro and Value Line usually only cover one share class per company (except for ETFs and CEFs) and they provide their own common shares outstanding figure for computing total market capitalizations that are compatible with their other fundamental data fields. One should always use these fields in fundamental analysis rather than cso.a.

I have my own uses for cso.a, the main one being to weight companies by total market capitalization within indexes that have been trimmed of secondary share classes. This brings me to the main reason I brought all of this up.


Excluding Secondary Share Classes

The field files permco.a and class.a provide a simple way to ensure that only the most primary share classes pass certain steps of technical analysis or market indicator screens (once again, there is no reason to ever do this in screens using fundamental data). Simply insert the step

(*) rank(class.a,permco.a,stepN) = 1

as stepN to ensure that only the most primary share class passes stepN. Depending on what steps come before stepN, not all of the stocks that pass stepN will necessarily have class rank 1 in class.a, but that may be fine for the application. If one only wants the primary share class at stepN, then simply make stepN

(**) class.a = 1

In the new version of the NHNL indicator I'll be presenting, I will include a step of type (*), which is now standard practice in all of my indicator encoding, but which was not possible when I first introduced the NHNL Ratio on this message board.


The Zero Yield 100

There are a few possibilities for how to fix the bug in my original formulation of Bear Catcher II, and in order to evaluate them, I have used an index of mine that I call the "Zero Yield 100", or ZY100. Its membership is defined daily as follows:

1. Select only ordinary common shares of corporations (domestic or foreign) or ADRs with primary listings on NASDAQ, NYSE, AMEX or Arca.
2. Remove stocks in Fama/French sector 11 of 12 (Financials).
3. Require 252 market days of trading history on exchanges listed in (1).
4. Remove secondary share classes.
5. Remove all stocks with any ex-dividend dates for cash dividends (ordinary or special) within the last 252 market days.
6. Take the largest 100 remaining stocks by total market capitalization (or US ADR float) averaged over the last 100 market days.

The GTR1 URL for the index is http://gtr1.backtest.org/2013/?s19261230lf-1lp-1h1s::MktCapW... Click "Run Screener" to see a list of current constituents (no password is required). Note that I have an additional complicated step between (5) and (6) above that allows the index to start off with only 20 constituents (like the ^DJI) in the 1920s and gradually grow to 100 constituents as the market expanded.

The index is similar in construction to the NASDAQ 100, and it can perhaps be thought of as NDX's psychotic little brother, currently representing about $3.6 trillion versus NDX's $5.2 trillion. To see why it might be described as "psychotic", have a look at its wild swings in 1929, where it provides what is possibly a good simulation of QQQ for the time.

In selecting only stocks that have not paid any dividends for a year, the screen finds companies that are either in trouble, are paying a portion of their profits to shareholders indirectly through share buy-backs, or are holding onto cash for planned acquisitions, capital purchases, etc. By taking only the largest 100 of such companies, the chances are good that the index members are in the latter healthy category of companies with aggressive growth plans. I therefore refer to ZY100 as a "large-cap speculative" index. Indeed, it tends to soar during speculative bubbles (e.g., see its 81% return in 1999) and implode during busts (e.g., see its -93.6% drawdown during the Great Depression), making it suitable for my purpose here. Namely, I want 90-year backtests that reward indicators for remaining bullish through bubbly peaks and quickly going bearish for sharp busts, and I believe ZY100 provides them. The point is not that ZY100 itself is the best investment (though it certainly could be a good one at certain times), but that it stress-tests the indicator where I want it to.


BCII Re-Formulated

I considered many possible solutions to the problem described at the beginning of this post, but the one I've settled upon happens to be the simplest and (in hindsight) the most obvious, so I won't bother presenting the others. All of them, however, attempted to the keep the indicator unaffected by changes in the number of stocks in the market. My solution is simply this: Express the daily number of strict new 252-day highest closes and strict new 252-day lowest closes (for what I mean by "strict", follow my link at the top of this post) as percentages of the number of eligible stocks in the exchange(s). Take the nine-day weighted moving average (weights 9, 8, 7, ... 1) of each and subtract. The indicator is bearish when this difference is negative, and bullish otherwise. (If this description requires clarification, simply run the URL below with "Signal Values" selected, download the report spreadsheet, open it in Excel and scroll down to Daily Signal Values, where all of the calculations should be transparent.)

However, as with the conventional NASDAQ New High/New Low difference (which does not adapt to the size of the market), the optimal cut-off turns out not to be zero, but a negative percentage. The following table summarizes performance statistics for trading ZY100 according to BCII with various percentage point cut-offs for the NH/NL difference:


            Trading ZY100 with BCII (param0% cut-off), Zero Lag, 19261230-20160324

param0 CAGR GSD(20) GDD(20; 0%) GDDD3 MDD UI(20) Sharpe(20) Beta(20) TI(20) AT
-100.00 7.53 34.28 21.47 22.39 -93.63 44.00 0.28 1.39 5.92 0.95
0.20 10.65 20.49 11.90 12.13 -68.13 22.23 0.45 0.56 15.41 3.87
0.15 10.95 20.38 11.76 11.86 -63.92 20.90 0.47 0.56 15.77 3.91
0.10 11.48 20.30 11.57 11.41 -62.38 19.49 0.49 0.57 16.30 3.75
0.05 11.95 20.72 11.62 11.14 -61.72 18.15 0.51 0.62 15.90 3.60
0.00 11.70 20.81 11.91 11.80 -67.46 20.06 0.49 0.62 15.54 3.64
-0.05 11.72 20.96 12.09 11.76 -64.84 19.83 0.49 0.62 15.40 3.59
-0.10 12.13 21.14 12.16 11.30 -63.58 18.74 0.51 0.64 15.66 3.59
-0.15 12.34 21.42 12.25 11.32 -66.47 18.43 0.51 0.66 15.61 3.59
-0.20 12.93 21.71 12.30 10.78 -62.75 17.08 0.54 0.68 15.92 3.54
-0.25 13.05 21.70 12.29 10.82 -63.58 16.43 0.54 0.68 16.04 3.53
-0.30 13.27 21.79 12.17 10.68 -59.76 16.14 0.55 0.70 15.91 3.47
-0.31 13.37 21.78 12.04 10.68 -56.54 16.24 0.55 0.70 16.01 3.45
-0.32 13.44 21.79 12.04 10.66 -56.70 16.21 0.55 0.70 16.09 3.44
-0.33 13.56 21.81 12.07 10.69 -56.70 16.29 0.56 0.70 16.24 3.43
-0.34 13.29 21.92 12.23 10.81 -59.26 16.49 0.54 0.71 15.85 3.43
-0.35 13.42 21.90 12.21 10.72 -59.61 16.24 0.55 0.71 15.99 3.44
-0.36 13.59 21.88 12.18 10.58 -57.02 15.93 0.56 0.71 16.19 3.42
-0.37 13.44 22.03 12.30 10.66 -59.53 16.35 0.55 0.71 15.92 3.42
-0.38 13.56 22.00 12.23 10.57 -59.53 16.13 0.55 0.71 16.06 3.40
-0.39 13.55 21.98 12.26 10.61 -59.53 16.40 0.55 0.71 16.09 3.34
-0.40 13.76 22.02 12.25 10.46 -59.53 16.15 0.56 0.71 16.29 3.30
-0.41 13.66 22.13 12.31 10.53 -59.59 16.11 0.56 0.72 16.10 3.32
-0.42 13.65 22.23 12.40 10.68 -59.45 16.22 0.56 0.72 16.03 3.30
-0.43 13.58 22.29 12.46 10.74 -59.74 16.31 0.55 0.72 15.92 3.31
-0.44 13.76 22.34 12.45 10.72 -56.84 16.34 0.56 0.73 16.02 3.33
-0.45 13.93 22.38 12.43 10.70 -56.84 16.38 0.57 0.73 16.20 3.30
-0.46 13.86 22.46 12.50 10.67 -56.84 16.17 0.56 0.73 16.07 3.29
-0.47 13.75 22.54 12.58 10.70 -60.31 16.23 0.56 0.74 15.90 3.26
-0.48 13.73 22.56 12.60 10.80 -60.31 16.26 0.56 0.74 15.88 3.31
-0.49 13.54 22.74 12.83 11.09 -62.72 16.14 0.55 0.74 15.64 3.30
-0.50 13.41 22.84 12.95 11.28 -62.72 16.68 0.54 0.75 15.35 3.29
-0.55 13.16 23.57 13.25 11.71 -62.96 17.38 0.52 0.79 14.36 3.38
-0.60 12.99 23.72 13.29 11.87 -64.96 17.63 0.51 0.80 14.03 3.30
-0.65 12.66 23.93 13.40 12.09 -69.16 18.55 0.49 0.81 13.51 3.33
-0.70 12.45 24.15 13.68 12.27 -70.40 19.16 0.48 0.82 13.18 3.29
-0.75 12.38 24.21 13.76 12.23 -71.19 19.54 0.48 0.82 13.07 3.26
-0.80 12.21 24.24 13.80 12.35 -72.13 20.44 0.47 0.83 12.87 3.22
-0.85 12.15 24.26 13.83 12.46 -73.12 20.75 0.47 0.83 12.74 3.24
-0.90 11.98 24.37 13.96 12.56 -73.54 20.82 0.46 0.84 12.46 3.23
-0.95 11.93 24.55 14.01 12.70 -70.76 20.99 0.46 0.85 12.25 3.36
-1.00 12.08 24.63 13.99 12.67 -69.68 20.81 0.46 0.86 12.36 3.25
http://gtr1.backtest.org/2013/?lf-1lp-1h1::gprc%281%29gt0:ca...

The top row in bold gives results for buying and holding ZY100 with no timing. The other row in bold shows where I believe the sensibly optimized cut-off value is, namely -0.40%. This variant adds more than six points to CAGR, slashes GDDD3 (my geometric version of Jim's DDD3 that treats losses as compounding, as I prefer) by more than half, slashes Ulcer Index by almost two thirds, and doubles Sharpe ratio. However, all of the variants of BCII provide significant improvement over buying and holding ZY100. Overall, BCII is very successful at taming this wild beast.


New Recommended BCC URL

The new BCC (Bear Catchers Combined) URL that incorporates the bug fix for BCII in the form of NHNLDiff is this: http://gtr1.backtest.org/2013/?lf-1lp-1h1::BCC:gt0:SMADiff:i... While I'm at it, I've changed the name of "BCIII" to "DBE" (for Jim's "Dying Bullish Euphoria"), but more importantly, I've also applied the optimized cut-off of -0.4% for BCII (NHNLDiff). lohill can use whatever cut-off he wants for his BCC reports by adjusting it in the field definition

BCC: linear(1,if(SMADiff>0,1,0),2,if(NHNLDiff>-0.4,1,0),4,DBE) ,

but if he does use a value other than 0, such as the -0.4 value I have applied, then past signals will change, right up through the present, where BCII is now in a bullish state, not a bearish state.

Robbie Geary
Print the post  

Announcements

What was Your Dumbest Investment?
Share it with us -- and learn from others' stories of flubs.
When Life Gives You Lemons
We all have had hardships and made poor decisions. The important thing is how we respond and grow. Read the story of a Fool who started from nothing, and looks to gain everything.
Contact Us
Contact Customer Service and other Fool departments here.
Work for Fools?
Winner of the Washingtonian great places to work, and Glassdoor #1 Company to Work For 2015! Have access to all of TMF's online and email products for FREE, and be paid for your contributions to TMF! Click the link and start your Fool career.