Exemple #1
0
        /// <summary>
        /// Keltner Band using JMA
        /// </summary>
        /// <returns></returns>
        public Jurik_JMA_Keltner Jurik_JMA_Keltner(Data.IDataSeries input, int band_delay, int band_len, double band_width)
        {
            if (cacheJurik_JMA_Keltner != null)
            {
                for (int idx = 0; idx < cacheJurik_JMA_Keltner.Length; idx++)
                {
                    if (cacheJurik_JMA_Keltner[idx].Band_delay == band_delay && cacheJurik_JMA_Keltner[idx].Band_len == band_len && Math.Abs(cacheJurik_JMA_Keltner[idx].Band_width - band_width) <= double.Epsilon && cacheJurik_JMA_Keltner[idx].EqualsInput(input))
                    {
                        return(cacheJurik_JMA_Keltner[idx]);
                    }
                }
            }

            lock (checkJurik_JMA_Keltner)
            {
                checkJurik_JMA_Keltner.Band_delay = band_delay;
                band_delay = checkJurik_JMA_Keltner.Band_delay;
                checkJurik_JMA_Keltner.Band_len = band_len;
                band_len = checkJurik_JMA_Keltner.Band_len;
                checkJurik_JMA_Keltner.Band_width = band_width;
                band_width = checkJurik_JMA_Keltner.Band_width;

                if (cacheJurik_JMA_Keltner != null)
                {
                    for (int idx = 0; idx < cacheJurik_JMA_Keltner.Length; idx++)
                    {
                        if (cacheJurik_JMA_Keltner[idx].Band_delay == band_delay && cacheJurik_JMA_Keltner[idx].Band_len == band_len && Math.Abs(cacheJurik_JMA_Keltner[idx].Band_width - band_width) <= double.Epsilon && cacheJurik_JMA_Keltner[idx].EqualsInput(input))
                        {
                            return(cacheJurik_JMA_Keltner[idx]);
                        }
                    }
                }

                Jurik_JMA_Keltner indicator = new Jurik_JMA_Keltner();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input      = input;
                indicator.Band_delay = band_delay;
                indicator.Band_len   = band_len;
                indicator.Band_width = band_width;
                Indicators.Add(indicator);
                indicator.SetUp();

                Jurik_JMA_Keltner[] tmp = new Jurik_JMA_Keltner[cacheJurik_JMA_Keltner == null ? 1 : cacheJurik_JMA_Keltner.Length + 1];
                if (cacheJurik_JMA_Keltner != null)
                {
                    cacheJurik_JMA_Keltner.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]    = indicator;
                cacheJurik_JMA_Keltner = tmp;
                return(indicator);
            }
        }
        /// <summary>
        /// Keltner Band using JMA
        /// </summary>
        /// <returns></returns>
        public Jurik_JMA_Keltner Jurik_JMA_Keltner(Data.IDataSeries input, int band_delay, int band_len, double band_width)
        {
            if (cacheJurik_JMA_Keltner != null)
                for (int idx = 0; idx < cacheJurik_JMA_Keltner.Length; idx++)
                    if (cacheJurik_JMA_Keltner[idx].Band_delay == band_delay && cacheJurik_JMA_Keltner[idx].Band_len == band_len && Math.Abs(cacheJurik_JMA_Keltner[idx].Band_width - band_width) <= double.Epsilon && cacheJurik_JMA_Keltner[idx].EqualsInput(input))
                        return cacheJurik_JMA_Keltner[idx];

            lock (checkJurik_JMA_Keltner)
            {
                checkJurik_JMA_Keltner.Band_delay = band_delay;
                band_delay = checkJurik_JMA_Keltner.Band_delay;
                checkJurik_JMA_Keltner.Band_len = band_len;
                band_len = checkJurik_JMA_Keltner.Band_len;
                checkJurik_JMA_Keltner.Band_width = band_width;
                band_width = checkJurik_JMA_Keltner.Band_width;

                if (cacheJurik_JMA_Keltner != null)
                    for (int idx = 0; idx < cacheJurik_JMA_Keltner.Length; idx++)
                        if (cacheJurik_JMA_Keltner[idx].Band_delay == band_delay && cacheJurik_JMA_Keltner[idx].Band_len == band_len && Math.Abs(cacheJurik_JMA_Keltner[idx].Band_width - band_width) <= double.Epsilon && cacheJurik_JMA_Keltner[idx].EqualsInput(input))
                            return cacheJurik_JMA_Keltner[idx];

                Jurik_JMA_Keltner indicator = new Jurik_JMA_Keltner();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Band_delay = band_delay;
                indicator.Band_len = band_len;
                indicator.Band_width = band_width;
                Indicators.Add(indicator);
                indicator.SetUp();

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