示例#1
0
        /// <summary>
        /// Tillsons T3 moving average
        /// </summary>
        /// <returns></returns>
        public Jurik_Tillson_T3 Jurik_Tillson_T3(Data.IDataSeries input, double t3_boost, double t3_len)
        {
            if (cacheJurik_Tillson_T3 != null)
            {
                for (int idx = 0; idx < cacheJurik_Tillson_T3.Length; idx++)
                {
                    if (Math.Abs(cacheJurik_Tillson_T3[idx].T3_boost - t3_boost) <= double.Epsilon && Math.Abs(cacheJurik_Tillson_T3[idx].T3_len - t3_len) <= double.Epsilon && cacheJurik_Tillson_T3[idx].EqualsInput(input))
                    {
                        return(cacheJurik_Tillson_T3[idx]);
                    }
                }
            }

            lock (checkJurik_Tillson_T3)
            {
                checkJurik_Tillson_T3.T3_boost = t3_boost;
                t3_boost = checkJurik_Tillson_T3.T3_boost;
                checkJurik_Tillson_T3.T3_len = t3_len;
                t3_len = checkJurik_Tillson_T3.T3_len;

                if (cacheJurik_Tillson_T3 != null)
                {
                    for (int idx = 0; idx < cacheJurik_Tillson_T3.Length; idx++)
                    {
                        if (Math.Abs(cacheJurik_Tillson_T3[idx].T3_boost - t3_boost) <= double.Epsilon && Math.Abs(cacheJurik_Tillson_T3[idx].T3_len - t3_len) <= double.Epsilon && cacheJurik_Tillson_T3[idx].EqualsInput(input))
                        {
                            return(cacheJurik_Tillson_T3[idx]);
                        }
                    }
                }

                Jurik_Tillson_T3 indicator = new Jurik_Tillson_T3();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input    = input;
                indicator.T3_boost = t3_boost;
                indicator.T3_len   = t3_len;
                Indicators.Add(indicator);
                indicator.SetUp();

                Jurik_Tillson_T3[] tmp = new Jurik_Tillson_T3[cacheJurik_Tillson_T3 == null ? 1 : cacheJurik_Tillson_T3.Length + 1];
                if (cacheJurik_Tillson_T3 != null)
                {
                    cacheJurik_Tillson_T3.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]   = indicator;
                cacheJurik_Tillson_T3 = tmp;
                return(indicator);
            }
        }
        /// <summary>
        /// Tillsons T3 moving average
        /// </summary>
        /// <returns></returns>
        public Jurik_Tillson_T3 Jurik_Tillson_T3(Data.IDataSeries input, double t3_boost, double t3_len)
        {
            if (cacheJurik_Tillson_T3 != null)
                for (int idx = 0; idx < cacheJurik_Tillson_T3.Length; idx++)
                    if (Math.Abs(cacheJurik_Tillson_T3[idx].T3_boost - t3_boost) <= double.Epsilon && Math.Abs(cacheJurik_Tillson_T3[idx].T3_len - t3_len) <= double.Epsilon && cacheJurik_Tillson_T3[idx].EqualsInput(input))
                        return cacheJurik_Tillson_T3[idx];

            lock (checkJurik_Tillson_T3)
            {
                checkJurik_Tillson_T3.T3_boost = t3_boost;
                t3_boost = checkJurik_Tillson_T3.T3_boost;
                checkJurik_Tillson_T3.T3_len = t3_len;
                t3_len = checkJurik_Tillson_T3.T3_len;

                if (cacheJurik_Tillson_T3 != null)
                    for (int idx = 0; idx < cacheJurik_Tillson_T3.Length; idx++)
                        if (Math.Abs(cacheJurik_Tillson_T3[idx].T3_boost - t3_boost) <= double.Epsilon && Math.Abs(cacheJurik_Tillson_T3[idx].T3_len - t3_len) <= double.Epsilon && cacheJurik_Tillson_T3[idx].EqualsInput(input))
                            return cacheJurik_Tillson_T3[idx];

                Jurik_Tillson_T3 indicator = new Jurik_Tillson_T3();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.T3_boost = t3_boost;
                indicator.T3_len = t3_len;
                Indicators.Add(indicator);
                indicator.SetUp();

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