OPEN-SOURCE SCRIPT
Cập nhật Zig Zag & Trendlines with Dynamic Threshold ATR

Percentage Zig Zag with Dynamic Threshold
This Pine Script indicator is an advanced Zig Zag tool that identifies and tracks price pivots based on a percentage move required for reversal, offering a clear visual representation of volatility-adjusted trends.
Core Functionality (The Reversal Threshold):
Unlike standard Zig Zag indicators that use a fixed price difference, this indicator calculates the required reversal size (%X) dynamically using the Average True Range (ATR).
It calculates the ATR as a percentage of the current price (ATR%).
The final threshold is this ATR% multiplied by a user-defined factor (default 3x).
This means the reversal threshold is wider during volatile periods and narrower during quiet periods, adapting automatically to market conditions. Users can optionally revert to a fixed percentage if desired.
Trend Extension Lines:
The indicator draws two unique, dynamic trend lines connecting the last two significant Highs and the last two significant Lows. Crucially, these lines do not wait for the entire Zig Zag leg to confirm:
If the price is actively forming a new up-leg, the High Extension Line connects the last confirmed High to the current extreme high of the active move.
The Low Extension Line functions similarly for the downtrend.
This feature allows the user to visualize dynamic support and resistance levels based on the current, active trend structure defined by the percentage threshold.
This Pine Script indicator is an advanced Zig Zag tool that identifies and tracks price pivots based on a percentage move required for reversal, offering a clear visual representation of volatility-adjusted trends.
Core Functionality (The Reversal Threshold):
Unlike standard Zig Zag indicators that use a fixed price difference, this indicator calculates the required reversal size (%X) dynamically using the Average True Range (ATR).
It calculates the ATR as a percentage of the current price (ATR%).
The final threshold is this ATR% multiplied by a user-defined factor (default 3x).
This means the reversal threshold is wider during volatile periods and narrower during quiet periods, adapting automatically to market conditions. Users can optionally revert to a fixed percentage if desired.
Trend Extension Lines:
The indicator draws two unique, dynamic trend lines connecting the last two significant Highs and the last two significant Lows. Crucially, these lines do not wait for the entire Zig Zag leg to confirm:
If the price is actively forming a new up-leg, the High Extension Line connects the last confirmed High to the current extreme high of the active move.
The Low Extension Line functions similarly for the downtrend.
This feature allows the user to visualize dynamic support and resistance levels based on the current, active trend structure defined by the percentage threshold.
Phát hành các Ghi chú
color updateMã 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.