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 200 candles we draw an XABCD harmonic pattern, using five past swing points.

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

onTick = () => {
  if (index % 200 === 0) { // draw every 200 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);
  }
};

Result

circle-info

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.

triangle-exclamation

Warning

circle-check

Good Practice

Last updated