OPEN-SOURCE SCRIPT
Structure Zig-Zag [TheTraderShark]

A zig-zag indicator should do one thing well — show you where the market structure is heading with zero noise. No extra labels. No complex settings. Just clean lines connecting the swings that matter.
Structure Zig-Zag connects confirmed swing highs and swing lows with alternating lines. Bullish legs (low to high) are green. Bearish legs (high to low) are red. Direction change points are marked so you can see exactly where the market shifted. That's it. Simple, clean, useful.
Built on confirmed pivot data — lines don't redraw or disappear after the fact.
🦈 FEATURES
▸ Zig-Zag Lines
Alternating lines connect each swing low to the next swing high, and each swing high to the next swing low. The result is a clear visual structure of the market's directional movement.
▸ Color-Coded by Direction
• Green lines — bullish legs (swing low → swing high), price moving up
• Red lines — bearish legs (swing high → swing low), price moving down
One glance tells you the current direction and where the turns happened.
▸ Direction Change Markers
When the zig-zag direction implies a structural shift — a higher high forming after a series of lower lows, or a lower low after higher highs — the pivot point is marked with a small indicator. These are the moments where momentum changed.
▸ Optional Price Labels
Toggle price labels at each zig-zag vertex to see the exact price at every swing point. Useful for measuring swing ranges and retracement depths.
▸ Line Management
Configurable maximum number of zig-zag lines on chart (default: 50). Oldest lines are automatically removed to keep your chart focused on recent structure. The current developing leg updates in real time as price extends.
🦈 WHY THIS OVER OTHER ZIG-ZAG INDICATORS
✅ Non-repainting — lines drawn from confirmed pivots, not live price
✅ Color-coded direction — instant visual of bullish vs bearish legs
✅ Direction change markers — see structural shifts at a glance
✅ Minimal settings — does one thing and does it well
✅ Clean chart — configurable line limit, no clutter
🦈 SETTINGS
🦈 Structure Zig-Zag
• Enable/Disable — toggle the zig-zag overlay on or off
• Line Width — visual thickness of zig-zag lines (1-5, default: 2)
• Show Price at Vertices — display the price level at each swing point
• Max Lines on Chart — limit total zig-zag lines to keep chart clean (default: 50)
🦈 ALERTS
• Structure direction changed to bullish — zig-zag is now making an upward leg
• Structure direction changed to bearish — zig-zag is now making a downward leg
🦈 HOW TO USE
Add the indicator — default settings work on all timeframes.
Green lines going up = bullish structure. Red lines going down = bearish structure.
Look at the length and steepness of each leg — long green legs with short red pullbacks = strong uptrend. The opposite = strong downtrend.
Direction change markers highlight where momentum shifted — these are often the best areas to look for entries.
Use the price labels to measure swing ranges: "The last bullish leg was 150 pips, pullback was only 40 pips — trend is healthy."
Tip: Combine with swing labels (HH/HL/LH/LL) for a full picture — the zig-zag shows direction, the labels tell you the structure quality.
🦈 NON-REPAINTING
• Zig-zag vertices are placed at confirmed swing points (pivot lookback delay)
• Once a line segment is confirmed, it does not move or disappear
• Only the current developing leg updates as price extends — this is expected behavior, not repainting
• Historical and real-time views match for all confirmed segments
🦈 ABOUT
Built by TheTraderShark. Part of the Market Structure & Swing Suite — the visual backbone that connects the swing data into a clear directional picture.
Feedback and feature requests welcome in the comments.
Structure Zig-Zag connects confirmed swing highs and swing lows with alternating lines. Bullish legs (low to high) are green. Bearish legs (high to low) are red. Direction change points are marked so you can see exactly where the market shifted. That's it. Simple, clean, useful.
Built on confirmed pivot data — lines don't redraw or disappear after the fact.
🦈 FEATURES
▸ Zig-Zag Lines
Alternating lines connect each swing low to the next swing high, and each swing high to the next swing low. The result is a clear visual structure of the market's directional movement.
▸ Color-Coded by Direction
• Green lines — bullish legs (swing low → swing high), price moving up
• Red lines — bearish legs (swing high → swing low), price moving down
One glance tells you the current direction and where the turns happened.
▸ Direction Change Markers
When the zig-zag direction implies a structural shift — a higher high forming after a series of lower lows, or a lower low after higher highs — the pivot point is marked with a small indicator. These are the moments where momentum changed.
▸ Optional Price Labels
Toggle price labels at each zig-zag vertex to see the exact price at every swing point. Useful for measuring swing ranges and retracement depths.
▸ Line Management
Configurable maximum number of zig-zag lines on chart (default: 50). Oldest lines are automatically removed to keep your chart focused on recent structure. The current developing leg updates in real time as price extends.
🦈 WHY THIS OVER OTHER ZIG-ZAG INDICATORS
✅ Non-repainting — lines drawn from confirmed pivots, not live price
✅ Color-coded direction — instant visual of bullish vs bearish legs
✅ Direction change markers — see structural shifts at a glance
✅ Minimal settings — does one thing and does it well
✅ Clean chart — configurable line limit, no clutter
🦈 SETTINGS
🦈 Structure Zig-Zag
• Enable/Disable — toggle the zig-zag overlay on or off
• Line Width — visual thickness of zig-zag lines (1-5, default: 2)
• Show Price at Vertices — display the price level at each swing point
• Max Lines on Chart — limit total zig-zag lines to keep chart clean (default: 50)
🦈 ALERTS
• Structure direction changed to bullish — zig-zag is now making an upward leg
• Structure direction changed to bearish — zig-zag is now making a downward leg
🦈 HOW TO USE
Add the indicator — default settings work on all timeframes.
Green lines going up = bullish structure. Red lines going down = bearish structure.
Look at the length and steepness of each leg — long green legs with short red pullbacks = strong uptrend. The opposite = strong downtrend.
Direction change markers highlight where momentum shifted — these are often the best areas to look for entries.
Use the price labels to measure swing ranges: "The last bullish leg was 150 pips, pullback was only 40 pips — trend is healthy."
Tip: Combine with swing labels (HH/HL/LH/LL) for a full picture — the zig-zag shows direction, the labels tell you the structure quality.
🦈 NON-REPAINTING
• Zig-zag vertices are placed at confirmed swing points (pivot lookback delay)
• Once a line segment is confirmed, it does not move or disappear
• Only the current developing leg updates as price extends — this is expected behavior, not repainting
• Historical and real-time views match for all confirmed segments
🦈 ABOUT
Built by TheTraderShark. Part of the Market Structure & Swing Suite — the visual backbone that connects the swing data into a clear directional picture.
Feedback and feature requests welcome in the comments.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。