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:
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。