xabcdPattern

The XABCD Pattern is a harmonic drawing tool that connects five points (X, A, B, C, D) to form patterns like Gartley, Bat, Butterfly, Crab, Shark and more. Traders use it to identify potential reversal zones based on Fibonacci ratios between legs.

Syntax

xabcdPattern(pointX, pointA, pointB, pointC, pointD, styles?)

Parameters

pointX (PricedData) · First anchor, the start of the pattern. pointA (PricedData) · Second point, ending the XA leg. pointB (PricedData) · Third point, ending the AB leg. pointC (PricedData) · Fourth point, ending the BC leg. pointD (PricedData) · Fifth point, final completion of the pattern. styles (XABCDPatternStyleOverrides) · Visual and ratio settings:

  • fillBackground (boolean) · Fill the pattern area.

  • transparency (number) · Background transparency (0–100).

  • showLabels (boolean) · Show leg labels (XA, AB, BC, CD).

  • line (LinesLevels without coeff) · Style for connecting lines (linestyle, linewidth, color).

  • background (RGBAColor | BaseColors) · Color for filled area.

Return Value

(string) · The drawing ID of the created XABCD Pattern.

Example

Every 80 candles we draw an XABCD harmonic pattern, using five past swing points.

//@version=1
init = () => {
  indicator({ onMainPanel: true, format: 'inherit' });
};

onTick = () => {
  if (index % 80 === 0) { // draw every 80 bars
    // 1) Define five anchors
    const X = newPoint(time(100), low(100));
    const A = newPoint(time(80),  high(80));
    const B = newPoint(time(60),  low(60));
    const C = newPoint(time(40),  high(40));
    const D = newPoint(time(20),  low(20));

    // 2) Style the pattern
    const style = {
      fillBackground: true,
      transparency: 80,
      showLabels: true,
      line: { linestyle: 0, linewidth: 2, color: color.blue },
      background: color.rgba(0, 128, 255, 0.2)
    };

    // 3) Draw the pattern
    xabcdPattern(X, A, B, C, D, style);
  }
};

Tips

  • Use significant pivots for X, A, B, C, D so the pattern forms naturally.

  • Look for Fibonacci confluence (e.g., AB = 0.618 of XA, CD = 1.27–1.618 of XA) to validate real harmonic setups.

  • Patterns work best on higher timeframes where noise is reduced.

Warning

  • Don’t force random points into the pattern — invalid ratios will lead to misleading setups. Always choose true swing highs and lows.

Good Practice

  • Keep your style in a single const style for easy adjustments.

  • Validate completion at point D with other tools (Fibonacci retracements, RSI divergence, volume) for stronger signals.

Last updated