Cup handle buy sell
Marks cup-and-handle breakouts; at default settings the buy marker can never draw.
Looks for a cup-and-handle shape on closes over the last 100 bars. The price must touch near the high, drop to near the low, climb back near the high, then hold a channel with matching slopes or a converging triangle for handle_hold bars. The buy test wants a close above the high times (1 + band), but at the default band of 0 that can never be true, because the high already includes the current close.
How to read it
- Only buy markers draw, on the candles. There is no line and no pane.
- A marker needs the full sequence: a touch of the high, a drop to the low, a return to the high, then a tight channel or triangle that holds for handle_hold bars.
- With default settings the chart shows no markers at all.
What it outputs
- Buy
- Marks the bar where the handle completes and the close is above the 100-bar high times (1 + band). The default band of 0 makes that impossible.
- Sell (unused)
- Never draws. The sell side is hard-wired to nothing.
When it fires
On the bar the channel or triangle has held for handle_hold bars, after a rim, a base and a second rim. The buy also needs the close above the 100-bar high times (1 + band) on that bar, so at band 0 it cannot draw.
Settings
- rim_eps
- How close the close must be to the 100-bar high to count as a rim touch, as a fraction (0.004 is 0.4%). Wider lets more touches count, so setups start more often. Negative values never match, so no setup can start.
- base_eps
- How close the close must be to the 100-bar low to count as the cup bottom. Wider lets shallower dips count, so more setups start. Negative values never match, so no setup can start.
- handle_hold
- How many consecutive bars the channel or triangle shape must hold. Higher waits for a longer tight shape and fires less often; 1 accepts a single bar of shape.
- band
- Sets the buy line at the 100-bar high times (1 + band). At 0 no close can clear it, so no buy. Negative values put the line under the high, so a close near it fires (-0.002 is within 0.2%). Positive values make the buy harder.
- confirm_days
- How many consecutive bars the buy test must hold before a marker draws. 1 draws on the first bar. Higher values make a buy very unlikely, because the handle stage lasts about one bar.
Pitfalls
- At default band 0 the buy cannot fire, because the 100-bar high includes the current close. The zero events on a month of SPY one-minute bars come from this, not rarity.
- The handle stage lasts one bar, so the buy test runs only on the bar the hold count is reached.
- Slope thresholds (0.5 percentage points for channels, 0.05% for triangles) are fixed in code, not parameters, and no stage has a time limit.