PROTECTED SOURCE SCRIPT

Advanced Harmonic Pattern Detector v6

17
Advanced Harmonic Pattern Detector and Backtesting Suite (Pine Script v6)

Overview

The Advanced Harmonic Pattern Detector and Backtesting Suite is an original TradingView indicator designed to identify harmonic price patterns using Fibonacci-based ratio validation. The script automatically detects harmonic structures in real time, plots their defining price legs, and highlights potential reversal zones derived from Fibonacci confluence.

In addition to pattern visualization, the indicator includes an integrated backtesting module that allows traders to evaluate historical pattern performance directly on the chart using configurable trade parameters.

The indicator is applicable across multiple asset classes, including forex, crypto, stocks, indices, and futures, and can be used on any timeframe.

Supported Harmonic Patterns

The indicator detects both bullish and bearish variations of the following patterns:

Gartley

Bat

Alternate Bat

Butterfly

Crab

Deep Crab

Shark

AB=CD

Three-Drive

Five-Zero

Each pattern is validated using predefined Fibonacci ratio relationships between the XA, AB, BC, and CD legs. Ratio tolerances are pattern-specific to balance accuracy and practical signal frequency.

Pattern Detection Logic

The detection engine is built around objective price-structure analysis and includes:

Automatic swing high and swing low identification

Fibonacci ratio validation for each pattern leg

Support for both retracement-based and extension-based patterns

Pattern confirmation using completed price data only

Once a pattern is confirmed, it is fixed on the chart and does not repaint.

Potential Reversal Zones (PRZ)

For each validated pattern, the indicator calculates and plots a Potential Reversal Zone based on Fibonacci confluence across relevant pattern legs. These zones are displayed directly on the chart and are intended to help traders anticipate areas where price may react, rather than signaling guaranteed reversals.

Bullish and bearish patterns are visually distinguished to maintain clarity during live analysis.

Integrated Backtesting and Performance Analysis

The indicator includes a built-in backtesting component that allows traders to simulate pattern-based trades using historical data. Features include:

Pattern-triggered trade simulation

User-defined stop-loss and take-profit levels

Adjustable risk-to-reward parameters

Trade count, win rate, and summary statistics

Results displayed in an on-chart performance table

This functionality enables traders to evaluate harmonic pattern behavior statistically within the same tool used for analysis.

Customization and Controls

Users can customize the indicator by:

Enabling or disabling individual harmonic patterns

Toggling bullish and bearish detection independently

Adjusting Fibonacci tolerance thresholds

Configuring stop-loss and take-profit ratios

These options allow the script to be adapted to different markets, instruments, and trading approaches.

Intended Use

This indicator is designed as a technical analysis and decision-support tool for traders who incorporate harmonic patterns and Fibonacci structure into their analysis. It is not a buy or sell signal generator and should be used alongside broader market context and risk management.

Disclaimer

This indicator is intended for educational and analytical purposes only and does not constitute financial advice. Always apply proper risk management and confirm analysis with additional tools.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.