Beispiel #1
0
 /// <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);
 }
Beispiel #2
0
 /// <summary>
 /// Resets this indicator to its initial state
 /// </summary>
 public override void Reset()
 {
     AverageTrueRange.Reset();
     MiddleBand.Reset();
     UpperBand.Reset();
     LowerBand.Reset();
     base.Reset();
 }
Beispiel #3
0
        /// <summary>
        /// Computes the next value for this indicator from the given state.
        /// </summary>
        /// <param name="input">The TradeBar to this indicator on this time step</param>
        /// <returns>A new value for this indicator</returns>
        protected override decimal ComputeNextValue(TradeBar input)
        {
            AverageTrueRange.Update(input);

            var typicalPrice = (input.High + input.Low + input.Close) / 3m;

            MiddleBand.Update(input.Time, typicalPrice);
            Console.WriteLine(input.Time.ToString("yyyymmdd") + "\t" + typicalPrice.SmartRounding() + "\t" + MiddleBand.Current.Value.SmartRounding());
            // poke the upper/lower bands, they actually don't use the input, they compute
            // based on the ATR and the middle band
            LowerBand.Update(input);
            UpperBand.Update(input);
            return(MiddleBand);
        }