Harmonic Patterns Based Supertrend
Jan 9, 2023

The Harmonic Patterns Based Supertrend indicator adapts the logic of harmonic patterns into a trend-following tool to simplify market direction identification. It automatically scans for patterns across the last five confirmed pivots and generates trailing stop-loss levels that behave similarly to a standard Supertrend.
Usage
The tool is used to identify trend shifts and provide dynamic support or resistance levels based on harmonic geometry. When the script detects a bullish pattern, it calculates a bullish zone that acts as a trailing floor; conversely, a bearish pattern establishes a bearish ceiling.
To mimic standard Supertrend behavior, the bullish zone will only move upward and the bearish zone will only move downward regardless of subsequent price action until a trend reversal is confirmed. This helps traders stay in a trend while minimizing noise. Examples of usage include:
- Trend Confirmation: Using the line color and position to confirm the prevailing market bias.
- Trailing Stops: Setting stop-loss orders based on the plotted Supertrend line.
- Reversal Trading: Identifying potential entry points when the price crosses the Supertrend line following a confirmed harmonic pattern.
Details
The script executes by deriving a Zigzag foundation and scanning for harmonic patterns across the most recent five confirmed pivots. Because it relies on confirmed pivots, patterns are not created on the absolute latest price movement (which is unconfirmed and shifting). This results in a slight delay in pattern appearance, which is intentional to ensure the reliability of the trend zones.
The core logic uses specific Fibonacci-based zones derived from the pattern's "Base" (minmax, correction, or CD leg) to set the Supertrend distance. The implementation ensures that even if new patterns form with different local lows or highs, the Supertrend logic preserves the directional integrity of the current trade.
Settings
- Base: Determines the structural anchor for calculating the trend zones. Options include 'minmax', 'correction', and 'CD'.
- Entry %: Sets the percentage distance for the entry threshold within the harmonic zone.
- Stop %: Adjusts the percentage distance for the stop-loss calculation relative to the base.
- Use Close Prices: When enabled, the indicator uses closing prices instead of high/low wicks for trend calculations.
- Error %: Defines the allowable deviation for pattern detection; higher values find more patterns with lower precision, while lower values increase accuracy.
- Zigzag: Sets the length/sensitivity of the underlying Zigzag used for pivot identification.
- Log Scale: If checked, patterns and ratios are calculated on a logarithmic scale.
- Display Harmonic Patterns: Toggles the visibility of the detected harmonic pattern shapes on the chart.
FAQ
How do I access Harmonic Patterns Based Supertrend?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Why do the patterns appear with a delay?
Patterns are based on confirmed Zigzag pivots. Since the most recent price point is still moving, the indicator waits for a pivot to be confirmed before drawing a pattern to ensure the trend zones are stable and accurate.
Can I use this for intraday trading?
Yes, the indicator is versatile and can be applied to any timeframe. Users should adjust the "Zigzag" and "Error %" settings to match the volatility of their specific timeframe.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.