Ejemplo n.º 1
0
        /// <summary>
        /// Adaptive CCI
        /// </summary>
        /// <returns></returns>
        public AdaptiveCci AdaptiveCci(Data.IDataSeries input, AdaptiveCciPlots adaptiveCciPlotNo, int altNumbarsPlot1, int altNumbarsPlot2, int altNumbarsPlot3, int altNumbarsPlot4, double cycPart, int periodMultiplier, int smooth)
        {
            if (cacheAdaptiveCci != null)
                for (int idx = 0; idx < cacheAdaptiveCci.Length; idx++)
                    if (cacheAdaptiveCci[idx].AdaptiveCciPlotNo == adaptiveCciPlotNo && cacheAdaptiveCci[idx].AltNumbarsPlot1 == altNumbarsPlot1 && cacheAdaptiveCci[idx].AltNumbarsPlot2 == altNumbarsPlot2 && cacheAdaptiveCci[idx].AltNumbarsPlot3 == altNumbarsPlot3 && cacheAdaptiveCci[idx].AltNumbarsPlot4 == altNumbarsPlot4 && Math.Abs(cacheAdaptiveCci[idx].CycPart - cycPart) <= double.Epsilon && cacheAdaptiveCci[idx].PeriodMultiplier == periodMultiplier && cacheAdaptiveCci[idx].Smooth == smooth && cacheAdaptiveCci[idx].EqualsInput(input))
                        return cacheAdaptiveCci[idx];

            lock (checkAdaptiveCci)
            {
                checkAdaptiveCci.AdaptiveCciPlotNo = adaptiveCciPlotNo;
                adaptiveCciPlotNo = checkAdaptiveCci.AdaptiveCciPlotNo;
                checkAdaptiveCci.AltNumbarsPlot1 = altNumbarsPlot1;
                altNumbarsPlot1 = checkAdaptiveCci.AltNumbarsPlot1;
                checkAdaptiveCci.AltNumbarsPlot2 = altNumbarsPlot2;
                altNumbarsPlot2 = checkAdaptiveCci.AltNumbarsPlot2;
                checkAdaptiveCci.AltNumbarsPlot3 = altNumbarsPlot3;
                altNumbarsPlot3 = checkAdaptiveCci.AltNumbarsPlot3;
                checkAdaptiveCci.AltNumbarsPlot4 = altNumbarsPlot4;
                altNumbarsPlot4 = checkAdaptiveCci.AltNumbarsPlot4;
                checkAdaptiveCci.CycPart = cycPart;
                cycPart = checkAdaptiveCci.CycPart;
                checkAdaptiveCci.PeriodMultiplier = periodMultiplier;
                periodMultiplier = checkAdaptiveCci.PeriodMultiplier;
                checkAdaptiveCci.Smooth = smooth;
                smooth = checkAdaptiveCci.Smooth;

                if (cacheAdaptiveCci != null)
                    for (int idx = 0; idx < cacheAdaptiveCci.Length; idx++)
                        if (cacheAdaptiveCci[idx].AdaptiveCciPlotNo == adaptiveCciPlotNo && cacheAdaptiveCci[idx].AltNumbarsPlot1 == altNumbarsPlot1 && cacheAdaptiveCci[idx].AltNumbarsPlot2 == altNumbarsPlot2 && cacheAdaptiveCci[idx].AltNumbarsPlot3 == altNumbarsPlot3 && cacheAdaptiveCci[idx].AltNumbarsPlot4 == altNumbarsPlot4 && Math.Abs(cacheAdaptiveCci[idx].CycPart - cycPart) <= double.Epsilon && cacheAdaptiveCci[idx].PeriodMultiplier == periodMultiplier && cacheAdaptiveCci[idx].Smooth == smooth && cacheAdaptiveCci[idx].EqualsInput(input))
                            return cacheAdaptiveCci[idx];

                AdaptiveCci indicator = new AdaptiveCci();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.AdaptiveCciPlotNo = adaptiveCciPlotNo;
                indicator.AltNumbarsPlot1 = altNumbarsPlot1;
                indicator.AltNumbarsPlot2 = altNumbarsPlot2;
                indicator.AltNumbarsPlot3 = altNumbarsPlot3;
                indicator.AltNumbarsPlot4 = altNumbarsPlot4;
                indicator.CycPart = cycPart;
                indicator.PeriodMultiplier = periodMultiplier;
                indicator.Smooth = smooth;
                Indicators.Add(indicator);
                indicator.SetUp();

                AdaptiveCci[] tmp = new AdaptiveCci[cacheAdaptiveCci == null ? 1 : cacheAdaptiveCci.Length + 1];
                if (cacheAdaptiveCci != null)
                    cacheAdaptiveCci.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheAdaptiveCci = tmp;
                return indicator;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adaptive CCI
        /// </summary>
        /// <returns></returns>
        public AdaptiveCci AdaptiveCci(Data.IDataSeries input, AdaptiveCciPlots adaptiveCciPlotNo, int altNumbarsPlot1, int altNumbarsPlot2, int altNumbarsPlot3, int altNumbarsPlot4, double cycPart, int periodMultiplier, int smooth)
        {
            if (cacheAdaptiveCci != null)
            {
                for (int idx = 0; idx < cacheAdaptiveCci.Length; idx++)
                {
                    if (cacheAdaptiveCci[idx].AdaptiveCciPlotNo == adaptiveCciPlotNo && cacheAdaptiveCci[idx].AltNumbarsPlot1 == altNumbarsPlot1 && cacheAdaptiveCci[idx].AltNumbarsPlot2 == altNumbarsPlot2 && cacheAdaptiveCci[idx].AltNumbarsPlot3 == altNumbarsPlot3 && cacheAdaptiveCci[idx].AltNumbarsPlot4 == altNumbarsPlot4 && Math.Abs(cacheAdaptiveCci[idx].CycPart - cycPart) <= double.Epsilon && cacheAdaptiveCci[idx].PeriodMultiplier == periodMultiplier && cacheAdaptiveCci[idx].Smooth == smooth && cacheAdaptiveCci[idx].EqualsInput(input))
                    {
                        return(cacheAdaptiveCci[idx]);
                    }
                }
            }

            lock (checkAdaptiveCci)
            {
                checkAdaptiveCci.AdaptiveCciPlotNo = adaptiveCciPlotNo;
                adaptiveCciPlotNo = checkAdaptiveCci.AdaptiveCciPlotNo;
                checkAdaptiveCci.AltNumbarsPlot1 = altNumbarsPlot1;
                altNumbarsPlot1 = checkAdaptiveCci.AltNumbarsPlot1;
                checkAdaptiveCci.AltNumbarsPlot2 = altNumbarsPlot2;
                altNumbarsPlot2 = checkAdaptiveCci.AltNumbarsPlot2;
                checkAdaptiveCci.AltNumbarsPlot3 = altNumbarsPlot3;
                altNumbarsPlot3 = checkAdaptiveCci.AltNumbarsPlot3;
                checkAdaptiveCci.AltNumbarsPlot4 = altNumbarsPlot4;
                altNumbarsPlot4          = checkAdaptiveCci.AltNumbarsPlot4;
                checkAdaptiveCci.CycPart = cycPart;
                cycPart = checkAdaptiveCci.CycPart;
                checkAdaptiveCci.PeriodMultiplier = periodMultiplier;
                periodMultiplier        = checkAdaptiveCci.PeriodMultiplier;
                checkAdaptiveCci.Smooth = smooth;
                smooth = checkAdaptiveCci.Smooth;

                if (cacheAdaptiveCci != null)
                {
                    for (int idx = 0; idx < cacheAdaptiveCci.Length; idx++)
                    {
                        if (cacheAdaptiveCci[idx].AdaptiveCciPlotNo == adaptiveCciPlotNo && cacheAdaptiveCci[idx].AltNumbarsPlot1 == altNumbarsPlot1 && cacheAdaptiveCci[idx].AltNumbarsPlot2 == altNumbarsPlot2 && cacheAdaptiveCci[idx].AltNumbarsPlot3 == altNumbarsPlot3 && cacheAdaptiveCci[idx].AltNumbarsPlot4 == altNumbarsPlot4 && Math.Abs(cacheAdaptiveCci[idx].CycPart - cycPart) <= double.Epsilon && cacheAdaptiveCci[idx].PeriodMultiplier == periodMultiplier && cacheAdaptiveCci[idx].Smooth == smooth && cacheAdaptiveCci[idx].EqualsInput(input))
                        {
                            return(cacheAdaptiveCci[idx]);
                        }
                    }
                }

                AdaptiveCci indicator = new AdaptiveCci();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input             = input;
                indicator.AdaptiveCciPlotNo = adaptiveCciPlotNo;
                indicator.AltNumbarsPlot1   = altNumbarsPlot1;
                indicator.AltNumbarsPlot2   = altNumbarsPlot2;
                indicator.AltNumbarsPlot3   = altNumbarsPlot3;
                indicator.AltNumbarsPlot4   = altNumbarsPlot4;
                indicator.CycPart           = cycPart;
                indicator.PeriodMultiplier  = periodMultiplier;
                indicator.Smooth            = smooth;
                Indicators.Add(indicator);
                indicator.SetUp();

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