/// <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(IndicatorDataPoint input)
 {
     _fastWma.Update(input);
     _slowWma.Update(input);
     _hullMa.Update(new IndicatorDataPoint(input.Time, 2 * _fastWma.Current.Value - _slowWma.Current.Value));
     return(_hullMa.Current.Value);
 }
예제 #2
0
 /// <summary>
 ///     Computes the next value for this indicator from the given state.
 /// </summary>
 /// <param name="window">The window of data held in this indicator</param>
 /// <param name="input">The input value to this indicator on this time step</param>        /// <returns></returns>
 /// <remarks>
 /// The Hull moving average is a series of nested weighted moving averages.
 /// Using the LWMA custom function for calculating weighted moving averages,
 /// the Hull moving average can be calculated following the steps.
 ///
 ///1.Calculate the n periodweighted moving average of a series "=WMA(price for n periods)"
 ///2.Calculate the n/2 period weighted moving average of a series"=WMA(price for n/2 periods)". Round n/2 to the nearest whole number
 ///3.Create a time series with 2*WMA from Step 2 - WMA from Step 1
 ///4.The HMA is the WMA of the series in Step 3. "=WMA(Step 3 outputs fo k period)"
 /// </remarks>
 protected override decimal ComputeNextValue(IReadOnlyWindow <IndicatorDataPoint> window, IndicatorDataPoint input)
 {
     _longWma.Update(input);
     _shortWma.Update(input);
     _smooth.Add(new IndicatorDataPoint(input.Time, 2 * _shortWma.Current.Value - _longWma.Current.Value));
     _result.Update(new IndicatorDataPoint(input.Time, _smooth[0].Value));
     return(_result.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(IndicatorDataPoint input)
 {
     _fastWma.Update(input);
     _slowWma.Update(input);
     if (_fastWma.IsReady && _slowWma.IsReady)
     {
         _hullMa.Update(new IndicatorDataPoint(input.Time, 2 * _fastWma - _slowWma));
     }
     return(_hullMa);
 }
예제 #4
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(IndicatorDataPoint input)
 {
     _shortRoc.Update(input);
     _longRoc.Update(input);
     if (!_longRoc.IsReady || !_shortRoc.IsReady)
     {
         return(decimal.Zero);
     }
     _lwma.Update(input.Time, _shortRoc.Current.Value + _longRoc.Current.Value);
     return(_lwma.Current.Value);
 }