OPEN-SOURCE SCRIPT
Actualizado Harmonic XABCD Pattern Detector

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
Key features
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
Alerts
Three optional alert conditions are available:
Limitations
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
- Strict and Soft modes — Strict uses fixed Fibonacci ratio rules. Soft applies a user-defined percentage tolerance around standard harmonic levels.
- PRZ box — Optional orange zone at D showing the projected reversal area.
- Structural stop line — Optional stop reference beyond D based on CD leg size and ATR buffer (visual reference only).
- Pattern score and confluence — Each completed pattern receives a quality score and a confluence count based on nearby pivot density.
- 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.
- On-chart table — Summary panel with pivot count, detection mode, pending projection status, average pattern score, and recent pattern history.
- 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:
- Pattern Completed — a valid XABCD (or Three Drives) formation is detected and drawn.
- Future Zone Touched — price enters a projected D zone while XABC is still active.
- 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 and is intended for manual chart analysis on TradingView.
Pine Script®
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.
Notas de prensa
Comment lines have been edited.Notas de prensa
Several bugs in replay mode have been fixed.Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Love for AlgoTrading
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Love for AlgoTrading
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.