Average True Range (ATR)
Average True Range (ATR) is a technical analysis indicator developed by J. Welles Wilder, based on trading ranges smoothed by an Nday exponential moving average.
The range of a day's trading is simply the high  low. The true range extends it to yesterday's closing price if it was outside of today's range.
The true range is the largest of the:
Most recent period's high minus the most recent period's low
Absolute value of the most recent period's high minus the previous close
Absolute value of the most recent period's low minus the previous close
Function Version 
ATR(x, z) 
x =Period, z =Offset, t =AverageType 
Indicator Version 
ATRx.z 

Average Type besides Simple 
tAVG(ATR1.z, x) 
Where x
is the period and must be an integer.
Where z
is the offset. An offset of 1 would be 1 bar ago.
Where t
is the type of moving average used to smooth true range. Leave blank for a simple, X for exponential, F for front weight and H for Hull.
Note that you can use an exponential average type to get the traditional Wilder's smoothing, but you need to set x
to ((period * 2)  1). So a 14 period Wilder's smoothed ATR would use a period of 27.
A 14 period ATR for the current bar can be written as follows.
ATR14.0
But you can get rid of the offset since it is zero and just use the following instead.
ATR14
A 14 period Wilder's smoothed ATR for the current bar can be written as follows.
XAVG(ATR, 27)
A 14 period Wilder's smoothed ATR from 2 bars ago can be written as follows.
XAVG(ATR1.2, 27)
Read more about Average True Range on Wikipedia.