/// <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 newValue = input.GetValue <decimal>();
            var smaValue = _sma.Process(input).GetValue <decimal>();

            if (input.IsFinal)
            {
                Buffer.Add(newValue);

                if (Buffer.Count > Length)
                {
                    Buffer.RemoveAt(0);
                }
            }

            var buff = Buffer;

            if (!input.IsFinal)
            {
                buff = new List <decimal>();
                buff.AddRange(Buffer.Skip(1));
                buff.Add(newValue);
            }

            //считаем значение отклонения в последней точке
            var std = buff.Select(t1 => t1 - smaValue).Select(t => t * t).Sum();

            return(new DecimalIndicatorValue(this, (decimal)Math.Sqrt((double)(std / Length))));
        }
Beispiel #2
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 smaValue = _sma.Process(input);

            if (_sma.IsFormed && input.IsFinal)
            {
                Buffer.Add(smaValue.GetValue <decimal>());
            }

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

            if (Buffer.Count > Length)
            {
                Buffer.RemoveAt(0);
            }

            return(new DecimalIndicatorValue(this, input.GetValue <decimal>() - Buffer[0]));
        }
Beispiel #3
0
        /// <inheritdoc />
        protected override IIndicatorValue OnProcess(IIndicatorValue input)
        {
            var candle = input.GetValue <Candle>();

            return(_sma.Process(input.SetValue(this, candle.OpenPrice - candle.ClosePrice)));
        }