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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.