OPEN-SOURCE SCRIPT
Price Action ZigZag (Impulses & Corrections)

This indicator tracks price structure by connecting significant swing highs and lows—giving a clear, actionable “ZigZag” view of market movement. It automatically maps the underlying price action as alternating impulses (trend legs) and corrections (pullbacks), directly on your chart, for any timeframe.
How does it work?
Swing Detection:
The script uses the user-selected “pivot length” to identify confirmed swing highs and lows with Pine Script’s ta.pivothigh and ta.pivotlow.
These pivots only print after full confirmation, making all lines strictly non-repainting.
ZigZag Drawing:
Impulse vs Correction Logic:
Labels & Colors:
Key Features:
How to use:
Disclaimer:
This script is a visualization and analysis tool for educational purposes—it does not predict future price movement, guarantee results, or provide trading signals. Always use sound risk management and your own judgment in live trading.
How does it work?
Swing Detection:
The script uses the user-selected “pivot length” to identify confirmed swing highs and lows with Pine Script’s ta.pivothigh and ta.pivotlow.
These pivots only print after full confirmation, making all lines strictly non-repainting.
ZigZag Drawing:
- After pivots are captured, the indicator connects each alternating swing with lines that trace the progression of price structure.
- Each line segment is mapped according to the sequence and direction of swings:
- Impulse: Moves that break further away from prior swing in the same direction (continuations/uptrends/downtrends)
- Correction: Moves that pull price back, but do not extend past the previous impulse (retracements/sideways action)
Impulse vs Correction Logic:
- Bullish impulse: swing from a higher low to a higher high (fast upward moves after a low)
- Bearish impulse: swing from a lower high to a lower low (fast downward moves after a high)
- Corrections appear as smaller lines between alternating swing points not leading to new trend extension.
Labels & Colors:
- Impulse lines are drawn teal (customizable), corrections in gray.
- Tiny labels ("Impulse", "Correction") are shown for clarity (optional).
- Most recent pivots are highlighted with yellow dots for quick visual reference.
Key Features:
- User-adjustable pivot length controls sensitivity and structure size (scalp to swing).
- Distinguishes between impulses and corrections instantly on the chart.
- Labels and color coding for clarity—traders can spot trend continuation vs. pullback at a glance.
- Non-repainting confirmed pivots and lines; never show incomplete data.
- Fully customizable appearance—all colors and label display adjustable in settings.
- Zero lookahead or repainting: all signals use confirmed, historical price only.
How to use:
- Add to any chart and set 'Swing Length' to fit your trading style (shorter for scalping, longer for bigger structure).
- Follow the ZigZag lines to see when price makes an impulse vs. correction, and use this to identify high-probability momentum or reversal zones.
- Combine this script with your own analysis/strategy or other indicators for deeper context.
- Adjust colors and label options for your preferred chart clarity.
Disclaimer:
This script is a visualization and analysis tool for educational purposes—it does not predict future price movement, guarantee results, or provide trading signals. Always use sound risk management and your own judgment in live trading.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.