public FractalAdaptiveMovingAverageExtend(int period, int fastMovingAverage, int slowMovingAverage)
            : base(0)
        {
            if (period <= 0)
            {
                throw new ArgumentException("period must be greater than 0");
            }

            if (period % 2 != 0)
            {
                throw new ArgumentException("period must be even number");
            }

            if (slowMovingAverage <= 0 || fastMovingAverage <= 0)
            {
                throw new ArgumentException("slow moving average or fast moving average must be greather than 0");
            }

            if (fastMovingAverage >= slowMovingAverage)
            {
                throw new ArgumentException("fast moving average must be smaller than slow moving average");
            }

            _sc         = slowMovingAverage;
            _fc         = fastMovingAverage;
            _h          = Math.Max(_period - 1, Even((_sc - _fc) / 2) + _fc);
            _period     = period;
            _halfPeriod = period / 2;
            _minAlpha   = 2.0 / (_sc + 1);
            _maxAlpha   = 1.0;
            _w          = Math.Log(_minAlpha);

            _initialFrama      = new MovingAverage(_h);
            _firstHalfHighest  = new Highest(_halfPeriod);
            _firstHalfLowest   = new Lowest(_halfPeriod);
            _secondHalfHighest = new Highest(_halfPeriod);
            _secondHalfLowest  = new Lowest(_halfPeriod);
        }
Exemplo n.º 2
0
 public VolumeChange(int windowSize)
     : base(0)
 {
     _volumeMa = new MovingAverage(windowSize);
 }
Exemplo n.º 3
0
 public CommodityChannelIndex(int windowSize)
     : base(0)
 {
     _maTruePrice = new MovingAverage(windowSize);
     _truePrices  = new CirculatedArray <double>(windowSize);
 }
Exemplo n.º 4
0
 public AverageTrueRange(int windowSize)
     : base(0)
 {
     _maTrueRange = new MovingAverage(windowSize);
 }