Average True Range (ATR)

Indicator that measures the actual volatility of the market.

Average True Range (ATR) measures the actual volatility of the market. It can be used for dynamic placing of Profit Target and Stop Loss actions. ATR is a moving average, generally covering 14 days of volatility measurements. It was created to allow traders to more accurately measure the daily volatility of an asset by using simple calculations. Indicator does not provide an indication of price direction, just volatility.

Trading application

ATR does not provide an indication of price direction, just volatility. Trades can use shorter periods to have more actual value of ATR without lag. If they wish to analyze volatility of an asset over a period of five trading days, they could use five-day ATR on end-of-day data. Assuming the historical price data is arranged in reverse chronological order, the trader finds the maximum of the absolute value of the current high minus the current low, the absolute value of the current high minus the previous close, and the absolute value of the current low minus the previous close. These True Range (TR) calculations are used in creating a moving average and this is known as ATR. Typically, the ATR is based on 14 periods and can be calculated on an intraday, daily, weekly or monthly basis. For the following example, the ATR will be based on daily data.

Calculation

ATR=[(PriorATRx(Period1))+CurrentTR]/PeriodATR = [(Prior ATR x (Period-1)) + Current TR] / Period

Parameters

Input Parameters

Name

Type

Range of value

Description

period

int

<1, int.MaxValue>

Number of bars used in the calculation.

Output Parameters

Indicator ouptuts a single value.

Type

Range of value

double

(0, double.MaxValue)

Examples

// Prints the current value of a 20 period ATR using
// the daily bars close price value.
atr = indicators.ATR(20).OnSeries(dailyBars);
Log("The current ATR value is " + atr.Value.ToString());
// Prints the previous ATR value
atr = indicators.ATR(20).Keep(2).OnSeries(dailyBars);
Log("The previous ATR value is " + atr.Values[1].ToString());

Complete example

using Signals.DataSeries.Bars;
using Signals.Framework;
using Signals.Indicators.ATR;
public class MyStrategy : SingleMarketStrategy
{
private Bars dailyBars;
private ATR atr;
public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
{
dailyBars = data.Bars(BarPeriodType.Day, 1).WithOffset(25);
atr = indicators.ATR(20).Keep(2).OnSeries(dailyBars);
}
public override void RegisterActions()
{
OnUpdateOf(dailyBars).Do(() =>
{
// Prints the current ATR value
Log("The current ATR value is " + atr.Value.ToString());
// Prints the previous ATR value
Log("The previous ATR value is " + atr.Values[1].ToString());
});
}
}