All indicators

Harmonic Patterns

Oct 28, 2023

Static chart image
FibonacciPatternsPivot Based (Retrospective)

The Harmonic Patterns indicator automatically identifies and visualizes harmonic price structures based on specific Fibonacci ratio alignments. By calculating consecutive Fibonacci relationships between swing points, this tool helps traders pinpoint potential reversal zones where historical patterns are likely to repeat.

Usage

The script serves as an automated technical analysis tool for identifying complex XABCD patterns. It utilizes a Zigzag mechanism to determine swing points and then evaluates the ratios between these points to validate specific harmonic structures.

Core Features

  • Automated Pattern Detection: Identifies multiple harmonic patterns including Bat, Alt Bat, Butterfly, Crab, Deep Crab, Gartley, Shark, and Cypher.
  • Bullish & Bearish Variants: Every detected pattern is categorized by its directional bias, with customizable colors and background fills.
  • Visual Analysis: Includes optional Zigzag lines and "HHLL" labels to clarify the underlying price structure.
  • Pattern Labeling: An optional diamond label displays a summary of detected patterns, including counts and the time of the most recent occurrence.

Details

Harmonic trading relies on the premise that financial markets exhibit geometric price patterns governed by Fibonacci ratios. This indicator quantifies these movements into four distinct legs (X to A, A to B, B to C, and C to D).

The script implements a "Fixed value leg offset" to increase the flexibility of detection. Since perfect Fibonacci touches are rare in live markets, this offset creates a calculation range (e.g., 88.6% +/- a user-defined percentage) to ensure high-probability setups are not ignored due to minor price discrepancies.

Settings

Zigzag Setup

  • Left bars: The number of bars required to the left of a high or low to confirm a pivot.
  • Right bars: The number of bars required to the right of a high or low to confirm a pivot.
  • Zigzag color / Width: Aesthetic controls for the Zigzag structure.
  • Plot Zigzag: Toggles the visibility of the connecting Zigzag lines.
  • Plot HHLL labels: Toggles labels for Higher Highs, Higher Lows, Lower Highs, and Lower Lows.

Harmonic Pattern Setup

  • Deviation %: Adds a buffer to the pivot range of each leg to account for market noise.
  • Ignore XD leg calculations: Allows the user to bypass the final leg ratio check for pattern identification.
  • Fixed value leg offset %: Defines the percentage range used to calculate Fibonacci levels for fixed-leg patterns, making identification more practical in volatile markets.
  • Show Pattern Labels: Enables the informative summary label on the chart.
  • Pattern-Specific Visibility: Individual toggles for each pattern type (e.g., Bullish Bat, Bearish Shark) including style and color customization.

FAQ

How do I interpret the detected patterns?

When a pattern like a "Gartley" or "Butterfly" is highlighted, it indicates that the current price action has completed a specific Fibonacci sequence, suggesting a potential trend reversal at the "D" point.

Can I adjust the sensitivity of the detections?

Yes, by modifying the "Left bars" and "Right bars" in the Zigzag Setup, you can change whether the script focuses on short-term noise or long-term macro structures.

How can I access Harmonic Patterns?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.