예제 #1
0
        /// <summary>
        /// Cummulative RSI2 to be used with strategy
        /// </summary>
        /// <returns></returns>
        public ZZCummulativeRSI ZZCummulativeRSI(Data.IDataSeries input, int cummRSIThres, int numDaysX, int rSILen)
        {
            if (cacheZZCummulativeRSI != null)
            {
                for (int idx = 0; idx < cacheZZCummulativeRSI.Length; idx++)
                {
                    if (cacheZZCummulativeRSI[idx].CummRSIThres == cummRSIThres && cacheZZCummulativeRSI[idx].NumDaysX == numDaysX && cacheZZCummulativeRSI[idx].RSILen == rSILen && cacheZZCummulativeRSI[idx].EqualsInput(input))
                    {
                        return(cacheZZCummulativeRSI[idx]);
                    }
                }
            }

            lock (checkZZCummulativeRSI)
            {
                checkZZCummulativeRSI.CummRSIThres = cummRSIThres;
                cummRSIThres = checkZZCummulativeRSI.CummRSIThres;
                checkZZCummulativeRSI.NumDaysX = numDaysX;
                numDaysX = checkZZCummulativeRSI.NumDaysX;
                checkZZCummulativeRSI.RSILen = rSILen;
                rSILen = checkZZCummulativeRSI.RSILen;

                if (cacheZZCummulativeRSI != null)
                {
                    for (int idx = 0; idx < cacheZZCummulativeRSI.Length; idx++)
                    {
                        if (cacheZZCummulativeRSI[idx].CummRSIThres == cummRSIThres && cacheZZCummulativeRSI[idx].NumDaysX == numDaysX && cacheZZCummulativeRSI[idx].RSILen == rSILen && cacheZZCummulativeRSI[idx].EqualsInput(input))
                        {
                            return(cacheZZCummulativeRSI[idx]);
                        }
                    }
                }

                ZZCummulativeRSI indicator = new ZZCummulativeRSI();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input        = input;
                indicator.CummRSIThres = cummRSIThres;
                indicator.NumDaysX     = numDaysX;
                indicator.RSILen       = rSILen;
                Indicators.Add(indicator);
                indicator.SetUp();

                ZZCummulativeRSI[] tmp = new ZZCummulativeRSI[cacheZZCummulativeRSI == null ? 1 : cacheZZCummulativeRSI.Length + 1];
                if (cacheZZCummulativeRSI != null)
                {
                    cacheZZCummulativeRSI.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]   = indicator;
                cacheZZCummulativeRSI = tmp;
                return(indicator);
            }
        }
예제 #2
0
        /// <summary>
        /// Cummulative RSI2 to be used with strategy
        /// </summary>
        /// <returns></returns>
        public ZZCummulativeRSI ZZCummulativeRSI(Data.IDataSeries input, int cummRSIThres, int numDaysX, int rSILen)
        {
            if (cacheZZCummulativeRSI != null)
                for (int idx = 0; idx < cacheZZCummulativeRSI.Length; idx++)
                    if (cacheZZCummulativeRSI[idx].CummRSIThres == cummRSIThres && cacheZZCummulativeRSI[idx].NumDaysX == numDaysX && cacheZZCummulativeRSI[idx].RSILen == rSILen && cacheZZCummulativeRSI[idx].EqualsInput(input))
                        return cacheZZCummulativeRSI[idx];

            lock (checkZZCummulativeRSI)
            {
                checkZZCummulativeRSI.CummRSIThres = cummRSIThres;
                cummRSIThres = checkZZCummulativeRSI.CummRSIThres;
                checkZZCummulativeRSI.NumDaysX = numDaysX;
                numDaysX = checkZZCummulativeRSI.NumDaysX;
                checkZZCummulativeRSI.RSILen = rSILen;
                rSILen = checkZZCummulativeRSI.RSILen;

                if (cacheZZCummulativeRSI != null)
                    for (int idx = 0; idx < cacheZZCummulativeRSI.Length; idx++)
                        if (cacheZZCummulativeRSI[idx].CummRSIThres == cummRSIThres && cacheZZCummulativeRSI[idx].NumDaysX == numDaysX && cacheZZCummulativeRSI[idx].RSILen == rSILen && cacheZZCummulativeRSI[idx].EqualsInput(input))
                            return cacheZZCummulativeRSI[idx];

                ZZCummulativeRSI indicator = new ZZCummulativeRSI();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.CummRSIThres = cummRSIThres;
                indicator.NumDaysX = numDaysX;
                indicator.RSILen = rSILen;
                Indicators.Add(indicator);
                indicator.SetUp();

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