All indicators

Harmonic Pattern Detection, Prediction, and Backtesting Tool

Oct 14, 2022

Static chart image
SignalsForecastingDashboardPatterns

The Harmonic Pattern Detection, Prediction, and Backtesting Tool indicator automatically identifies, projects, and evaluates XABCD harmonic patterns across multiple timeframes to provide high-probability reversal signals. It streamlines the complex process of harmonic trading by calculating retracement accuracy, defining potential reversal zones (PRZ), and providing a built-in backtesting suite to verify historical performance.

Usage

The Usage section describes how the script can be used, examples should be provided in this section. This tool can be used to identify complete patterns for immediate entry or to monitor developing "potential" patterns for future trade planning.

Pattern Identification

The script scans multiple pivot lengths to find various harmonic structures. Each pattern is assigned a score based on its adherence to theoretical Fibonacci ratios. High-scoring patterns (e.g., above 90%) represent setups where the retracements and leg symmetries closely match harmonic ideals.

Prediction and PRZ

Once a pattern is identified, the tool plots the Potential Reversal Zone (PRZ) using confluence from XA and BC leg retracements. This area acts as the primary zone for anticipating price reversals. The indicator also draws paths toward customizable targets (e.g., .618 AD or 1.272 XA) based on the specific pattern type found.

Backtesting and Statistics

Users can utilize the on-chart results table to assess the success rate of specific patterns under current market conditions. By adjusting the target, stop-loss, and "Pattern Time Limit" settings, traders can see how these variables impact the historical win rate and total return for each harmonic type.

Details

The script utilizes four primary components to calculate a pattern's total score:

  1. Retracement % Accuracy: Measures how closely the legs match theoretical Fibonacci ratios.
  2. PRZ Level Confluence: Evaluates how close the XA and BC projection levels are to one another.
  3. Point D / PRZ Confluence: Measures the proximity of the terminal Point D to the calculated PRZ levels.
  4. Leg Length Symmetry: Compares the time duration (number of bars) of each leg to ensure the pattern is proportional.

A time limit is enforced for backtesting; if price does not reach the target or stop-loss within a set multiple of the pattern's duration, the trade is marked as "timed out" to ensure statistics only reflect price action relevant to the harmonic structure.

Settings

Include

  • Bullish/Bearish: Toggles the visibility of long or short patterns.
  • Potential/Incomplete: Enables the display of patterns that have not yet reached Point D.
  • Only high scoring: Filters out patterns that do not meet the minimum score requirement for entry.
  • Lookback bars: Limits the pattern search to a specific number of recent bars.

Types & Targets

  • Gartley/Bat/Butterfly/Crab/Shark/Cypher: Individual toggles for each pattern type.
  • Target 1 & 2: Dropdown menus to select specific Fibonacci retracements or points (A, B, C) as profit targets for each pattern.

Entry/Stop

  • Enter after Point C/D: Defines the trigger point for a trade entry.
  • Entry window (time limit): Sets how long an entry order remains valid after the entry trigger.
  • Stop: Sets the stop-loss distance based on several methods including % beyond PRZ, % beyond Point D, or Risk:Reward ratios.

Pattern

  • Allowed fib ratio error %: Determines how much deviation from perfect Fibonacci ratios is permitted.
  • Allowed leg length asymmetry %: Sets the tolerance for variations in the time duration of legs.
  • Weight settings: Adjusts how much influence accuracy, PRZ confluence, and Point D confluence have on the final pattern score.

FAQ

How do I interpret the pattern score? The score represents a weighted average of retracement accuracy and PRZ confluence. A higher score indicates a "cleaner" pattern that more strictly follows harmonic theory.

What does the "Pattern time limit" do? It defines the expiration of a trade for backtesting purposes. If price takes too long to hit a target, the pattern is considered less relevant to the eventual price move.

How do I access this tool? 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.