/// <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="input">IndicatorDataPoint - the time and value of the next price</param> /// <returns></returns> protected override decimal ComputeNextValue(TradeBar input) { var x = 0.0; var y = 0.0; var price = (input.Low + input.High) / 2m; _medianMin.Update(input.Time, price); _medianMax.Update(input.Time, price); if (!IsReady) { return(0); } var minL = _medianMin.Current.Value; var maxH = _medianMax.Current.Value; if (minL != maxH) { x = _alpha * 2 * ((double)((price - minL) / (maxH - minL)) - .5) + (1 - _alpha) * _previous; y = FisherTransformFunction(x); } _previous = x; return(Convert.ToDecimal(y) + .5m * Current.Value); }
/// <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(TradeBar input) { _maximum.Update(new IndicatorDataPoint { Value = input.High }); _minimum.Update(new IndicatorDataPoint { Value = input.Low }); return((_maximum + _minimum) / 2); }
/// <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(TradeBar input) { Minimum.Update(input.Time, input.Low); Maximum.Update(input.Time, input.High); if (!this.IsReady) { return(0); } var range = (Maximum.Current.Value - Minimum.Current.Value); return(range == 0 ? 0 : -100m * (Maximum.Current.Value - input.Close) / range); }
/// <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 decimal ComputeAroonUp(int upPeriod, Maximum max, IndicatorDataPoint input) { max.Update(input); return(100m * (upPeriod - max.PeriodsSinceMaximum) / upPeriod); }