The
Cup-With-Handle Search Algorithm
Haiku laboratories Technical
memorandum
Copyright © Haiku laboratories 2010
Updated March 2010
The Cup-With-Handle (CwH) Pattern
The Cup-With-Handle (CwH) Pattern
The CwH structure, or pattern, was first described by William O’Neil in 1988 in his book "How to Make Money in Stocks" (See reference [1]). Since then several authors have elaborated on the pattern and its value as an indicator. In his book, O'Neil describes an approach to investing called the CANSLIM method. This method combines technical and fundamental analysis to identify some of the best stocks in a certain cycle. Each letter in the acronym CANSLIM stands for some characteristic of a stock or the market in which it is traded. For example, C stands for the stock's "current quarterly earnings" while M stands for "market direction". The letter I stands for "institutional sponsorship" which is an indication of money flow into or out of a stock, a major aspect of the CANSLIM method. According to the system, only those stocks meeting a set of quantifiable criteria are candidates for purchase. In addition, a stock must exhibit one of three or four different chart patterns that summarize less quantifiable aspects of the system. The most common chart pattern used is the cup-with-handle.

Figure 1. An idealized CwH structure.
Figure 1 shows an idealized CwH pattern showing how both price and volume action are involved in its formation. There are 5 main points on the chart denoted at the days K, A, B, C, and D. The actual CwH pattern is located between points A and D, the cup portion being located between points A and C. Point K denotes the beginning of a setup phase. Starting at point K, the stock's price rises, peaking at Point A, defining the top or left side, of the cup. Point A is the highest point on the chart to date. After peaking at A, the price drops then trades sideways for a while until both price and volume begin their increase at point B. After point B the price continues to rise on increasing volume, forming the right side of the cup. The rise in price and volume both peak at Point C, the pivot point, defining the highest point in the right side of the cup. Then, as the price pulls back on lighter volume, a handle is formed with the most recent day being point D. The CwH pattern is now complete and the buy point will occur when the price breaks above the value at point C, on large volume. This is indicated by point E in the Figure. These, then, are some of the technical requirements that a stock's price-volume chart should meet before it becomes a candidate for a CANSLIM stock.
Here we begin quantifying the requirements given in the last
section. The CwH pattern may be divided
into the four frames, in order:
setup, left-cup, right-cup and handle.
Table 1 gives minimum and maximum allowable lengths for the frames and
their total length.
|
FRAME |
NAME |
MIN LENGTH |
MAX LENGTH |
RANGE |
|
1 |
Setup |
2 |
50 |
K - A |
|
2 |
Left Cup |
20 |
147 |
A - B |
|
3 |
Right Cup |
3 |
25 |
B - C |
|
4 |
Handle |
2 |
30 |
C - D |
|
|
Totals |
27 |
252 |
K - D |
Table 1. CwH pattern components and their length in Tdays
Frame lengths are given in trading days or Tdays, essentially weekdays minus any holidays when exchanges are closed. Depending on the year and where the holidays fall, one year of data is approximately 252 tdays. The length restrictions imposed in Table 1 limit the pattern to a maximum length of 252 and minimum of 27, and help define its overall geometry. They also limit the number of possible patterns to just over four million.
To capture price requirements for the pattern, let PK, PA, PB, PC and PD represent prices at the time points K through D, respectively. Then we can write the requirement that the price at point A exceeds the price at point K as PK < PA. Also, PB < PC and PB < PA for a proper cup, and PD ≤ PC for the handle. We further require that the pivot ratio PC / PA falls in a fixed range, specifically
0.78 ≤ PC / PA
≤ 1.1.
(These are called “high-handle” charts or CANSLIM charts. If the ratio falls in the range 0.25 to 0.78
they are called Low-handles. See [7] for
more on low-handles.) Similarly, the
handle-ratio PD / PC cannot fall below 0.5. (Note that
the current values of the handle-ratio and all other required parameters are
available here.)
Another price requirement is that no price PJ at some point
J within the cup exceeds the line connecting PC and PA. This may be written
,
where A < J < C. The last
price requirement is that the handle shall not drop below the 50% mark between
PB and PC written
PD > 0.5 (PC –
PB).
Figure 2 is an actual CwH
chart found on 09/29/09. The pattern is
shown as a set of 5 red dots in the high-low channel. Note that daily highs are used for each of
these points except PB, which is a low value.

Figure 2. The CwH structure in YHOO. Points at K, A, B,C and D are shown as red
dots. Daily highs and lows are on the
left axis, and volumes are on the right. Chart ends 09/29/09
To quantify the volume requirements for the CwH we use the relative-price-volume, or RPV, which captures a stock's price-volume interaction. A stock's daily RPV value is the fractional change in its closing price from the previous day multiplied by the volume traded that day. RPV is a measure of the stock’s dollar-value that moved on a particular day. If yk denotes the closing price of a stock on day k, the daily relative price change or daily return is defined as
.
Letting v(k) denote the stock’s volume on day k, the daily RPV is
rpv(k) = rkv(k)
A chart of RPV values for the CLCT data in Figure 2 is shown in Figure 3, along with the daily closes for reference. Notice that RPV values are read on the right axis; they are positive on up days and negative on down days. Because of their definition as a product they tend to vary widely. Their large variance prompts the use of logarithms below.

Figure 3. RPV’s for YHOO (blue, right axis)
and its closing prices (green line, left axis).
The average of the positive rpv values over a particular time frame is called the up-relative-price-volume, and denoted URPVn, where n refers to one of the frame numbers 1,2,3,4 in Table 1. Similarly, the DRPVn, the down-relative-price-volume in frame n, is the average of the negative values in the frame, but expressed as a positive number. We will also have need of a stock’s overall average rpv for the latest 50 days, written
,
where the vertical bars indicate absolute value. The first volume requirement is that the stock’s ARPV cannot be zero. The second requirement is that the up-RPV exceeds the down-RPV in frame 3, where price is building up to the pivot. This may be written as a log-ratio:
.
which implies URPV3 > DRPV3.
The third requirement is
,
indicating volume is drying up in the handle. If either of the DRPV’s in these expressions
is zero, substitute the ARPV. The final
requirement is that
,
the URPV during the right-side must exceed the average. Logarithms are used here to reduce the
effects of the extreme values typical of RPV’s.
Besides the criteria just described, there are several more used to
screen for the CwH pattern. To avoid
stocks with bad price characteristics, the minimum closing price is set at
$2.00, over the range of the data. Also
the minimum price-range, defined as the ratio of the highest close to the lowest close, is set
to 1.5. Lastly, to avoid bad volume
characteristics, stocks having a zero-volume day within the last 35 days are
rejected. In summary, there are 15
criteria for being a CwH chart, and any pattern not meeting them all is
ignored.
Once a pattern is found it needs to be ranked against other patterns,
both within the same chart and with other charts. If there is more than one distinct pattern in
a chart, the algorithm selects the highest ranked. Also, depending on market conditions, a scan
may produce over one hundred finds, and ranking helps the trader select the
best charts for further analysis. The
log-ratios R1, R2, R3 are indicators for the accumulation of up-volume. Since this is one of the criteria for a
successful breakout, we define a chart’s rank as
Rank = R1 + R2 + R3
This is, of course, equivalent to the logarithm of the
product of the three ratios themselves.
On 09/29/09, 2248 NASDAQ stocks were screened for the CwH
structure. The resulting 98 finds were
ranked and the top 24 results, those with Rank > 6, are shown in Table
2. Volumes are in thousands. Each stock’s Rank and the Rank components R1,
R2, R3 are shown. The column labeled PVR
holds the pattern’s pivot ratio. The
Setup, Right-Side, Handle and overall pattern length are given in the next four
columns. The Score column contains the
number of distinct CwH patterns that were found. More information about the column headings is
here.
|
Symbol |
Close |
Volume |
Rank |
R1 |
R2 |
R3 |
PVR |
K-A |
B-C |
C-D |
A-D |
Score |
|
CLCT |
5.51 |
10 |
11.84 |
6.01 |
3.01 |
2.82 |
1.05 |
45 |
3 |
10 |
84 |
1 |
|
UTSI |
2.15 |
462 |
9.649 |
3.28 |
2.79 |
3.58 |
1.05 |
47 |
9 |
8 |
80 |
3 |
|
BPFH |
6.65 |
641 |
9.341 |
3.17 |
3.01 |
3.17 |
1.05 |
45 |
3 |
6 |
98 |
1 |
|
ITMN |
15.6 |
257 |
8.835 |
5.66 |
1.9 |
1.27 |
0.92 |
20 |
3 |
11 |
159 |
1 |
|
UEIC |
20.9 |
61 |
8.731 |
2.85 |
3.14 |
2.75 |
0.95 |
46 |
3 |
13 |
99 |
1 |
|
OSTK |
15.1 |
116 |
8.213 |
4.56 |
1.93 |
1.72 |
1.07 |
8 |
5 |
6 |
49 |
2 |
|
RVSB |
3.7 |
9 |
7.971 |
2.13 |
2.86 |
2.99 |
0.98 |
14 |
3 |
18 |
161 |
1 |
|
ARNA |
4.48 |
2584 |
7.92 |
2.11 |
2.47 |
3.34 |
0.8 |
49 |
5 |
7 |
159 |
2 |
|
CCNE |
17.9 |
2 |
7.797 |
3.47 |
3.57 |
0.76 |
1 |
42 |
5 |
2 |
42 |
2 |
|
YHOO |
17.5 |
31600 |
7.554 |
4.57 |
1.84 |
1.14 |
1.01 |
10 |
3 |
8 |
48 |
1 |
|
SIMO |
4 |
318 |
7.43 |
2.72 |
2.11 |
2.6 |
0.96 |
45 |
4 |
4 |
76 |
2 |
|
NGAS |
2.47 |
509 |
7.397 |
1.84 |
3.02 |
2.54 |
0.87 |
42 |
4 |
9 |
101 |
2 |
|
THQI |
7.09 |
994 |
7.246 |
3.23 |
2.47 |
1.55 |
0.84 |
50 |
3 |
4 |
77 |
1 |
|
FCNCA |
156 |
13 |
7.173 |
2.5 |
2.2 |
2.47 |
1.02 |
22 |
3 |
4 |
36 |
1 |
|
ISSC |
5.01 |
34 |
6.755 |
3.06 |
1.6 |
2.1 |
0.99 |
12 |
5 |
14 |
158 |
3 |
|
OYOG |
26.5 |
13 |
6.721 |
4.12 |
1.6 |
1.01 |
1.06 |
24 |
12 |
5 |
63 |
5 |
|
SOHU |
68.5 |
869 |
6.689 |
4.77 |
1.34 |
0.58 |
1.04 |
50 |
3 |
8 |
78 |
1 |
|
MIND |
6 |
31 |
6.573 |
2.98 |
1.94 |
1.65 |
1.06 |
30 |
5 |
9 |
84 |
3 |
|
COGO |
6.2 |
399 |
6.433 |
3 |
1.26 |
2.18 |
0.78 |
39 |
3 |
4 |
109 |
1 |
|
AMZN |
91.7 |
4394 |
6.402 |
2.68 |
2.55 |
1.18 |
1 |
46 |
7 |
4 |
48 |
3 |
|
PALM |
17.4 |
14722 |
6.304 |
2.29 |
1.25 |
2.76 |
1.08 |
45 |
5 |
4 |
63 |
3 |
|
TRAD |
8.28 |
180 |
6.201 |
1.96 |
2.12 |
2.12 |
0.96 |
45 |
3 |
4 |
52 |
1 |
|
|
18.2 |
4451 |
6.091 |
3.63 |
1.37 |
1.09 |
0.97 |
44 |
3 |
9 |
99 |
1 |
|
DRIV |
39.7 |
290 |
6.078 |
2.44 |
2.64 |
1 |
0.97 |
45 |
9 |
3 |
81 |
4 |
Table 2. Top 24 results of a scan of 2248 NASDAQ
stocks in order of their Ranks.
The chart for CLCT, the highest ranked chart, is shown in Figure
4. Its high rank is mostly due to a
large R1 value, corresponding to its URPV3 exceeding its DRPV3 by a factor of
more than 400. This is due in turn to
the short length of frame 3 (only 3 tdays) and the surge in volume in that
frame. A similar situation can be seen
in the Yahoo chart in Figure 2. CLCT is
interesting in that it contains an apparent second CwH pattern within the main
one. The right side of the main CwH
corresponds to a breakout from the inner structure.

Figure 4. Highs, lows and volumes for CLCT. The red points indicate the defining points
for its CwH pattern.
More examples from Table 2 may be seen at CwH
Examples. The screening program
rejects charts that do not meet the required criteria and assigns them a
negative score. Rejection criteria and
their related scores are here. Lastly, a summary of the algorithm’s
parameter values is here.
Using this algorithm, the trader is provided with a list
of stocks whose CwH charts are the best CANSLIM candidates on a purely
technical basis. It is then up to the
trader to research these stocks to determine which have the qualifying
fundamental criteria. This list is a "watch" list, not a
"buy" list. The user must not buy stocks from the list yet, as many
stocks which complete the cup with handle set up, do not break out. From point D they often roll over forming the
right shoulder of a head-and-shoulders topping pattern and fail disastrously.
Using the CANSLIM system from this point the user must wait for these stocks to
break out on significant volume to actually buy them.
References
[1] O'Neil, William J., How to
Make Money in Stocks, McGraw-Hill. 1991
[2] Kuhn, Gregory J., "Back to Basics Trading Stocks"
Technical Analysis of Stocks & Commodities, December 1994.
[3] Kuhn, Gregory J., "The Cup-With-Handle Pattern", Technical
Analysis of Stocks & Commodities, March 1995.
[4] Kuhn, Gregory J., "Trading with the Cup-With-Handle" Technical
Analysis of Stocks & Commodities , July 1995.
[5] Martinelli, Rick [1998]. Pattern
Recognition in Time Series, Technical Analysis of Stocks & Commodities,
January. 1998
[6] Martinelli, Rick and Hyman, Barry, “Cup-With-Handle
And The Computerized Approach”, Technical Analysis of Stocks &
Commodities, January. 1998
[7] Hyman, Barry and Martinelli, Rick, Part 2, Trading Within The Cup,
Technical Analysis of Stocks & Commodities, September 2001
[8] The CANSLIM
Method