PulseHub
OPEN-SOURCE SCRIPT
Updated

Harmonic XABCD Pattern Detector

11 986
Overview

This overlay indicator scans the chart for classic XABCD harmonic formations using pivot-based structure detection. When a valid five-point pattern completes at pivot D, it draws the zigzag legs, labels key ratios, and optionally highlights the Potential Reversal Zone (PRZ) near D.

The script is designed for visual pattern recognition and education. It does not place orders, generate trade signals for automation, or guarantee future price behavior.

Supported patterns

  • Gartley
  • Bat
  • Butterfly
  • Crab
  • Deep Crab
  • Cypher
  • Shark
  • AB=CD
  • Three Drives (7-point structure)


Key features

  1. Strict and Soft modes — Strict uses fixed Fibonacci ratio rules. Soft applies a user-defined percentage tolerance around standard harmonic levels.
  2. PRZ box — Optional orange zone at D showing the projected reversal area.
  3. Structural stop line — Optional stop reference beyond D based on CD leg size and ATR buffer (visual reference only).
  4. Pattern score and confluence — Each completed pattern receives a quality score and a confluence count based on nearby pivot density.
  5. See the Future — When X-A-B-C is complete but D is not yet confirmed, the script can project possible D zones for active setups.
  6. On-chart table — Summary panel with pivot count, detection mode, pending projection status, average pattern score, and recent pattern history.
  7. Alerts — Optional alerts for pattern completion, future zone touch, and possible formation in the projected D zone.


How detection works

The script identifies swing pivots using configurable left/right bar settings, then evaluates consecutive pivot sequences against harmonic ratio rules. A pattern is drawn only after the pivot structure and ratio checks pass the selected mode (Strict or Soft).

Important: Pivot D is confirmed only after the configured Pivot Right Bars have closed. Until then, price action near the projected zone is handled by the See the Future module, not as a completed pattern.

Main settings

  • Pivot Settings — Pivot left/right bars and maximum stored pivots.
  • Filter Settings — Minimum leg size (ATR multiplier) and ATR period.
  • Detection Mode — Strict vs Soft ratio control; Soft tolerance (%).
  • Pattern Filters — Enable or disable individual harmonic types.
  • Visual Settings — Labels, leg ratios, butterfly wings, PRZ, stop line, colors, and history table rows.
  • See the Future — Projected D zones, zone merge, touch markers, and extension length.
  • Storage — Maximum stored patterns for redraw and history.
  • Alerts — Toggle alert conditions for completion and future-zone events.
  • Analytics — Confluence ATR multiplier for pivot clustering near PRZ.


Alerts

Three optional alert conditions are available:

  1. Pattern Completed — a valid XABCD (or Three Drives) formation is detected and drawn.
  2. Future Zone Touched — price enters a projected D zone while XABC is still active.
  3. Possible Formation — price reaches an extremum inside a projected D zone before D is confirmed.


Limitations

  • Harmonic patterns are subjective geometric models. Different pivot settings, timeframes, and tolerance modes will produce different results.
  • Overlapping patterns are filtered, but dense or choppy markets may still produce frequent redraws on setting changes.
  • The optional stop line is a structural visual reference, not a validated risk-management rule.
  • See the Future projections are hypothetical until pivot D is confirmed by the pivot engine.
  • This indicator runs on
    Pine Script®
    and is intended for manual chart analysis on PulseWire.



Disclaimer

This script is provided for informational and educational purposes only. It does not constitute investment advice, financial advice, trading advice, or a recommendation to buy or sell any instrument.

Trading involves substantial risk of loss. Past pattern occurrences do not guarantee future results. Always do your own research and consult a qualified financial professional before making trading decisions.

The author makes no warranties about the accuracy, completeness, or suitability of the detected patterns for any particular market or timeframe.
Release Notes
Comment lines have been edited.
Release Notes
Several bugs in replay mode have been fixed.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by PulseWire. Read more in the Terms of Use.