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:
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.
Script de código abierto
Siguiendo fielmente el espíritu de TradingView, el creador de este script lo ha publicado en código abierto, permitiendo que otros traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la publicación de este código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.