Exemplo n.º 1
0
        /// <summary>
        /// Triple Exponential Moving Average
        /// </summary>
        /// <returns></returns>
        public TEMA TEMA(Data.IDataSeries input, int period)
        {
            if (cacheTEMA != null)
            {
                for (int idx = 0; idx < cacheTEMA.Length; idx++)
                {
                    if (cacheTEMA[idx].Period == period && cacheTEMA[idx].EqualsInput(input))
                    {
                        return(cacheTEMA[idx]);
                    }
                }
            }

            lock (checkTEMA)
            {
                checkTEMA.Period = period;
                period           = checkTEMA.Period;

                if (cacheTEMA != null)
                {
                    for (int idx = 0; idx < cacheTEMA.Length; idx++)
                    {
                        if (cacheTEMA[idx].Period == period && cacheTEMA[idx].EqualsInput(input))
                        {
                            return(cacheTEMA[idx]);
                        }
                    }
                }

                TEMA indicator = new TEMA();
                indicator.BarsRequired        = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack         = MaximumBarsLookBack;
#endif
                indicator.Input  = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                TEMA[] tmp = new TEMA[cacheTEMA == null ? 1 : cacheTEMA.Length + 1];
                if (cacheTEMA != null)
                {
                    cacheTEMA.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheTEMA           = tmp;
                return(indicator);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Triple Exponential Moving Average
        /// </summary>
        /// <returns></returns>
        public TEMA TEMA(Data.IDataSeries input, int period)
        {
            if (cacheTEMA != null)
                for (int idx = 0; idx < cacheTEMA.Length; idx++)
                    if (cacheTEMA[idx].Period == period && cacheTEMA[idx].EqualsInput(input))
                        return cacheTEMA[idx];

            lock (checkTEMA)
            {
                checkTEMA.Period = period;
                period = checkTEMA.Period;

                if (cacheTEMA != null)
                    for (int idx = 0; idx < cacheTEMA.Length; idx++)
                        if (cacheTEMA[idx].Period == period && cacheTEMA[idx].EqualsInput(input))
                            return cacheTEMA[idx];

                TEMA indicator = new TEMA();
                indicator.BarsRequired = BarsRequired;
                indicator.CalculateOnBarClose = CalculateOnBarClose;
#if NT7
                indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                indicator.MaximumBarsLookBack = MaximumBarsLookBack;
#endif
                indicator.Input = input;
                indicator.Period = period;
                Indicators.Add(indicator);
                indicator.SetUp();

                TEMA[] tmp = new TEMA[cacheTEMA == null ? 1 : cacheTEMA.Length + 1];
                if (cacheTEMA != null)
                    cacheTEMA.CopyTo(tmp, 0);
                tmp[tmp.Length - 1] = indicator;
                cacheTEMA = tmp;
                return indicator;
            }
        }
Exemplo n.º 3
0
 protected override void OnStartUp()
 {
     tema1 = TEMA(Inputs[0], Period);
     tema2 = TEMA(tema1, Period);
 }