AverageTrueRange


Summary

Average true range. An indicator providing the degree of price volatility.

Remarks

Average true range (ATR) is a technical analysis volatility indicator originally developed by J. Welles Wilder. The indicator provides the degree of price volatility. The average true range is an N-day exponential moving average of the true range values. Wilder recommended a 14-period smoothing.

Syntax

public AverageTrueRange AverageTrueRange(int periods, MovingAverageType maType)
public AverageTrueRange AverageTrueRange(MarketSeries marketSeries, int periods, MovingAverageType maType)

Parameters

NameDescription

Example 1

private AverageTrueRange atrIndicator;
[Parameter(DefaultValue = 20)]
public int Period { get; set; }
[Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType MAType { get; set; }
[Parameter(DefaultValue = 0.002)]
public double ATRValue { get; set; }
protected override void OnStart()
{
    atrIndicator = Indicators.AverageTrueRange(Period, MAType);
}
protected override void OnTick()
{
    //If atrIndicator last value is greater than the ATRValue input
    if (atrIndicator.Result.LastValue > ATRValue)
    {
        // Do something
    }
    //...
}