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

DirectionXABCD
BullishLowHighLowHighLow (below X) → Buy
BearishHighLowHighLowHigh (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.

LegMeasurementTargetCheck Type
ABRetracement of XA0.786isNear (exact)
BCRetracement of AB0.382–0.886inRange
ADExtension of XA (beyond X)1.27–1.618inRange

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.