ATR

Overview of the Average True Range calculation.

The average true range (ATR) is a technical indicator of volatility based on the average of a particular set of trading ranges over a defined number of periods. The ATR is the average of the true range for a set of periods. The greatest of one of three ranges is calculated as the true range for a period: the current high minus the current low, the current high minus the previous period’s close, or the current low minus the previous close.

Once the true range is calculated, the average for a set lookback period is taken, typically 14 periods. A decline in ATR indicates a decrease in recent volatility. An increase in ATR indicates an increase in recent volatility.

The source code for the ATR function is available here.

/* Average True Range is the greatest of the following: 
 *
 *  val1 = distance from today's high to today's low.
 *  val2 = distance from yesterday's close to today's high.
 *  val3 = distance from yesterday's close to today's low.   
 *
 * These value are averaged for the specified period using
 * Wilder method. This method has an unstable period comparable
 * to an Exponential Moving Average (EMA).
 */

Last updated