コード例 #1
0
        /// <summary>
        /// Quantifying slope od EMA
        /// </summary>
        /// <returns></returns>
        public ZZSlopeQuant ZZSlopeQuant(Data.IDataSeries input, int eMAPeriod, int lookbackBars)
        {
            if (cacheZZSlopeQuant != null)
            {
                for (int idx = 0; idx < cacheZZSlopeQuant.Length; idx++)
                {
                    if (cacheZZSlopeQuant[idx].EMAPeriod == eMAPeriod && cacheZZSlopeQuant[idx].LookbackBars == lookbackBars && cacheZZSlopeQuant[idx].EqualsInput(input))
                    {
                        return(cacheZZSlopeQuant[idx]);
                    }
                }
            }

            lock (checkZZSlopeQuant)
            {
                checkZZSlopeQuant.EMAPeriod = eMAPeriod;
                eMAPeriod = checkZZSlopeQuant.EMAPeriod;
                checkZZSlopeQuant.LookbackBars = lookbackBars;
                lookbackBars = checkZZSlopeQuant.LookbackBars;

                if (cacheZZSlopeQuant != null)
                {
                    for (int idx = 0; idx < cacheZZSlopeQuant.Length; idx++)
                    {
                        if (cacheZZSlopeQuant[idx].EMAPeriod == eMAPeriod && cacheZZSlopeQuant[idx].LookbackBars == lookbackBars && cacheZZSlopeQuant[idx].EqualsInput(input))
                        {
                            return(cacheZZSlopeQuant[idx]);
                        }
                    }
                }

                ZZSlopeQuant indicator = new ZZSlopeQuant();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input        = input;
                indicator.EMAPeriod    = eMAPeriod;
                indicator.LookbackBars = lookbackBars;
                Indicators.Add(indicator);
                indicator.SetUp();

                ZZSlopeQuant[] tmp = new ZZSlopeQuant[cacheZZSlopeQuant == null ? 1 : cacheZZSlopeQuant.Length + 1];
                if (cacheZZSlopeQuant != null)
                {
                    cacheZZSlopeQuant.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheZZSlopeQuant   = tmp;
                return(indicator);
            }
        }
コード例 #2
0
        /// <summary>
        /// Quantifying slope od EMA
        /// </summary>
        /// <returns></returns>
        public ZZSlopeQuant ZZSlopeQuant(Data.IDataSeries input, int eMAPeriod, int lookbackBars)
        {
            if (cacheZZSlopeQuant != null)
                for (int idx = 0; idx < cacheZZSlopeQuant.Length; idx++)
                    if (cacheZZSlopeQuant[idx].EMAPeriod == eMAPeriod && cacheZZSlopeQuant[idx].LookbackBars == lookbackBars && cacheZZSlopeQuant[idx].EqualsInput(input))
                        return cacheZZSlopeQuant[idx];

            lock (checkZZSlopeQuant)
            {
                checkZZSlopeQuant.EMAPeriod = eMAPeriod;
                eMAPeriod = checkZZSlopeQuant.EMAPeriod;
                checkZZSlopeQuant.LookbackBars = lookbackBars;
                lookbackBars = checkZZSlopeQuant.LookbackBars;

                if (cacheZZSlopeQuant != null)
                    for (int idx = 0; idx < cacheZZSlopeQuant.Length; idx++)
                        if (cacheZZSlopeQuant[idx].EMAPeriod == eMAPeriod && cacheZZSlopeQuant[idx].LookbackBars == lookbackBars && cacheZZSlopeQuant[idx].EqualsInput(input))
                            return cacheZZSlopeQuant[idx];

                ZZSlopeQuant indicator = new ZZSlopeQuant();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.EMAPeriod = eMAPeriod;
                indicator.LookbackBars = lookbackBars;
                Indicators.Add(indicator);
                indicator.SetUp();

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