OPEN-SOURCE SCRIPT
Daily True Range (DTR) vs Average True Range (ATR)

Overview
The "DTR vs ATR with Color-Coded Percentage" indicator is a powerful volatility analysis tool designed for traders who want to understand daily price movements in the context of historical volatility. It calculates the Daily True Range (DTR)—the raw measure of a single day’s volatility—and compares it to the Average True Range (ATR), which smooths volatility over a user-defined period (default 14 days). The indicator presents this data in an intuitive table, featuring a color-coded percentage that visually represents how the current day’s move (DTR) stacks up against the average volatility (ATR). This helps traders quickly assess whether the current day’s price action is unusually volatile, average, or subdued relative to recent history.
Purpose
Features
The "DTR vs ATR with Color-Coded Percentage" indicator is a powerful volatility analysis tool designed for traders who want to understand daily price movements in the context of historical volatility. It calculates the Daily True Range (DTR)—the raw measure of a single day’s volatility—and compares it to the Average True Range (ATR), which smooths volatility over a user-defined period (default 14 days). The indicator presents this data in an intuitive table, featuring a color-coded percentage that visually represents how the current day’s move (DTR) stacks up against the average volatility (ATR). This helps traders quickly assess whether the current day’s price action is unusually volatile, average, or subdued relative to recent history.
Purpose
- Volatility Comparison: Visualize how the current day’s price range (DTR) relates to the average range (ATR) over a specified period.
- Decision Support: Identify days with exceptional movement (e.g., breakouts or reversals) versus normal or quiet days, aiding in trade entry/exit decisions.
- Risk Management: Gauge daily volatility to adjust position sizing or stop-loss levels based on whether the market is exceeding or falling short of typical movement.
Features
- Daily True Range (DTR) Calculation:
Computes the True Range for the current day as the greatest of:
Current day’s High - Low
High - Previous Close
Low - Previous Close
Aggregates data on any timeframe to ensure accurate daily values. - Average True Range (ATR):
Calculates the smoothed average of DTR over a customizable period (default 14 days) using Wilder’s smoothing method. - Updates in real-time as the day progresses.
- Timeframe Flexibility: Works on any chart timeframe (e.g., 1-minute, 1-hour) while always calculating DTR and ATR based on daily data.
- Color-Coded Display in either compact or table mode
- The percentage value is color-coded in the table based on configurable thresholds:
- Safe (default 75): Normal range, within typical volatility
- Warning: (default 75-125): Above-average volatility.
- Danger (default 125): Exceptionally high volatility
- Safe (default 75): Normal range, within typical volatility
- The percentage value is color-coded in the table based on configurable thresholds:
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.