/// <summary> /// Initializes a new instance of the <see cref="NormalizedAverageTrueRange"/> class using the specified name and period. /// </summary> /// <param name="name">The name of this indicator</param> /// <param name="period">The period of the NATR</param> public NormalizedAverageTrueRange(string name, int period) : base(name) { _period = period; _tr = new TrueRange(name + "_TR"); _atr = new AverageTrueRange(name + "_ATR", period, MovingAverageType.Simple); }
/// <summary> /// Resets this indicator to its initial state /// </summary> public override void Reset() { AverageTrueRange.Reset(); MiddleBand.Reset(); UpperBand.Reset(); LowerBand.Reset(); base.Reset(); }
/// <summary> /// Computes the next value for this indicator from the given state. /// </summary> /// <param name="time"></param> /// <param name="input">The TradeBar to this indicator on this time step</param> /// <returns>A new value for this indicator</returns> protected override DoubleArray Forward(long time, DoubleArray input) { AverageTrueRange.Update(time, input); var typicalPrice = (input[HighIdx] + input[LowIdx] + input[CloseIdx]) / 3d; MiddleBand.Update(time, typicalPrice); // poke the upper/lower bands, they actually don't use the input, they compute // based on the ATR and the middle band LowerBand.Update(time, input); UpperBand.Update(time, input); return(MiddleBand); }