OPEN-SOURCE SCRIPT

ATR ZigZag - Volatility-Filtered Market Structure

44
Description
This indicator draws ZigZags using an ATR based threshold for direction switching to identify major swing highs and lows. Instead of relying on fractals or fixed bar-count swings, pivots are confirmed only when price moves beyond the prior extreme by:

threshold = ATR(length) × ATR_mult

This filters noise, enforces valid swing structure (high → low → high), and adapts automatically to volatility. The ATR ZigZag is ideal for traders who want a clean, objective view of swing structure without noise. This has many uses, including mapping swing structure, drawing chart patterns, and trading around extremes.

Lag and Repainting
Pivots are confirmed only after price moves sufficiently in the opposite direction. This creates necessary lag. The ZigZag is drawn when this occurs, and will anchor to the high/low in the past. Optional detection dot plots show exactly when confirmation occurred.

What You See
  • ZigZag: dashed gray line, repainted to anchor at the confirmed highs and lows
  • Latest Pivot Levels: Dashed horizontal lines at the most recent confirmed high/low.
  • Optional Live Swing Leg: A real-time line from the last confirmed pivot to the current swing extreme, updating until a new pivot forms.
  • Optional ATR Boxes: 1×ATR shaded zones around the latest pivot for structural context.
  • Optional Pivot Confirmation Dots: Markers show the bar where the threshold is crossed and a swing is officially confirmed. This is to understand the lag and see when the ZigZag repainted.

免責事項

この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。