+1 888 340 6572 GET STARTED

Patterns > Cup & Handle

Article/Author: "Cup-With-Handle And The Computerized Approach", Rick Martinelli & Barry Hyman, S&C Magazine, Traders Tips, 10/1998

Download: Cuphndl.ela

File Includes: Indicator - Cup & Handle

Category: Indicator > Patterns

Description:

Cup and handle patterns were first identified by William J O'Neil in his book "How To Make Money In Stocks". The cup and handle is a longer term continuation pattern, normally observed on weekly charts.

The cup and handle forms as an intermediate/secondary cycle correction before the primary cycle resumes its up-trend. The pattern is a form of (ascending) triangle.

The cup pattern should take a minimum of 7 weeks to form. There is no upper limit with some patterns taking as long as a year. The handle may form over one or two weeks but may also take several months.

Usage:

When the indicator identifies a cup-with-handle formation, it will place the following characters on the chart for identification of the key points:

K: Beginning of the setup phase
LS: Left-hand side of the cup formation
RS: Right-hand side of the cup formation
B: Bottom of the cup.

Once the key points have been identified, the indicator will also plot a horizontal line at the level of the right-hand side of the cup. The horizontal line will continue to plot until either the upward price breakout occurs or the close falls below the acceptable level. If an upward price breakout occurs, a red dot will be plotted at the close.

This indicator will generate an alert for two situations. The first is when a valid cup-with-handle formation has been identified. The second is when a price breakout above the right-hand side of the cup formation has occurred. "AlrtLen", the only input for this indicator, determines the number of bars after the occurrence of either of the two above criteria
that an alert will be generated.




Inputs:

AlrtLen - number of bars after the occurrence of either of the two above criteria that an alert will be generated.

EasyLanguage Code:
INPUTS: ALRTLEN(4);

VARS: SH(0), LFTSIDE(0), LFTLEN(0), B(0), CC(0), AVGVAL(0), CUP(FALSE), CUPBAR(0), RGTSIDE(0);
VARS: HIVOLUME(0), AVGVOLUME(0), CHP(0), KBAR(0), RS(0), RSLINE(0), ALERTRESET(0);

SH = SWINGHIGH(1, CLOSE, 1, 2)[2];
AVGVAL = AVERAGE(CLOSE, 5);
IF AVGVAL > AVGVAL[1] THEN
CC = CC + 1
ELSE
CC = 0;
HIVOLUME = HIGHEST(VOLUME, 5);
AVGVOLUME = AVERAGE(VOLUME, 50);

IF SH <> -1 AND HIVOLUME > AVGVOLUME[2] AND HIGHEST(CLOSE, 3) <= SH THEN BEGIN
LFTSIDE = SH;
LFTLEN = 0;
FOR VALUE1 = 145 DOWNTO 25 BEGIN
IF CLOSE[VALUE1] >= LFTSIDE AND HIVOLUME[VALUE1-2] > AVGVOLUME[VALUE1] THEN BEGIN
LFTSIDE = CLOSE[VALUE1];
LFTLEN = VALUE1;
END;
END;
IF LFTLEN <> 0 THEN BEGIN
IF HIGHEST(CLOSE, LFTLEN-8)[4] < SH THEN BEGIN
CHP = TEXT_NEW(DATE[LFTLEN], TIME[LFTLEN], CLOSE[LFTLEN], "LS");
TEXT_SETSTYLE(CHP, 2, 1);
CHP = TEXT_NEW(DATE[3], TIME[3], SH, "RS");
TEXT_SETSTYLE(CHP, 2, 1);
B = CLOSE[CC[3]+3];
CHP = TEXT_NEW(DATE[CC[3]+3],TIME[CC[3]+3],B,"B");
TEXT_SETSTYLE(CHP, 2, 0);
IF LOWEST(CLOSE, 35)[LFTLEN] <= B THEN BEGIN
KBAR = LOWESTBAR(CLOSE, 30)[LFTLEN];
CHP = TEXT_NEW(DATE[KBAR],TIME[KBAR],CLOSE[KBAR],"K");
TEXT_SETSTYLE(CHP, 2, 0);
CUP = TRUE;
CUPBAR = BARNUMBER[3];
RGTSIDE = SH;
ALERTRESET = 0;
RS = SH;
RSLINE = TL_NEW(DATE[3], TIME[3], RS, DATE, TIME, RS);
END;
END;
END;
END;

IF CUP AND BARNUMBER > CUPBAR + 3 THEN BEGIN
TL_SETEND(RSLINE, DATE, TIME, RS);
IF CLOSE < (RGTSIDE*.80) THEN
CUP = FALSE
ELSE
IF CLOSE > RGTSIDE AND VOLUME > AVGVOLUME THEN BEGIN
PLOT1(CLOSE, "C&H_BRKOUT");
ALERTRESET = 0;
CUP = FALSE;
END;
END;

ALERTRESET = ALERTRESET + 1;
IF ALERTRESET <= ALRTLEN THEN
ALERT = TRUE;