Ultimate ZigZag

1 754
Hello friends,

Ultimate ZigZag is a market structure toolkit that combines ZigZag, swing points, market structure, fractals, trendlines, Fibonacci retracements, and swing analytics into a single indicator.

Each of these tools analyzes the same underlying concept: significant price swings. Instead of calculating those swings independently, every module in this script shares one confirmed pivot engine. This keeps every visual element and calculation synchronized, and avoids the contradictions that come from running several separate indicators that each detect swings slightly differently.

The result is a compact environment where market structure, trendlines, Fibonacci retracements, fractals, and swing statistics are all built from the same sequence of confirmed pivots. That means one consistent read on price action, instead of stacking four or five indicators that quietly disagree with each other.

🛠️ How It Works

The indicator first identifies confirmed swing highs and lows using configurable left/right pivot lookbacks. A pivot needs a set number of bars sloping away from it on both sides before it's accepted. Once a pivot is confirmed, it becomes the shared data source every other module in the script reads from.

This means every module (ZigZag, market structure, fractals, trendlines, Fibonacci retracements, and swing metrics) references that same sequence of confirmed pivots, so everything stays synchronized no matter which combination you enable.
  • ZigZag - A ZigZag line connects confirmed swing highs and lows, filtering out minor fluctuations so the larger directional moves in price are easy to see. It provides the structural backbone every other module in this indicator builds on.
  • Market Structure - Market structure classifies successive swings as higher highs, higher lows, lower highs, or lower lows, so the current trend can be described objectively. The script tracks the most recent unresolved swing high and low and distinguishes three events by how price interacts with them: a wick that breaks a level and is confirmed by a close continues the prevailing bias (Break of Structure) or reverses it (Change of Character / MSS); a wick that breaks a level but closes back on the original side is tagged a Swing Failure Pattern, and the bias stays unchanged.
    snapshot
  • Fractals - A fractal is a local turning point where a set number of bars slope toward a central peak or trough on both sides. Every candle is the trivial depth-1 case, and each additional depth requires one more consecutive bar sloping toward the peak on both sides. A depth-2 fractal is therefore the classic 3-bar pattern (the peak with one sloping bar on each side), and each higher depth extends that by one more bar per side. The script plots fractals from any minimum depth you configure (2 or higher), with optional display of non-pivot fractals alongside the confirmed ones.
    snapshot
  • Trendlines - A trendline connects two price points to visualize a move's slope and flag when it breaks. You choose a Start and an End pivot type for each trendline, and the End must chronologically follow the Start rather than simply reconnecting whichever two pivots are most recent. Trendlines can project forward and optionally stop once broken.
    snapshot
  • Fibonacci Retracements - Fibonacci retracements mark horizontal levels (ratios such as 38.2% or 61.8% derived from a prior price swing) commonly referenced when gauging potential pullback areas. This script anchors each retracement to the current swing's own price range and only rebuilds it once price closes beyond that range, not on every minor pivot in between, so the levels stay stable through normal noise.
    snapshot
  • Swing Metrics - Statistics calculated for every completed swing, including price change, percentage, retracement, bars, volume, and ATR, quantifying each move instead of relying on visual estimation.
    snapshot
⚙️ How to Use

The indicator is modular, so you can enable only the components relevant to your workflow:
  • Use ZigZag on its own for a clean view of confirmed swings.
  • Add Market Structure to see HH/HL/LH/LL classification and BoS/CHoCH/SFP events.
  • Add Trendlines to connect specific pivot types you select, with optional forward projection.
  • Add Fibonacci Retracements to see levels drawn automatically from the current swing.
  • Add Fractals or Swing Metrics for additional confirmation and context.
🔥 Key Features
  • Advanced ZigZag with configurable pivot detection
  • Automatic classification of HH, HL, LH, and LL market structure
  • Break of Structure (BoS), CHoCH/MSS, and Swing Failure Pattern (SFP) detection
  • Configurable fractal detection with adjustable minimum depth (2 and up) and optional non-pivot fractals
  • Up to 6 independently configurable trendlines connecting selected pivot types, with optional projection, break detection, and a limit on how many recent segments stay visible
  • Automatic Fibonacci retracements with customizable retracement and extension levels, labels, and backgrounds
  • Swing metrics including price change, percentage, ticks, retracement, bars, volume, and ATR
  • Alerts for pivots, fractals, structure events, trendlines, trendline breaks, and Fibonacci level crossings
I hope this toolkit becomes a valuable part of your trading workflow. If you have any feedback, ideas, or suggestions for future improvements, I'd be happy to hear them.

👋 Good luck and happy trading!

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.