Pattern Recognition Advanced

Harmonic Patterns Indicator

Identify high-probability reversal zones using XABCD harmonic patterns. Detect Gartley, Butterfly, Bat, and Crab formations with precise Fibonacci measurements for NinjaTrader 8.

Overview

Harmonic patterns are geometric price structures based on Fibonacci ratios that identify potential reversal zones with remarkable precision. These patterns were first documented by H.M. Gartley in 1935 in his book "Profits in the Stock Market," and later expanded significantly by Scott Carney who discovered additional patterns and refined the Fibonacci ratio requirements.

All harmonic patterns share a common five-point XABCD structure. The X point marks the beginning of the pattern, followed by an initial move to A, a retracement to B, an extension or retracement to C, and finally the completion at D. What makes each pattern unique is the specific Fibonacci ratios that must exist between these legs.

Traders use harmonic patterns for several key purposes: identifying high-probability reversal zones before they occur, achieving precise entry points with well-defined risk levels, and managing risk effectively through the Pattern Completion Zone (PCZ). Unlike many technical indicators that react to price, harmonic patterns are predictive in nature, allowing traders to anticipate where reversals may occur.

Key Benefits

  • Predictive reversal zones based on mathematical Fibonacci relationships
  • Precise entry points with clearly defined stop-loss levels
  • Multiple profit targets using Fibonacci retracements of the AD leg

Key Patterns

Gartley Pattern

The Gartley pattern, also known as the "Gartley 222" or "perfect pattern," is the most common harmonic formation and serves as the foundation for understanding all other harmonic patterns. First described by H.M. Gartley, this pattern represents a natural market rhythm of impulse and correction.

The defining ratios for a valid Gartley pattern are: the AB leg must retrace approximately 61.8% of the XA leg, the BC leg should retrace between 38.2% and 88.6% of the AB leg, and critically, the CD leg must complete at the 78.6% retracement of the XA leg. This 78.6% level at point D is what distinguishes the Gartley from other patterns and creates the Potential Reversal Zone (PRZ).

The Gartley is considered a moderate extension pattern because the D point completes within the original XA range. This creates favorable risk-to-reward ratios as stops can be placed just beyond the X point, while targets aim for retracements of the AD leg.

Butterfly Pattern

The Butterfly pattern is an extension pattern discovered by Bryce Gilmore and later refined by Scott Carney. Unlike the Gartley, the Butterfly's D point extends beyond the X point, making it ideal for catching reversals at new highs or lows.

The key ratios for the Butterfly pattern are: AB must retrace exactly 78.6% of XA (a deeper retracement than the Gartley), BC retraces 38.2% to 88.6% of AB, and CD extends to 127% to 161.8% of the XA leg. This extension means point D will be beyond point X, which is why Butterflies often appear at significant market turning points.

When trading Butterfly completions, initial profit targets are typically set at 38.2% of the AD leg, with extended targets at 61.8%. Because D extends beyond X, traders should be prepared for potentially larger reversals when this pattern completes successfully.

Bat Pattern

The Bat pattern, discovered by Scott Carney in 2001, is often considered the most reliable harmonic pattern due to its deep retracement characteristics. The pattern gets its name from its visual appearance when plotted on a chart, resembling the wings of a bat.

What distinguishes the Bat pattern is its ratio structure: AB retraces only 38.2% to 50% of XA (a shallower initial retracement), BC retraces 38.2% to 88.6% of AB, and most importantly, CD completes at the 88.6% retracement of XA. This 88.6% level is the defining characteristic of the Bat pattern.

The deep 88.6% retracement creates a tight Pattern Completion Zone (PCZ), which is why the Bat is favored by many harmonic traders. The tight PCZ allows for precise stop placement just beyond the 88.6% level, creating excellent risk-to-reward ratios when the pattern validates.

Crab Pattern

The Crab pattern, also discovered by Scott Carney, features the most extreme extension of all harmonic patterns. It is known for identifying reversal points at market extremes where other patterns may have already failed.

The Crab's defining ratios are: AB retraces 38.2% to 61.8% of XA, BC retraces 38.2% to 88.6% of AB, and the CD leg extends to a precise 161.8% extension of the XA leg. This extreme extension means the Crab pattern completes the farthest from the X point of any standard harmonic pattern.

Because of its extreme extension, the Crab pattern requires patience and discipline. However, when valid Crab patterns complete and reverse, they often produce significant moves. The 161.8% extension level acts as a powerful reversal zone, particularly when confluent with other technical levels.

Professional Harmonic Scanner

Auto-detect all harmonic patterns with real-time alerts, pattern completion zones, and automated Fibonacci measurements.

Learn More

How to Trade Harmonics

Pattern Completion Zone (PCZ)

The Pattern Completion Zone, also known as the Potential Reversal Zone (PRZ), is where the D point should complete based on the pattern's Fibonacci requirements. This zone is calculated by combining the relevant retracement or extension levels from multiple legs. A tighter PCZ generally indicates a higher probability setup.

Entry Strategy

The most reliable approach to trading harmonic patterns is to wait for D point completion combined with a confirmation candlestick. This might be a hammer or shooting star at the PCZ, an engulfing pattern, or any reversal candlestick that shows rejection from the completion zone. Confirm D point reversals with Volume Profile levels showing HVN support for additional confluence.

Stop Placement

Stops should be placed just beyond the PRZ to account for potential price spikes while limiting risk. For Gartley and Bat patterns, this typically means placing stops beyond point X. For Butterfly and Crab patterns, stops go beyond the relevant extension level that defines the D point.

Take Profit Targets

Standard profit targets for harmonic patterns are based on Fibonacci retracements of the AD leg: 38.2% for the initial target, 50% for the secondary target, and 61.8% for extended targets. Many traders take partial profits at each level and trail stops to lock in gains.

Pattern Failure

Harmonic patterns fail when price moves significantly beyond the PRZ without reversing. For Gartley and Bat patterns, failure is typically defined as price exceeding 113% of the XA leg. For extension patterns like Butterfly and Crab, failure occurs when price exceeds approximately 200% of XA. Recognizing failure early prevents holding losing positions hoping for a reversal.

NinjaScript Implementation

The following NinjaScript code provides a conceptual framework for harmonic pattern detection. Full implementations require robust swing point identification and ratio validation across all legs.

namespace NinjaTrader.NinjaScript.Indicators
{
    public class HarmonicPatternConcept : Indicator
    {
        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description = "Harmonic Pattern Concept";
                Name = "HarmonicPatternConcept";
                IsOverlay = true;
            }
        }

        protected override void OnBarUpdate()
        {
            if (CurrentBar < 50) return;

            // Find swing points (simplified)
            // X, A, B, C, D points would be identified here

            // Calculate Fibonacci retracement
            // double xaLeg = Math.Abs(priceA - priceX);
            // double abRetracement = Math.Abs(priceB - priceA) / xaLeg;

            // Check Gartley ratios
            // if (abRetracement >= 0.618 * 0.95 && abRetracement <= 0.618 * 1.05)
            // {
            //     // Potential Gartley AB leg
            // }
        }
    }
}

Note: Full harmonic detection requires swing point identification and ratio validation across all legs. Production implementations include tolerance thresholds and pattern scoring algorithms.

Settings

Harmonic pattern indicators typically offer several configuration options to customize detection sensitivity and display preferences.

  • Pattern Types: Select which patterns to detect (Gartley, Butterfly, Bat, Crab, or all)
  • Ratio Tolerance: Acceptable deviation from ideal Fibonacci ratios (typically 5% is standard)
  • Swing Strength: Number of bars required to confirm swing points (higher values = fewer patterns)
  • Display Options: Show or hide projected completion zones, pattern labels, and Fibonacci levels
  • Alert Settings: Configure notifications for pattern formation, completion, or failure

Frequently Asked Questions

What are harmonic patterns?

Harmonic patterns are geometric price structures that use Fibonacci ratios to identify potential reversal zones. They consist of five points (XABCD) where specific retracement and extension ratios must align for the pattern to be valid.

How do I identify a Gartley pattern?

A Gartley pattern requires AB to retrace 61.8% of XA, BC to retrace 38.2-88.6% of AB, and CD to retrace 78.6% of XA. The D point is your potential entry zone where price may reverse.

What Fibonacci ratios define harmonic patterns?

Each pattern has specific ratio requirements. Gartley uses 78.6% at D, Bat uses 88.6%, Butterfly extends to 127-161.8%, and Crab extends to 161.8%. The AB and BC legs have ratio ranges that must also be met.

Which harmonic pattern is most reliable?

The Bat pattern is often considered most reliable due to its deep 88.6% retracement creating a tight Pattern Completion Zone (PCZ). The Gartley is most common and easiest to identify. Reliability depends on overall market context.

How do I trade harmonic pattern completion?

Wait for price to reach the Pattern Completion Zone (D point), then look for a reversal candlestick confirmation. Enter after confirmation, place stop beyond the PRZ, and target 38.2%, 50%, or 61.8% retracements of the AD leg.

Can harmonic patterns be automated in NinjaTrader?

Yes, NinjaScript can automate harmonic pattern detection by identifying swing points and calculating Fibonacci ratios between them. However, most traders prefer visual confirmation before taking trades.