OPEN-SOURCE SCRIPT
Cody Zig Zag

Cody Zig Zag – MT4-Style Zig Zag for TradingView
The ZigZag indicator that actually works like the classic MT4 version!
🔍 Overview
Cody Zig Zag is a powerful, fully customizable ZigZag indicator that replicates the exact behavior of the popular MetaTrader 4 (MT4) ZigZag. Unlike TradingView's built-in ZigZag, this version behaves identically to what MT4 traders know and love – making it perfect for Elliott Wave traders, support/resistance hunters, and breakout specialists.
⚙️ Input Parameters (Just like MT4!)
Parameter Default Description
Depth 12 Minimum number of bars between swing points
Deviation 5 Minimum price movement (in ticks) to form a new swing
Backstep 2 Minimum bars between swing points of the same type
Line Thickness 2 Visual weight of the ZigZag line
Bull Color Lime Color for upward swings
Bear Color Red Color for downward swings
Repaint Levels True Enables real-time repainting (MT4 style)
🎯 Key Features
✅ TRUE MT4 BEHAVIOR – Exact replication of MetaTrader 4's classic ZigZag algorithm
✅ INTELLIGENT LABELS – Automatically identifies HH (Higher High), LH (Lower High), LL (Lower Low), and HL (Higher Low)
✅ REAL-TIME UPDATES – Optional repainting mode for live market analysis
✅ DIRECTION BACKGROUND – Visual market direction indicator (Green = Bullish, Red = Bearish)
✅ ALERT CONDITIONS – Get notified when the ZigZag direction changes
💡 How to Use
For Beginners:
Just add the indicator to your chart – the default settings (12,5,2) work perfectly for most timeframes!
For Advanced Traders:
Lower Depth (5-8) → More swings, more detail (scalping/1min charts)
Higher Depth (12-20) → Cleaner swings, fewer signals (swing trading/4H+ charts)
Adjust Deviation → Control minimum swing size based on volatility
🎨 Visual Guide
Lime Line = Price moving UP
Red Line = Price moving DOWN
HH Label = Higher High (uptrend continuation)
LH Label = Lower High (potential reversal down)
LL Label = Lower Low (downtrend continuation)
HL Label = Higher Low (potential reversal up)
📊 Best For
📌 Elliott Wave Counting – Perfect for identifying wave structure
📌 Support & Resistance – Automatically marks swing highs/lows
📌 Breakout Trading – Visualize clear break levels
📌 Divergence Trading – Spot hidden/regular divergences with RSI/MACD
📌 Harmonic Patterns – Identify XABCD patterns easily
⏰ Alert Conditions
Direction Changed – Triggered whenever the ZigZag changes direction
Bullish Direction – When price starts moving up
Bearish Direction – When price starts moving down
🔧 Troubleshooting
Q: Why does the indicator "repaint"?
A: That's how MT4 ZigZag works! Repainting shows the most accurate real-time swing points. Turn OFF "Repaint Levels" if you prefer traditional non-repainting behavior.
Q: What timeframes work best?
A: Works on ALL timeframes! Lower Depth values (5-8) for lower timeframes, higher Depth (12-20) for higher timeframes.
Q: Can I use this for automated strategies?
A: Yes! The alert conditions can trigger tradingview alerts for manual or webhook-based trading.
🙏 Credits
Original MT4 ZigZag logic ported to Pine Script™ v6 by lucemanb
Renamed and optimized as Cody Zig Zag
📝 Keywords
ZigZag MT4 Elliott Wave Swing High Swing Low Support Resistance Divergence Breakout Harmonic Patterns Price Action Trend Reversal Higher High Lower Low Technical Analysis TradingView Indicator Free Indicator
⭐ Support & Feedback
If you find this indicator useful:
Like & Follow for more tools
Leave a review with your suggestions
Share with your trading community
Happy Trading! 🚀
Disclaimer: This indicator is for educational and analytical purposes. Past performance does not guarantee future results. Always practice proper risk management.
The ZigZag indicator that actually works like the classic MT4 version!
🔍 Overview
Cody Zig Zag is a powerful, fully customizable ZigZag indicator that replicates the exact behavior of the popular MetaTrader 4 (MT4) ZigZag. Unlike TradingView's built-in ZigZag, this version behaves identically to what MT4 traders know and love – making it perfect for Elliott Wave traders, support/resistance hunters, and breakout specialists.
⚙️ Input Parameters (Just like MT4!)
Parameter Default Description
Depth 12 Minimum number of bars between swing points
Deviation 5 Minimum price movement (in ticks) to form a new swing
Backstep 2 Minimum bars between swing points of the same type
Line Thickness 2 Visual weight of the ZigZag line
Bull Color Lime Color for upward swings
Bear Color Red Color for downward swings
Repaint Levels True Enables real-time repainting (MT4 style)
🎯 Key Features
✅ TRUE MT4 BEHAVIOR – Exact replication of MetaTrader 4's classic ZigZag algorithm
✅ INTELLIGENT LABELS – Automatically identifies HH (Higher High), LH (Lower High), LL (Lower Low), and HL (Higher Low)
✅ REAL-TIME UPDATES – Optional repainting mode for live market analysis
✅ DIRECTION BACKGROUND – Visual market direction indicator (Green = Bullish, Red = Bearish)
✅ ALERT CONDITIONS – Get notified when the ZigZag direction changes
💡 How to Use
For Beginners:
Just add the indicator to your chart – the default settings (12,5,2) work perfectly for most timeframes!
For Advanced Traders:
Lower Depth (5-8) → More swings, more detail (scalping/1min charts)
Higher Depth (12-20) → Cleaner swings, fewer signals (swing trading/4H+ charts)
Adjust Deviation → Control minimum swing size based on volatility
🎨 Visual Guide
Lime Line = Price moving UP
Red Line = Price moving DOWN
HH Label = Higher High (uptrend continuation)
LH Label = Lower High (potential reversal down)
LL Label = Lower Low (downtrend continuation)
HL Label = Higher Low (potential reversal up)
📊 Best For
📌 Elliott Wave Counting – Perfect for identifying wave structure
📌 Support & Resistance – Automatically marks swing highs/lows
📌 Breakout Trading – Visualize clear break levels
📌 Divergence Trading – Spot hidden/regular divergences with RSI/MACD
📌 Harmonic Patterns – Identify XABCD patterns easily
⏰ Alert Conditions
Direction Changed – Triggered whenever the ZigZag changes direction
Bullish Direction – When price starts moving up
Bearish Direction – When price starts moving down
🔧 Troubleshooting
Q: Why does the indicator "repaint"?
A: That's how MT4 ZigZag works! Repainting shows the most accurate real-time swing points. Turn OFF "Repaint Levels" if you prefer traditional non-repainting behavior.
Q: What timeframes work best?
A: Works on ALL timeframes! Lower Depth values (5-8) for lower timeframes, higher Depth (12-20) for higher timeframes.
Q: Can I use this for automated strategies?
A: Yes! The alert conditions can trigger tradingview alerts for manual or webhook-based trading.
🙏 Credits
Original MT4 ZigZag logic ported to Pine Script™ v6 by lucemanb
Renamed and optimized as Cody Zig Zag
📝 Keywords
ZigZag MT4 Elliott Wave Swing High Swing Low Support Resistance Divergence Breakout Harmonic Patterns Price Action Trend Reversal Higher High Lower Low Technical Analysis TradingView Indicator Free Indicator
⭐ Support & Feedback
If you find this indicator useful:
Like & Follow for more tools
Leave a review with your suggestions
Share with your trading community
Happy Trading! 🚀
Disclaimer: This indicator is for educational and analytical purposes. Past performance does not guarantee future results. Always practice proper risk management.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。