Harmonic Patterns

Oct 28, 2023

Static chart image
Fibonacci
Patterns
Pivot 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 access on the following platforms
tradingviewSymbolTradingView
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

ninjatraderNinjaTrader
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

metatrader4MetaTrader 4/5
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

thinkorswimThinkorswim
Open in your browser

This in-app browser is not compatible with Get Access from the library.

Tap the menu (...) at the top of your screen and select "Open in Browser", "Open in Safari", or "Open in Chrome" to continue.

Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.

Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.

As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.

Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.com TradingView® has no affiliation with the owner, developer, or provider of the Services described herein.

Market data is provided by CBOE, CME Group, BarChart, Massive, CoinAPI. Select U.S. equities data is provided through Massive. CBOE BZX real-time U.S. equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.

This does not represent our full Disclaimer. Please read our full disclaimer.

© 2026 LuxAlgo Global, LLC.