Ejemplo n.º 1
0
        /// <summary>
        /// T3 Moving Average
        /// </summary>
        /// <returns></returns>
        public T3 T3(Data.IDataSeries input, int period, int tCount, double vFactor)
        {
            if (cacheT3 != null)
            {
                for (int idx = 0; idx < cacheT3.Length; idx++)
                {
                    if (cacheT3[idx].Period == period && cacheT3[idx].TCount == tCount && Math.Abs(cacheT3[idx].VFactor - vFactor) <= double.Epsilon && cacheT3[idx].EqualsInput(input))
                    {
                        return(cacheT3[idx]);
                    }
                }
            }

            lock (checkT3)
            {
                checkT3.Period  = period;
                period          = checkT3.Period;
                checkT3.TCount  = tCount;
                tCount          = checkT3.TCount;
                checkT3.VFactor = vFactor;
                vFactor         = checkT3.VFactor;

                if (cacheT3 != null)
                {
                    for (int idx = 0; idx < cacheT3.Length; idx++)
                    {
                        if (cacheT3[idx].Period == period && cacheT3[idx].TCount == tCount && Math.Abs(cacheT3[idx].VFactor - vFactor) <= double.Epsilon && cacheT3[idx].EqualsInput(input))
                        {
                            return(cacheT3[idx]);
                        }
                    }
                }

                T3 indicator = new T3();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input   = input;
                indicator.Period  = period;
                indicator.TCount  = tCount;
                indicator.VFactor = vFactor;
                Indicators.Add(indicator);
                indicator.SetUp();

                T3[] tmp = new T3[cacheT3 == null ? 1 : cacheT3.Length + 1];
                if (cacheT3 != null)
                {
                    cacheT3.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheT3             = tmp;
                return(indicator);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// T3 Moving Average
        /// </summary>
        /// <returns></returns>
        public T3 T3(Data.IDataSeries input, int period, int tCount, double vFactor)
        {
            if (cacheT3 != null)
                for (int idx = 0; idx < cacheT3.Length; idx++)
                    if (cacheT3[idx].Period == period && cacheT3[idx].TCount == tCount && Math.Abs(cacheT3[idx].VFactor - vFactor) <= double.Epsilon && cacheT3[idx].EqualsInput(input))
                        return cacheT3[idx];

            lock (checkT3)
            {
                checkT3.Period = period;
                period = checkT3.Period;
                checkT3.TCount = tCount;
                tCount = checkT3.TCount;
                checkT3.VFactor = vFactor;
                vFactor = checkT3.VFactor;

                if (cacheT3 != null)
                    for (int idx = 0; idx < cacheT3.Length; idx++)
                        if (cacheT3[idx].Period == period && cacheT3[idx].TCount == tCount && Math.Abs(cacheT3[idx].VFactor - vFactor) <= double.Epsilon && cacheT3[idx].EqualsInput(input))
                            return cacheT3[idx];

                T3 indicator = new T3();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Period = period;
                indicator.TCount = tCount;
                indicator.VFactor = vFactor;
                Indicators.Add(indicator);
                indicator.SetUp();

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