Butterfly Pattern
The Butterfly is a 5-point XABCD harmonic pattern where D extends beyond X rather than retracing to it. This makes it an extension pattern — D is the most extreme price point, so the stop-loss is placed beyond D rather than beyond X.
XABCD Structure
| Direction | X | A | B | C | D |
|---|---|---|---|---|---|
| Bullish | Low | High | Low | High | Low (below X) → Buy |
| Bearish | High | Low | High | Low | High (above X) → Sell |
The PRZ is the price band between C and D.
Fibonacci Ratios
FIB_TOLERANCE = 0.05 (5%) applies to all isNear checks.
| Leg | Measurement | Target | Check Type |
|---|---|---|---|
| AB | Retracement of XA | 0.786 | isNear (exact) |
| BC | Retracement of AB | 0.382–0.886 | inRange |
| AD | Extension of XA (beyond X) | 1.27–1.618 | inRange |
D target selection: if the AD ratio < 1.45 the target is 1.27; otherwise 1.618. The closer target drives the isNear error used in confidence.
Confidence
Confidence is the mean accuracy of the AB and AD legs:
confidence = 1 − (abError + adError) / 2
Clamped to [0, 1].
SL/TP
Because D is the extreme point (beyond X), the SL is placed beyond D — not beyond X.
- SL: beyond D, ±0.1% buffer
- TP1: D + 0.382 × |A − D|
- TP2: D + 0.618 × |A − D|
- TP3: A price
Levels are scalable via per-pattern TradingConfig multipliers. See TP Level Calculation.
Related
- Crab Pattern — also an extension pattern with D beyond X
- Swing Point Detection
- Markets — Pattern Detection Overview