Example #1
0
        /// <summary>
        /// The CMO differs from other momentum oscillators such as Relative Strength Index (RSI) and Stochastics. It uses both up and down days data in the numerator of the calculation to measure momentum directly. Primarily used to look for extreme overbought and oversold conditions, CMO can also be used to look for trends.
        /// </summary>
        /// <returns></returns>
        public CMO CMO(Data.IDataSeries input, int period)
        {
            if (cacheCMO != null)
            {
                for (int idx = 0; idx < cacheCMO.Length; idx++)
                {
                    if (cacheCMO[idx].Period == period && cacheCMO[idx].EqualsInput(input))
                    {
                        return(cacheCMO[idx]);
                    }
                }
            }

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

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

                CMO indicator = new CMO();
                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();

                CMO[] tmp = new CMO[cacheCMO == null ? 1 : cacheCMO.Length + 1];
                if (cacheCMO != null)
                {
                    cacheCMO.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheCMO            = tmp;
                return(indicator);
            }
        }
Example #2
0
        /// <summary>
        /// The CMO differs from other momentum oscillators such as Relative Strength Index (RSI) and Stochastics. It uses both up and down days data in the numerator of the calculation to measure momentum directly. Primarily used to look for extreme overbought and oversold conditions, CMO can also be used to look for trends.
        /// </summary>
        /// <returns></returns>
        public CMO CMO(Data.IDataSeries input, int period)
        {
            if (cacheCMO != null)
                for (int idx = 0; idx < cacheCMO.Length; idx++)
                    if (cacheCMO[idx].Period == period && cacheCMO[idx].EqualsInput(input))
                        return cacheCMO[idx];

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

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

                CMO indicator = new CMO();
                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();

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