by Rick Martinelli & Barry Hyman
Haiku Laboratories Technical Memorandum, January 2001
Copyright (c) 2001

Note: this document has been published essentially unchanged in the September 2001 issue of Technical Analysis of Stocks and Commodities, under the title Trading Within the Cup.

The Screening Algorithm
Some Examples


In our previous article, Cup-With-Handle and the Computerized Approach (TASC 10/98), we described an automated approach to identifying stocks that have set up the “cup-with-handle” structure with proper price and volume characteristics. The impetus for writing such an algorithm is that on any given day there may be new stocks that “break out” of a cup-with-handle pattern, but by the time investors are aware of them they could have already broken out to levels well above the pivot point (see Figure 1).  Identifying stocks that are set up correctly allows the trader to be watching such stocks before they break out, and makes it possible to buy these stocks just as they are breaking above the pivot (on sufficient volume).  It is critical to buy a stock not more than a few percent above the pivot price because in many cases stocks tend to pull back to and test the pivot area before continuing their advance.  If a tight stop-loss discipline is followed, the trader who chases a stock too far above the pivot point is likely to get stopped out on a subsequent pullback to, or just below, the pivot point.

Figure 1 shows an idealized cup-with-handle structure, including both its daily closing price and volume characteristics.  Following an advance, point A identifies the start of the left side of the cup.  The price then falls, begins building a base and trades essentially sideways until reaching point B, which is the end of the bottom of the cup.  It then begins to rise on increasing volume until hitting resistance at the pivot point C, completing the cup. As the price pulls back under the resistance, and must do so on decreasing volume, a proper handle forms on the right side of the cup between points C and D. After point D the price finally begins its breakout run.  At point E a position may be taken, just as the price exceeds the pivot price on sufficient volume.  Note: If the position is not taken until point F, and a suitable stop-loss level established, the trader may be stopped out on a subsequent pullback at point G and miss a subsequent dramatic advance.

In the CANSLIM approach, William O’Neil recommends buying stocks only as they break out of the cup-with-handle to new highs.  But what about traders who prefer to begin taking a position in a stock as it is setting up, rather than waiting for it to hit a new high?  Some traders would like to begin taking positions in stocks earlier in their base formations so that they already own shares prior to the breakout.  Many investors and money managers use the technique whereby they begin building a position in a stock which has strong accumulation characteristics earlier in the base, with the intention of “topping off” their positions as the momentum investors start getting in causing the stock to break out to a new high.  One method of doing so is to identify stocks with patterns similar to the cup-with-handle but where the handles and pivot points are lower than the left side of the cup. The idealized chart in Figure 1 may be called a “high-handle” version of a cup-with-handle.  In a high-handle pattern, the pivot point C is not allowed to drop below a fixed level, determined here as roughly the top 20% of the range between point A and the bottom of the cup.  Figure 2 shows an idealized example of what an early-stage, “low-handle” candidate might look like.  Here the pivot point C is well below the ~20% level at approximately 60% down from point A.   

Buying early goes hand-in-hand with another commonly followed technical method described by Stan Weinstein in his book “Secrets for Profiting in Bull and Bear Markets”.  There the author describes the ideal time to begin taking a position in a stock as when the stock breaks out from what he calls the resistance level in a Stage 1 base to begin a Stage 2 advance, and does so on rising volume.  An idealized example of this behavior is shown in Figure 3.  Weinstein’s approach fits neatly with the concept of buying stocks within the cup-with-handle base that exhibit strong accumulation.  That is, after the price falls and forms a bottom where selling volume dries up, the price begins turning up on rising volume.  It then pulls back on lighter volume prior to resuming its ascent on increasing volume.  Such action looks very much like a cup-with-handle where the handle is at a level below the left side of the cup, as in Figure 2.

It is quite common for this low-handle action, i.e. pullbacks in the base on light volume after advances on heavy volume, to occur more than once as the stock builds the right side of the cup.  This action is very constructive and offers entry points for traders and investors. Keep in mind, however, this method is contrary to O’Neil’s principle that stocks that have not cleared all prior resistance are apt to face “overhead supply” resistance as the stock moves up.  Nevertheless, in practice, many traders take early positions as stocks fight their way through the resistance.  Combining O’Neil’s approach with Weinstein’s approach, both of which are applications of basic technical analysis principles, provides a systematic method of building positions in stocks prior to their prices breaking out to new highs. 

When using either of these methods, it is always recommended that tight stop losses be used.  The breakout prices, including the lower pivot prices, in a constructive pattern often tend to be subsequent areas of support.  As described above, after purchasing a stock, it is recommended to enter a tight sell stop order at a price just below support. Therefore, again, it is ideal to buy stocks just as their prices clear these pivot points, and not to pay more than that level.  If purchased just above the pivot price, as the stock pulls back to the pivot, or even just below it intra-day, the trader will be less apt to get stopped out on a this kind of normal pullback to support.  In order to be able to buy at just the right point, one needs to already have identified these set-ups.  We have created a computer algorithm to find them.

The Screening Algorithm

In our previous article we described an algorithm for finding and ranking stocks whose charts had set up with the high-handle version of a cup-with-handle structure (Figure 1).  The algorithm placed certain restrictions on price-volume and timing.  For example, the handle was constrained to be at least two days long and no longer than 30 days, and up-volume had to exceed down-volume in the right side of the cup.  One important criterion, mentioned above, was that the pivot point price could not be greater than the price at point A, nor fall more than ~20% of the range between point A and the bottom of the cup.  The screening process applied the algorithm to a database of between eight and nine thousand stocks and any stocks meeting all of the algorithm’s criteria were culled to create a list of  “finds”.  These finds were then ranked by an indicator that compared up to down relative-price-volume, our measure of buying power, or strength if you will.

To find stocks whose charts have set up with the low-handle version of a cup-with-handle structure (Figure 2) the algorithm was modified to include charts in which the pivot point was below the ~20% level but above the 75% level.  These finds make up another list, separate from the high-handles.  In addition, the criterion for ranking all stocks was tweaked slightly and are now ranked by their Accumulation Ratio (AR), defined here as the ratio of each stock’s total up-volume to down-volume over the past 50 trading days.

Some Examples

Table 1 shows the top ten stocks from the low-handle screening of a database of 8,399 stocks on June 23, 2000.  The stocks are sorted by AR.  On this particular day, there were actually 113 stocks that screened out with low-handles.  Of the top ten AR stocks, four of them subsequently broke above the pivot point with sufficient volume on the day of the breakout and thus qualified to have been bought there.  Those were ENDO, CAMP, MVIS and TARO. Two of those four, ENDO and MVIS, subsequently rolled over and the trader should have been stopped out with small losses.  The other two, TARO and CAMP, followed through after breaking above their pivot points for gains of 50% and nearly 100% in the weeks following their “low-handle breakouts”.  


Close Price

50-day  Vol Avg

Accum Ratio

Handle  Height

Handle Length

Right  Cup







































































Table 1. Top 10 stocks from the low-handle screening on 6/23/00, ranked by accumulation ratio.   Handle Height is the pivot point ratio, and Handle Length and Right Cup length are expressed in days.

There are some important subtleties in the charts of these two stocks.  But first, lets examine the market and the overall usefulness of such an algorithm.  In late June on the date of this example, the NASDAQ had formed a low-handle chart itself, following the requisite “follow-through day” that the CANSLIM method defines. Since the majority of stocks follow the overall trend of the market, one would expect to find many stocks with low-handles at this point.  Indeed the program identified 113 of them on that day, a comparatively large number.  What is also important to note is that subsequent to the May-June upturn in the NASDAQ, the rally fizzled and the market rolled over.  One would expect that most stocks would again follow the market and stocks bought on the upswing would have ended up as losses.  Taking positions in the four stocks found on this particular day when they broke out, getting stopped out of the losers at 7-8% losses, and holding the gainers, would have yielded two solid winners.  In other words, the program helps narrow down the universe of stocks to a small number of possible break-out candidates.  Each stock’s price-volume action determines which candidates are to be bought, and finally a simple stop-loss discipline will helps weed out the weaker ones. 

As the weak stocks get weeded out,  only the strong ones remain.  This leads us to the concept of building a position.  Take a close look a the charts of TARO and CAMP.  In the case of TARO (Figure 4), the first low-handle formed from June 14 through July 19.  On July 20, the stock broke above the $12.50 pivot point, set on June 14, on almost five times average daily volume.  That was the first buy point.  The stock rallied up to the $15 level and built a higher low-handle there.  On August 11 the stock broke above the $15.13 pivot point but the volume was not sufficient.  The following day, however, the volume was nearly three times the 50-day average volume and the price was still within the range where position could have been increased.  For the subsequent two weeks the stock finally established a true high-handle, at nearly the same level as the previous high set back in January.  On August 30 the stock broke above the pivot point of $16.38 on nearly three times average daily volume making it the third buy point.  The final shares in the position should have been added at that time, right as the purists and the momentum investors began buying their first shares.

Once a stock’s chart has formed a handle and has been found by the screening process, it may also be found on subsequent days while the handle continues to form.  If it is a low-handle chart there is also the possibility of multiple handles forming on the way to breaking out to a new high.  Such was also the case with CAMP, shown in Figure 5.  It was first detected by the screening process on June 13 and continued to appear on the screenings through June 19.  There were a total of three distinct times when the stock could have been bought, two low-handle points at $32 on June 21 and at $36.50 on June 28, and the final breakout above $46.56 on July 7. 

Note that on July 14, just 5 days after the final breakout, CAMP broke down on its highest single day volume in months, falling below $43.00.  That was a clear sell signal.  For investors who only bought the stock after it had finally cleared all resistance, at a price just above $46.56, they would have sold their position at a loss.  But for investors who traded within the cup-with-handle using the techniques described in this paper, and bought CAMP at all 3 points described, they would have closed out their position with a total gain, netting gains of more than $10 (better than 31% gain) and $6 (better than 16%) on the first two purchases and a small loss on the final buy.  Since most stocks follow the direction of the overall market, trading within the cup-with-handle is an excellent way to improve one’s trading success in markets other than strong bull markets.

Figure 1.  An idealized cup-with-handle pattern, showing two possible buy points and their stop loss levels.

Figure 2.  An idealized low-handle version of the cup-with-handle pattern.

Figure 3.  An example of a chart breaking above a Stage 1 resistance level to a Stage 2 advance.  See also Chart 1-6 in Weinstein’s book.

Figure 4.  Cup-with-handle pattern for TARO showing a low-handle followed by a high-handle, and their respective pivot and buy points.

Figure 5.  Cup-with-handle pattern for CAMP showing two low-handles followed by a high-handle, and their respective buy points.