示例#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);
 }
示例#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();
 }
示例#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(DataPointBar input)
        {
            AverageTrueRange.Update(input);

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

            MiddleBand.Update(input.Occured, input.TimeZone, 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(input);
            UpperBand.Update(input);
            return(MiddleBand);
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the KeltnerChannels class
        /// </summary>
        /// <param name="name">The name of this indicator</param>
        /// <param name="period">The period of the average true range and moving average (middle band)</param>
        /// <param name="k">The number of multiples specifying the distance between the middle band and upper or lower bands</param>
        /// <param name="movingAverageType">The type of moving average to be used</param>
        public KeltnerChannels(string name, int period, decimal k, MovingAverageType movingAverageType = MovingAverageType.Simple)
            : base(name)
        {
            _k = k;

            //Initialize ATR and SMA
            AverageTrueRange = new AverageTrueRange(name + "_AverageTrueRange", period, MovingAverageType.Simple);
            MiddleBand       = movingAverageType.AsIndicator(name + "_MiddleBand", period);

            //Compute Lower Band
            LowerBand = new FunctionalIndicator <DataPointBar>(name + "_LowerBand",
                                                               input => ComputeLowerBand(),
                                                               lowerBand => MiddleBand.IsReady,
                                                               () => MiddleBand.Reset()
                                                               );

            //Compute Upper Band
            UpperBand = new FunctionalIndicator <DataPointBar>(name + "_UpperBand",
                                                               input => ComputeUpperBand(),
                                                               upperBand => MiddleBand.IsReady,
                                                               () => MiddleBand.Reset()
                                                               );
        }
示例#5
0
        public Interfaces.Indicators.AverageTrueRange AverageTrueRange(int period, DataStream stream, TimeSpan barSize)
        {
            var nmodule = new AverageTrueRange(period, barSize, stream);

            return(_manager.Subscribe <AverageTrueRange>(nmodule));
        }
示例#6
0
        public Interfaces.Indicators.AverageTrueRange AverageTrueRange(int period, DataStream stream)
        {
            var nmodule = new AverageTrueRange(period, _manager.Agent.TimeFrame, stream);

            return(_manager.Subscribe <AverageTrueRange>(nmodule));
        }