Average True Range |
Atr is an indicator that shows volatility of the market. Atr can often reach a high value at the bottom of the market after a sheer fall in prices that might be characterized by panic selling. Low values of the indicator are typical for the periods of sideways movement of long duration which happen at the top of the market and/or during consolidation. Average True Range can be interpreted according to the same principles as other volatility indicators.
The principle of forecasting based on this indicator can be worded the following way: the higher the value of the indicator, the higher the probability of a trend change; the lower the indicator’s value, the weaker the trend’s movement.
To initialize Atr indicator use the following constructors:
Atr – this constructor sets default value of 14 for period.
Atr(Int32) – sets period of the indicator
Atr(IAverager) – sets the type of averaging
Use
ATR - property to get current value
1// Create new instance, period = 28 2Atr atr = new Atr(28); 3 4// Number of stored values 5atr.HistoryCapacity = 2; 6 7// Add new data point 8atr.Add(Bars.Current.Open, Bars.Current.High, Bars.Current.Low, Bars.Current.Close, Bars.Current.Volume, CurrentTime); 9 10// Get indicator values 11double IndicatorValue = atr.ATR; 12// Get previous value 13if (atr.HistoryCount == 2) 14{ 15 double IndicatorPrevValue = atr[1]; 16}
ATR with custom averaging:
1// Create new instance, instead of MMA we will use SMA period = 28 2Atr atr = new Atr(new Sma(28)); 3 4// Add new data point 5atr.Add(Bars.Current.Open, Bars.Current.High, Bars.Current.Low, Bars.Current.Close, Bars.Current.Volume, CurrentTime); 6 7// Get indicator values 8double IndicatorValue = atr.ATR;