예제 #1
0
        /// <summary>
        /// The Momentum indicator measures the amount that a security's price has changed over a given time span.
        /// </summary>
        /// <returns></returns>
        public Momentum Momentum(Data.IDataSeries input, int period)
        {
            if (cacheMomentum != null)
            {
                for (int idx = 0; idx < cacheMomentum.Length; idx++)
                {
                    if (cacheMomentum[idx].Period == period && cacheMomentum[idx].EqualsInput(input))
                    {
                        return(cacheMomentum[idx]);
                    }
                }
            }

            lock (checkMomentum)
            {
                checkMomentum.Period = period;
                period = checkMomentum.Period;

                if (cacheMomentum != null)
                {
                    for (int idx = 0; idx < cacheMomentum.Length; idx++)
                    {
                        if (cacheMomentum[idx].Period == period && cacheMomentum[idx].EqualsInput(input))
                        {
                            return(cacheMomentum[idx]);
                        }
                    }
                }

                Momentum indicator = new Momentum();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input  = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                Momentum[] tmp = new Momentum[cacheMomentum == null ? 1 : cacheMomentum.Length + 1];
                if (cacheMomentum != null)
                {
                    cacheMomentum.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheMomentum       = tmp;
                return(indicator);
            }
        }
예제 #2
0
 protected override void OnStartUp()
 {
     if (momType == anaKaufmanEfficiencyType.Classic)
     {
         Anchor   = SMA(Input, 1);
         lookback = period;
     }
     else
     {
         Anchor   = SMA(SMA(Input, period + 1), period + 1);
         lookback = 0;
     }
     Mom = Momentum(Input, 1);
 }
예제 #3
0
 protected override void OnStartUp()
 {
     mom  = Momentum(Median, momo);
     dexp = zDexpSmooth(mom, alpha, 1);
 }
예제 #4
0
        /// <summary>
        /// The Momentum indicator measures the amount that a security's price has changed over a given time span.
        /// </summary>
        /// <returns></returns>
        public Momentum Momentum(Data.IDataSeries input, int period)
        {
            if (cacheMomentum != null)
                for (int idx = 0; idx < cacheMomentum.Length; idx++)
                    if (cacheMomentum[idx].Period == period && cacheMomentum[idx].EqualsInput(input))
                        return cacheMomentum[idx];

            lock (checkMomentum)
            {
                checkMomentum.Period = period;
                period = checkMomentum.Period;

                if (cacheMomentum != null)
                    for (int idx = 0; idx < cacheMomentum.Length; idx++)
                        if (cacheMomentum[idx].Period == period && cacheMomentum[idx].EqualsInput(input))
                            return cacheMomentum[idx];

                Momentum indicator = new Momentum();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                Momentum[] tmp = new Momentum[cacheMomentum == null ? 1 : cacheMomentum.Length + 1];
                if (cacheMomentum != null)
                    cacheMomentum.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheMomentum = tmp;
                return indicator;
            }
        }