Beispiel #1
0
 /// <summary>
 ///      Initializes a new instance of the <see cref="CoppockCurve" /> indicator
 /// </summary>
 /// <param name="name">A name for the indicator</param>
 /// <param name="shortRocPeriod">The period for the short ROC</param>
 /// <param name="longRocPeriod">The period for the long ROC</param>
 /// <param name="lwmaPeriod">The period for the LWMA</param>
 public CoppockCurve(string name, int shortRocPeriod, int longRocPeriod, int lwmaPeriod)
     : base(name)
 {
     _shortRoc    = new RateOfChangePercent(shortRocPeriod);
     _longRoc     = new RateOfChangePercent(longRocPeriod);
     _lwma        = new LinearWeightedMovingAverage(lwmaPeriod);
     WarmUpPeriod = Math.Max(shortRocPeriod, longRocPeriod) + lwmaPeriod - 1;
 }
        /// <summary>
        ///      A Hull Moving Average
        /// </summary>
        /// <param name="name">string - a name for the indicator</param>
        /// <param name="period">int - the number of periods to calculate the HMA - the period of the slower LWMA</param>
        public HullMovingAverage(string name, int period)
            : base(name)
        {
            if (period < 2)
            {
                throw new ArgumentException("The Hull Moving Average period should be greater or equal to 2", "period");
            }
            _slowWma = new LinearWeightedMovingAverage(period);
            _fastWma = new LinearWeightedMovingAverage((int)Math.Round(period * 1d / 2));
            var k = (int)Math.Round(Math.Sqrt(period));

            _hullMa      = new LinearWeightedMovingAverage(k);
            WarmUpPeriod = period + k - 1;
        }