Esempio n. 1
0
        /// <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)
        {
            _maximum.Update(time, new DoubleArrayScalar(input[HighIdx]));
            _minimum.Update(time, new DoubleArrayScalar(input[LowIdx]));

            return((_maximum + _minimum) / 2);
        }
Esempio n. 2
0
        /// <summary>
        ///      Computes the next value in the transform.
        ///      value1 is a function used to normalize price withing the last _period day range.
        ///      value1 is centered on its midpoint and then doubled so that value1 wil swing between -1 and +1.
        ///      value1 is also smoothed with an exponential moving average whose alpha is 0.33.
        ///
        ///      Since the smoothing may allow value1 to exceed the _period day price range, limits are introduced to
        ///      preclude the transform from blowing up by having an input larger than unity.
        /// </summary>
        /// <param name="time"></param>
        /// <param name="input">DoubleArray - the time and value of the next price</param>
        protected override DoubleArray Forward(long time, DoubleArray input)
        {
            var price = (input[LowIdx] + input[HighIdx]) / 2d;

            _medianMin.Update(time, price);
            _medianMax.Update(time, price);

            if (!IsReady)
            {
                return(0);
            }

            var x    = 0.0;
            var y    = 0.0;
            var minL = _medianMin.Current.Value;
            var maxH = _medianMax.Current.Value;

            if (minL != maxH)
            {
                x = _alpha * 2 * ((price - minL) / (maxH - minL) - .5) + (1 - _alpha) * _previous;
                y = FisherTransformFunction(x);
            }

            _previous = x;

            return(Convert.ToDouble(y) + .5d * Current.Value);
        }
Esempio n. 3
0
        /// <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)
        {
            Maximum.Update(time, input);
            var val = Maximum.Current.Value - input.Value;

            Delta.Update(time, val);
            return(val);
        }
Esempio n. 4
0
        /// <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)
        {
            Minimum.Update(time, input[LowIdx]);
            Maximum.Update(time, input[HighIdx]);

            if (!IsReady)
            {
                return(0);
            }

            var range = Maximum.Current.Value - Minimum.Current.Value;

            return(Math.Abs(range) < ZeroEpsilon ? 0 : -100.0d * (Maximum.Current.Value - input[CloseIdx]) / range);
        }
Esempio n. 5
0
 /// <summary>
 ///      AroonUp = 100 * (period - {periods since max})/period
 /// </summary>
 /// <param name="upPeriod">The AroonUp period</param>
 /// <param name="max">A Maximum indicator used to compute periods since max</param>
 /// <param name="input">The next input data</param>
 /// <returns>The AroonUp value</returns>
 private static double ComputeAroonUp(int upPeriod, Maximum max, long time, DoubleArray input)
 {
     max.Update(time, input);
     return(100.0d * (upPeriod - max.PeriodsSinceMaximum) / upPeriod);
 }