The Cup & Handle, popularized by William O'Neil, combines a rounded bottom (the cup) with a brief downward drift or consolidation (the handle) before breaking out to new highs. The cup should be a smooth U-shape, not a sharp V.
A 41-day cup from a rim of 110 down to 90 and back: 20 deep. The handle dips to 105, a quarter of the cup’s depth — under the usual one-third limit. Day 50 closes at 112, above the rim; the target is 110 + 20 = 130.
The example data
A U from 110 (day 0) down to 90 (day 20) and back to 110 (day 40), then a handle down to 105 (day 47) and a close of 112 on day 50, as daily closes; high and low are half a point either side of each bar.
- O’Neil’s version has conditions this code leaves out — a prior uptrend, the cup’s length, volume drying up in the handle — and they change which cups qualify.
- A deep handle, or one that falls below the cup’s midpoint, usually means the base has failed.
- Like every measured move, the target is a rough guide.
c = df['close'] cup = c.iloc[:41] rim, bottom = min(cup.iloc[0], cup.iloc[-1]), cup.min() depth = rim - bottom handle = c.iloc[41:-1] shallow = rim - handle.min() < depth / 3 # handle retraces under a third of the cup breakout = c.iloc[-1] > rim target = rim + depth
Assumes import numpy as np, import pandas as pd, and a DataFrame df with columns open, high, low and close for the data above.
- How to Make Money in Stocks, W. J. O’Neil, McGraw-Hill, 1988
- Encyclopedia of Chart Patterns (2nd ed.), T. N. Bulkowski, Wiley, 2005 — success and failure rates from large counts of patterns
Last reviewed October 2026 · How this site checks its content · Report a mistake