Ejemplo n.º 1
0
        public KaufmanAdaptiveMovingAverage(Equity equity, int periodCount, int emaFastPeriodCount, int emaSlowPeriodCount)
            : base(equity, periodCount, emaFastPeriodCount, emaSlowPeriodCount)
        {
            _erIndicator = new EfficiencyRatio(equity, periodCount);

            Func <int, decimal> sc = i =>
            {
                double erValue = Convert.ToDouble(_erIndicator.ComputeByIndex(i).Er);
                return(Convert.ToDecimal(Math.Pow(erValue * (2.0 / (emaFastPeriodCount + 1) - 2.0 / (emaSlowPeriodCount + 1)) + 2.0 / (emaSlowPeriodCount + 1), 2)));
            };

            _gemaIndicator = new GenericExponentialMovingAverage(
                equity,
                periodCount - 1,
                i => Equity[i].Close,
                i => Equity[i].Close,
                i => sc(i));
        }
Ejemplo n.º 2
0
        public KaufmanAdaptiveMovingAverage(IList <decimal> closes, int periodCount, int emaFastPeriodCount, int emaSlowPeriodCount)
            : base(closes)
        {
            _er = new EfficiencyRatio(closes, periodCount);

            Func <int, decimal> sc = i =>
            {
                double erValue = Convert.ToDouble(_er[i]);
                return(Convert.ToDecimal(Math.Pow(erValue * (2.0 / (emaFastPeriodCount + 1) - 2.0 / (emaSlowPeriodCount + 1)) + 2.0 / (emaSlowPeriodCount + 1), 2)));
            };

            _gema = new GenericExponentialMovingAverage <decimal>(
                closes,
                periodCount - 1,
                i => Inputs[i],
                i => Inputs[i],
                i => sc(i));

            PeriodCount        = periodCount;
            EmaFastPeriodCount = emaFastPeriodCount;
            EmaSlowPeriodCount = emaSlowPeriodCount;
        }