OPEN-SOURCE SCRIPT
ATR ZigZag Breakout

ATR ZigZag Breakout
This strategy uses my ATR ZigZag indicator (powered by the ZigZagCore library) to scalp breakouts at volatility-filtered highs and lows.
Everyone knows stops cluster around clear swing highs and lows. Breakout traders often pile in there, too. These levels are predictable areas where aggressive orders hit the tape. The idea here is simple:
→ Let ATR ZigZag define clean, volatility-filtered pivots
→ Arm a stop market order at those pivots
→ Join the breakout when the crowd hits the level
The key to greater success in this simple strategy lies in the ZigZag. Because the pivots are filtered by ATR instead of fixed bar counts or fractals, the levels tend to be more meaningful and less noisy.
This approach is especially suited for intraday trading on volatile instruments (e.g., NQ, GC, liquid crypto pairs).
How It Works
1. Pivot detection
The ATR ZigZag uses an ATR-based threshold to confirm swing highs and lows. Only when price has moved far enough in the opposite direction does a pivot become “official.”
2. Candidate breakout level
When a new swing direction is detected and the most recent high/low has not yet been broken in the current leg, the strategy arms a stop market order at that pivot.
• Long candidate → most recent swing high
• Short candidate → most recent swing low
These “candidate trades” are shown as dotted lines.
3. Entry, SL, and TP
If price breaks through the level, the stop order is filled and a bracket is placed:
• Stop loss = ATR × SL multiplier
• Take profit = SL distance × RR multiplier
Once a level has traded, it is not reused in the same swing leg.
4. Cancel & rotate
If the market reverses and forms a new swing in the opposite direction before the level is hit, the pending order is cancelled and a new candidate is considered in the new direction.
Additional Features
• Optional session filter for backtesting specific trading hours
This strategy uses my ATR ZigZag indicator (powered by the ZigZagCore library) to scalp breakouts at volatility-filtered highs and lows.
Everyone knows stops cluster around clear swing highs and lows. Breakout traders often pile in there, too. These levels are predictable areas where aggressive orders hit the tape. The idea here is simple:
→ Let ATR ZigZag define clean, volatility-filtered pivots
→ Arm a stop market order at those pivots
→ Join the breakout when the crowd hits the level
The key to greater success in this simple strategy lies in the ZigZag. Because the pivots are filtered by ATR instead of fixed bar counts or fractals, the levels tend to be more meaningful and less noisy.
This approach is especially suited for intraday trading on volatile instruments (e.g., NQ, GC, liquid crypto pairs).
How It Works
1. Pivot detection
The ATR ZigZag uses an ATR-based threshold to confirm swing highs and lows. Only when price has moved far enough in the opposite direction does a pivot become “official.”
2. Candidate breakout level
When a new swing direction is detected and the most recent high/low has not yet been broken in the current leg, the strategy arms a stop market order at that pivot.
• Long candidate → most recent swing high
• Short candidate → most recent swing low
These “candidate trades” are shown as dotted lines.
3. Entry, SL, and TP
If price breaks through the level, the stop order is filled and a bracket is placed:
• Stop loss = ATR × SL multiplier
• Take profit = SL distance × RR multiplier
Once a level has traded, it is not reused in the same swing leg.
4. Cancel & rotate
If the market reverses and forms a new swing in the opposite direction before the level is hit, the pending order is cancelled and a new candidate is considered in the new direction.
Additional Features
• Optional session filter for backtesting specific trading hours
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.