OPEN-SOURCE SCRIPT

Daily True Range (DTR) vs Average True Range (ATR)

107
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
  • 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
  1. 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.
  2. Average True Range (ATR):
    Calculates the smoothed average of DTR over a customizable period (default 14 days) using Wilder’s smoothing method.
  3. Updates in real-time as the day progresses.
  4. Timeframe Flexibility: Works on any chart timeframe (e.g., 1-minute, 1-hour) while always calculating DTR and ATR based on daily data.
  5. 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

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.