Exemple #1
0
        /// <summary>
        /// To handle the input value.
        /// </summary>
        /// <param name="input">The input value.</param>
        /// <returns>The resulting value.</returns>
        protected override IIndicatorValue OnProcess(IIndicatorValue input)
        {
            // используем дополнительную переменную IsFormed,
            // т.к. нужна задержка в один период для корректной инициализации скользящей средней
            _isFormed = MovingAverage.IsFormed;

            return(MovingAverage.Process(TrueRange.Process(input)));
        }
Exemple #2
0
        /// <summary>
        /// To reset the indicator status to initial. The method is called each time when initial settings are changed (for example, the length of period).
        /// </summary>
        public override void Reset()
        {
            base.Reset();

            _isFormed = false;

            MovingAverage.Length = Length;
            TrueRange.Reset();
        }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AverageTrueRange"/>.
        /// </summary>
        /// <param name="movingAverage">Moving Average.</param>
        /// <param name="trueRange">True range.</param>
        public AverageTrueRange(LengthIndicator <decimal> movingAverage, TrueRange trueRange)
        {
            if (movingAverage == null)
            {
                throw new ArgumentNullException(nameof(movingAverage));
            }

            if (trueRange == null)
            {
                throw new ArgumentNullException(nameof(trueRange));
            }

            MovingAverage = movingAverage;
            TrueRange     = trueRange;
        }
Exemple #4
0
 /// <summary>
 /// Возможно ли обработать входное значение.
 /// </summary>
 /// <param name="input">Входное значение.</param>
 /// <returns><see langword="true"/>, если возможно, иначе, <see langword="false"/>.</returns>
 public override bool CanProcess(IIndicatorValue input)
 {
     return(TrueRange.CanProcess(input) && MovingAverage.CanProcess(input));
 }