예제 #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;
 }
예제 #2
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);

            // Define our warmup
            // LWMA does not get updated until ROC are warmed up and ready, so add our periods.
            // Then minus 1 because on the same point ROC is ready LWMA will receive its first point.
            WarmUpPeriod = Math.Max(_shortRoc.WarmUpPeriod, _longRoc.WarmUpPeriod) + 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);
        }
예제 #4
0
        // The length of the smoothed window
        // square root of period rounded to the nearest whole number

        /// <summary>
        /// A Hull Moving Average
        /// </summary>
        /// <param name="name">string - a name for the indicator</param>
        /// <param name="period">int - the number of periods over which to calculate the HMA - the length of the longWMA</param>
        public HullMovingAverage(string name, int period)
            : base(name, period)
        {
            // Creates the long LWMA for the number of periods specified in the constuctor
            _longWma = new LinearWeightedMovingAverage("Long", period);

            // Creates the short LWMA for half the period rounded to the nearest whole number
            _shortWma = new LinearWeightedMovingAverage("Short", period / 2);

            // Creates the smoother data set to which the resulting wma is applied
            _smooth = new RollingWindow <IndicatorDataPoint>(period);

            // number of historical periods to look at in the resulting WMA
            int k = System.Convert.ToInt32(Math.Sqrt(period));

            // Creates the LWMA for the output. This step probably could have been skipped

            _result = new LinearWeightedMovingAverage("Result", k);
        }