OPEN-SOURCE SCRIPT
Mis à jour

ZigZag

1 298
ZigZag Indicator – Overview

This ZigZag indicator highlights the most important swing highs and swing lows on the chart, helping traders see market structure more clearly by filtering out minor price movements. It connects significant turning points with straight lines, creating a clean visual representation of trend direction and major reversals.


How It Works

  • Price constantly moves up and down, but not every movement is meaningful. The ZigZag indicator waits for price to make a move large enough to be considered a true swing point. Once such a movement occurs, the indicator identifies it as either a swing high or a swing low and draws a line connecting it to the previous swing.

  • This produces a simplified outline of market structure, making it easier to recognize trends, corrections, and major turning points.


Settings

  • ZigZag Length

    Controls the sensitivity of the indicator.
    Lower values produce more frequent swing points.
    Higher values show only major swings and reduce noise.

  • Show ZigZag

    Enables or disables the visual lines. When disabled, the indicator continues tracking swing points internally.


What You See on the Chart

  • Every time the market creates a confirmed swing high or swing low, the indicator draws a line to the previous swing in the opposite direction.

  • After a major low is confirmed, a line is drawn to the most recent high.
  • After a major high is confirmed, a line is drawn to the most recent low.
  • This creates a clear, continuous zigzag that outlines the dominant movements of the market without reacting to every small fluctuation.


Why This ZigZag Is Useful

  • It does not repaint once a swing is confirmed.
  • It provides a clean and simplified view of price structure.
  • It helps identify trend direction, structure breaks, impulses, and corrections.
  • It is useful for traders who follow price action, smart money concepts, and swing-based strategies.


Recommended Use Cases

  • This ZigZag indicator is suited for traders who rely on market structure analysis, including:
  • Swing trading
  • Smart Money Concepts (BOS/CHOCH detection)
  • Identifying impulses and pullbacks
  • Finding strong highs and lows
  • Studying overall trend direction
Notes de version
This update refines the ZigZag indicator by improving structure validity tracking, breakout awareness, and visual clarity, while keeping the core non-repainting swing logic unchanged.


What’s New in This Update
  1. Swing Level Break Tracking (New)

    The indicator now tracks whether the most recent swing high or swing low has been broken by price.
    A swing high is marked as broken once price closes above it.
    A swing low is marked as broken once price closes below it.
    This allows traders to clearly distinguish between active (valid) structure levels and invalidated ones.

  2. Conditional Horizontal Levels
    Horizontal lines for the last confirmed High and Low are now drawn only if they remain unbroken.
    If a level is broken, its horizontal line is automatically removed.
    This prevents outdated structure levels from cluttering the chart or misleading analysis.

  3. Price-Scale Labels Respect Structure State
    Price-scale labels for the last High and Low are now shown only while the level is valid.
    Once a level is broken, its price label disappears.
    This keeps the price scale aligned with current market structure.

  4. Breakout Alert Conditions
    New alert conditions have been added for structural breaks:
    Alert when price closes above the last swing high.
    Alert when price closes below the last swing low.
    These alerts are based on confirmed swings, not raw highs/lows, making them suitable for structure-based analysis (e.g., BOS-style monitoring).

What Did Not Change

The ZigZag logic remains non-repainting once a swing is confirmed.
Swing detection is still controlled entirely by the ZigZag Length setting.
The indicator continues to filter out minor fluctuations and display only meaningful swings.

Why This Update Matters

This update makes the ZigZag more useful for market structure analysis by clearly separating:
Valid vs. broken swing levels
Structure that still matters vs. structure that has already failed
This is especially helpful for traders studying trend continuation, structure breaks, and swing-based price action.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.