OPEN-SOURCE SCRIPT

Harmonic Patterns [kingthies]

123
Harmonic Patterns [kingthies]


This indicator scans price swings for classic X-A-B-C-D harmonic patterns and plots the structure plus a PRZ (Potential Reversal Zone) to help you frame areas where reactions are statistically more likely. It supports both bullish and bearish setups and can trigger alerts when a new D pivot confirms a pattern.


What it does
  • Builds a pivot-based swing map (ZigZag-style) using a configurable Pivot Length.
  • Evaluates the most recent 5 swing points (X, A, B, C, D) against harmonic ratio rules with a user-defined tolerance.
  • Detects: Gartley, Bat, Butterfly, Crab, Deep Crab, Cypher, Shark (loose).
  • Draws the pattern legs (X-A-B-C-D), labels the detection with ratio readouts, and projects a PRZ using 3 target levels (derived from XA/BC logic per pattern).
  • Offers two rendering modes:
    • Best only: picks the closest match (lowest score) to reduce clutter.
    • Show all: plots every valid match (uses filled PRZ boxes to keep object usage under control).


PRZ (Potential Reversal Zone)
  • PRZ is built from three target levels and expanded into a zone.
  • Optional padding uses ATR (ATR multiplier) to widen/narrow the zone for volatility.
  • Display modes: Off, Box, Lines, Both.
  • Zones can be extended forward by a configurable number of bars to keep the area visible as price develops.


How to use
  1. Start with Confirm only when D pivot forms enabled (recommended) to reduce false positives while patterns are still forming.
  2. Adjust Pivot Length based on timeframe:
    Lower values = more swings, more signals, more noise.
    Higher values = cleaner structures, fewer signals.
  3. Use Ratio Tolerance to control strictness:
    Lower tolerance = fewer, higher-confidence matches.
    Higher tolerance = more matches, potentially lower quality.
  4. Treat harmonics as context, not a standalone entry system:
    • Look for confluence (HTF levels, structure, volume, momentum/RSI divergence, etc.).
    • Use your own confirmation and risk plan (invalidations beyond PRZ / beyond D).


Settings overview
  • Swings (Pivot ZigZag)Pivot Length: pivot sensitivity.
    Use Wicks: uses High/Low; if off, uses Close.
    Max Stored Swings: limits stored pivots for performance/object control.
  • Harmonic DetectionRatio Tolerance (%): allowed deviation around ideal ratios.
    Confirm only when D pivot forms: reduces repaint-like behavior.
    When multiple match: Best only vs Show all.
  • Pattern Filters enable/disable each pattern type.
  • PRZPRZ Display: Off / Box / Lines / Both.
    PRZ Padding (ATR multiplier): volatility-adjusted zone padding.
    PRZ Extend (bars): how far to project the zone.
  • Visuals
    • Draw Legs: draws X-A-B-C-D.
    • Show Pattern Label: prints pattern name, direction, ratios, and score.
    • Label Offset: shift label forward if you want more space.


Alerts
  • “Bullish/Bearish Harmonic (Any)” triggers on any detected pattern.
  • Per-pattern alerts are included for each supported pattern type.


Notes
  • This indicator is educational and intended to assist with pattern recognition and confluence mapping.
  • Harmonic patterns do not guarantee reversals—always manage risk and confirm with your own process.

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.