Exemple #1
0
 /// <summary>
 /// Computes the next value of the following sub-indicators from the given state:
 /// StandardDeviation, MiddleBand, UpperBand, LowerBand
 /// </summary>
 /// <param name="input">The input given to the indicator</param>
 /// <returns>The input is returned unmodified.</returns>
 protected override decimal ComputeNextValue(IndicatorDataPoint input)
 {
     StandardDeviation.Update(input);
     MiddleBand.Update(input);
     UpperBand.Update(input);
     LowerBand.Update(input);
     return(input);
 }
Exemple #2
0
        /// <summary>
        /// Computes the next value of this indicator from the given state
        /// </summary>
        /// <param name="input">The input given to the indicator</param>
        /// <returns>
        /// A new value for this indicator
        /// </returns>
        protected override decimal ComputeNextValue(IBaseDataBar input)
        {
            var coeff = _width * (input.High - input.Low) / (input.High + input.Low);

            LowerBand.Update(input.Time, input.Low * (1 - coeff));
            UpperBand.Update(input.Time, input.High * (1 + coeff));
            MiddleBand.Update(input.Time, input.Close);

            return(MiddleBand);
        }
        /// <summary>
        ///      Computes the next value of this indicator from the given state
        /// </summary>
        /// <param name="time"></param>
        /// <param name="input">The input given to the indicator</param>
        /// <returns>
        ///      A new value for this indicator
        /// </returns>
        protected override DoubleArray Forward(long time, DoubleArray input)
        {
            var coeff = _width * (input[HighIdx] - input[LowIdx]) / (input[HighIdx] + input[LowIdx]);

            LowerBand.Update(time, input[LowIdx] * (1 - coeff));
            UpperBand.Update(time, input[HighIdx] * (1 + coeff));
            MiddleBand.Update(time, input[CloseIdx]);

            return(MiddleBand);
        }
        /// <summary>
        /// Computes the next value of this indicator from the given state
        /// </summary>
        /// <param name="input">The input given to the indicator</param>
        /// <returns>A new value for this indicator, which by convention is the mean value of the upper band and lower band.</returns>
        protected override decimal ComputeNextValue(IBaseDataBar input)
        {
            if (_previousInput != null)
            {
                UpperBand.Update(new IndicatorDataPoint(_previousInput.Time, _previousInput.High));
                LowerBand.Update(new IndicatorDataPoint(_previousInput.Time, _previousInput.Low));
            }

            _previousInput = input;
            return((UpperBand.Current.Value + LowerBand.Current.Value) / 2);
        }
Exemple #5
0
        /// <summary>
        /// Computes the next value of this indicator from the given state
        /// </summary>
        /// <param name="input">The input given to the indicator</param>
        /// <returns>A new value for this indicator, which by convention is the mean value of the upper band and lower band.</returns>
        protected override decimal ComputeNextValue(DataPointBar input)
        {
            if (_previousInput != null)
            {
                UpperBand.Update(new IndicatorDataPoint(_previousInput.Occured, _previousInput.TimeZone, _previousInput.High));
                LowerBand.Update(new IndicatorDataPoint(_previousInput.Occured, _previousInput.TimeZone, _previousInput.Low));
            }

            _previousInput = input;
            return (UpperBand.Current.Price + LowerBand.Current.Price) / 2;
        }
Exemple #6
0
        /// <summary>
        /// Computes the next value of this indicator from the given state
        /// </summary>
        /// <param name="input">The input given to the indicator</param>
        /// <returns>A new value for this indicator, which by convention is the mean value of the upper band and lower band.</returns>
        protected override decimal ComputeNextValue(IBaseDataBar input)
        {
            if (_previousInput != null)
            {
                UpperBand.Update(_previousInput.Time, _previousInput.High);
                LowerBand.Update(_previousInput.Time, _previousInput.Low);
            }

            _previousInput = input;
            return((UpperBand + LowerBand) / 2);
        }
        /// <summary>
        ///      Computes the next value of this indicator from the given state
        /// </summary>
        /// <param name="time"></param>
        /// <param name="input">The input given to the indicator</param>
        /// <returns>A new value for this indicator, which by convention is the mean value of the upper band and lower band.</returns>
        protected override DoubleArray Forward(long time, DoubleArray input)
        {
            if (_previousInput != null)
            {
                UpperBand.Update(_previousTime, _previousInput.High);
                LowerBand.Update(_previousTime, _previousInput.Low);
            }

            _previousInput = input.Clone();
            _previousTime  = time;
            return((UpperBand + LowerBand) / 2);
        }
Exemple #8
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(IBaseDataBar input)
        {
            AverageTrueRange.Update(input);

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

            MiddleBand.Update(input.Time, 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);
        }
Exemple #9
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);
        }
Exemple #10
0
        /// <summary>
        ///      Computes the next value for this indicator from the given state.
        /// </summary>
        /// <param name="time"></param>
        /// <param name="input">The TradeBar to this indicator on this time step</param>
        /// <returns>A new value for this indicator</returns>
        protected override DoubleArray Forward(long time, DoubleArray input)
        {
            AverageTrueRange.Update(time, input);

            var typicalPrice = (input[HighIdx] + input[LowIdx] + input[CloseIdx]) / 3d;

            MiddleBand.Update(time, 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(time, input);
            UpperBand.Update(time, input);
            return(MiddleBand);
        }