OPEN-SOURCE SCRIPT
Volume Weighted ATR

This script implements a Volume‑Weighted Average True Range (VWATR) indicator, a variation of ATR that incorporates trading volume into the volatility calculation. Instead of treating all price movements equally, it amplifies true range during high‑volume periods and dampens it during low‑volume periods, producing a volatility measure that adapts to liquidity conditions. The script begins by allowing the user to choose a lookback length and a smoothing method, offering RMA, SMA, EMA, or WMA for flexibility in how responsive the indicator should be.
The core of the calculation starts with the standard true range, which captures the most meaningful price movement of each bar. This true range is then multiplied by volume, creating a volume‑weighted true range that gives more importance to bars where market participation is higher. To ensure consistency, the script defines a custom moving‑average function that applies the selected smoothing method to any input series. This function is used twice: once to smooth the volume‑weighted true range and once to smooth volume itself.
The final VWATR value is obtained by dividing the smoothed volume‑weighted true range by the smoothed volume. Mathematically, this produces a volume‑weighted mean of true range, making the indicator more sensitive to volatility expansions that occur with strong participation and less reactive to low‑volume noise. The script concludes by plotting this VWATR line, giving traders a clean, adaptive measure of volatility that can be used for regime detection, breakout confirmation, or dynamic stop sizing
The core of the calculation starts with the standard true range, which captures the most meaningful price movement of each bar. This true range is then multiplied by volume, creating a volume‑weighted true range that gives more importance to bars where market participation is higher. To ensure consistency, the script defines a custom moving‑average function that applies the selected smoothing method to any input series. This function is used twice: once to smooth the volume‑weighted true range and once to smooth volume itself.
The final VWATR value is obtained by dividing the smoothed volume‑weighted true range by the smoothed volume. Mathematically, this produces a volume‑weighted mean of true range, making the indicator more sensitive to volatility expansions that occur with strong participation and less reactive to low‑volume noise. The script concludes by plotting this VWATR line, giving traders a clean, adaptive measure of volatility that can be used for regime detection, breakout confirmation, or dynamic stop sizing
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.