/// <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)
        {
            var candle = input.GetValue <Candle>();

            // Находим минимум и максимум для заданного периода
            var minValue = _min.Process(input.SetValue(this, candle.LowPrice)).GetValue <decimal>();
            var maxValue = _max.Process(input.SetValue(this, candle.HighPrice)).GetValue <decimal>();

            var sumValue = 0m;

            // Вычисляем сумму модулей разности цен закрытия текущего и предыдущего дня для заданного периода
            if (_previousClosePrice != null)
            {
                sumValue = _sum.Process(input.SetValue(this, Math.Abs(_previousClosePrice.Value - candle.ClosePrice))).GetValue <decimal>();
            }

            if (input.IsFinal)
            {
                _previousClosePrice = candle.ClosePrice;
            }

            if (!IsFormed)
            {
                return(new DecimalIndicatorValue(this));
            }

            // Вычисляем значение индикатора
            if (sumValue != 0)
            {
                return(new DecimalIndicatorValue(this, ((maxValue - minValue) / sumValue)));
            }

            return(new DecimalIndicatorValue(this));
        }
示例#2
0
        /// <summary>
        /// Обработать входное значение.
        /// </summary>
        /// <param name="input">Входное значение.</param>
        /// <returns>Результирующее значение.</returns>
        protected override IIndicatorValue OnProcess(IIndicatorValue input)
        {
            var candle = input.GetValue <Candle>();

            // Находим минимум и максимум для заданного периода
            var lowValue  = _low.Process(input.SetValue(this, candle.LowPrice)).GetValue <decimal>();
            var highValue = _high.Process(input.SetValue(this, candle.HighPrice)).GetValue <decimal>();

            if ((highValue - lowValue) != 0)
            {
                return(new DecimalIndicatorValue(this, -100m * (highValue - candle.ClosePrice) / (highValue - lowValue)));
            }

            return(new DecimalIndicatorValue(this));
        }
示例#3
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)
        {
            var candle = input.GetValue <Candle>();

            var highValue = _high.Process(input.SetValue(this, candle.HighPrice)).GetValue <decimal>();
            var lowValue  = _low.Process(input.SetValue(this, candle.LowPrice)).GetValue <decimal>();

            var diff = highValue - lowValue;

            if (diff == 0)
            {
                return(new DecimalIndicatorValue(this, 0));
            }

            return(new DecimalIndicatorValue(this, 100 * (candle.ClosePrice - lowValue) / diff));
        }