コード例 #1
0
ファイル: CCI.cs プロジェクト: fandres70/NinjaTrader.Base
        /// <summary>
        /// The Commodity Channel Index (CCI) measures the variation of a security's price from its statistical mean. High values show that prices are unusually high compared to average prices whereas low values indicate that prices are unusually low.
        /// </summary>
        /// <returns></returns>
        public CCI CCI(Data.IDataSeries input, int period)
        {
            if (cacheCCI != null)
            {
                for (int idx = 0; idx < cacheCCI.Length; idx++)
                {
                    if (cacheCCI[idx].Period == period && cacheCCI[idx].EqualsInput(input))
                    {
                        return(cacheCCI[idx]);
                    }
                }
            }

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

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

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

                CCI[] tmp = new CCI[cacheCCI == null ? 1 : cacheCCI.Length + 1];
                if (cacheCCI != null)
                {
                    cacheCCI.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheCCI            = tmp;
                return(indicator);
            }
        }
コード例 #2
0
ファイル: CCI.cs プロジェクト: redrhino/NinjaTrader.Base
        /// <summary>
        /// The Commodity Channel Index (CCI) measures the variation of a security's price from its statistical mean. High values show that prices are unusually high compared to average prices whereas low values indicate that prices are unusually low.
        /// </summary>
        /// <returns></returns>
        public CCI CCI(Data.IDataSeries input, int period)
        {
            if (cacheCCI != null)
                for (int idx = 0; idx < cacheCCI.Length; idx++)
                    if (cacheCCI[idx].Period == period && cacheCCI[idx].EqualsInput(input))
                        return cacheCCI[idx];

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

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

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

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