Example #1
0
        /// <summary>
        /// Measure the stretch for above EMA
        /// </summary>
        /// <returns></returns>
        public ZZStretchAwayEMATop ZZStretchAwayEMATop(Data.IDataSeries input, int eMALen)
        {
            if (cacheZZStretchAwayEMATop != null)
            {
                for (int idx = 0; idx < cacheZZStretchAwayEMATop.Length; idx++)
                {
                    if (cacheZZStretchAwayEMATop[idx].EMALen == eMALen && cacheZZStretchAwayEMATop[idx].EqualsInput(input))
                    {
                        return(cacheZZStretchAwayEMATop[idx]);
                    }
                }
            }

            lock (checkZZStretchAwayEMATop)
            {
                checkZZStretchAwayEMATop.EMALen = eMALen;
                eMALen = checkZZStretchAwayEMATop.EMALen;

                if (cacheZZStretchAwayEMATop != null)
                {
                    for (int idx = 0; idx < cacheZZStretchAwayEMATop.Length; idx++)
                    {
                        if (cacheZZStretchAwayEMATop[idx].EMALen == eMALen && cacheZZStretchAwayEMATop[idx].EqualsInput(input))
                        {
                            return(cacheZZStretchAwayEMATop[idx]);
                        }
                    }
                }

                ZZStretchAwayEMATop indicator = new ZZStretchAwayEMATop();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input  = input;
                indicator.EMALen = eMALen;
                Indicators.Add(indicator);
                indicator.SetUp();

                ZZStretchAwayEMATop[] tmp = new ZZStretchAwayEMATop[cacheZZStretchAwayEMATop == null ? 1 : cacheZZStretchAwayEMATop.Length + 1];
                if (cacheZZStretchAwayEMATop != null)
                {
                    cacheZZStretchAwayEMATop.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]      = indicator;
                cacheZZStretchAwayEMATop = tmp;
                return(indicator);
            }
        }
        /// <summary>
        /// Measure the stretch for above EMA
        /// </summary>
        /// <returns></returns>
        public ZZStretchAwayEMATop ZZStretchAwayEMATop(Data.IDataSeries input, int eMALen)
        {
            if (cacheZZStretchAwayEMATop != null)
                for (int idx = 0; idx < cacheZZStretchAwayEMATop.Length; idx++)
                    if (cacheZZStretchAwayEMATop[idx].EMALen == eMALen && cacheZZStretchAwayEMATop[idx].EqualsInput(input))
                        return cacheZZStretchAwayEMATop[idx];

            lock (checkZZStretchAwayEMATop)
            {
                checkZZStretchAwayEMATop.EMALen = eMALen;
                eMALen = checkZZStretchAwayEMATop.EMALen;

                if (cacheZZStretchAwayEMATop != null)
                    for (int idx = 0; idx < cacheZZStretchAwayEMATop.Length; idx++)
                        if (cacheZZStretchAwayEMATop[idx].EMALen == eMALen && cacheZZStretchAwayEMATop[idx].EqualsInput(input))
                            return cacheZZStretchAwayEMATop[idx];

                ZZStretchAwayEMATop indicator = new ZZStretchAwayEMATop();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.EMALen = eMALen;
                Indicators.Add(indicator);
                indicator.SetUp();

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