Beispiel #1
0
        /// <summary>
        /// The SMMA (Smoothed Moving Average) is an indicator that shows the average value of a security's price over a period of time.
        /// </summary>
        /// <returns></returns>
        public SMMA SMMA(Data.IDataSeries input, int period)
        {
            if (cacheSMMA != null)
            {
                for (int idx = 0; idx < cacheSMMA.Length; idx++)
                {
                    if (cacheSMMA[idx].Period == period && cacheSMMA[idx].EqualsInput(input))
                    {
                        return(cacheSMMA[idx]);
                    }
                }
            }

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

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

                SMMA indicator = new SMMA();
                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();

                SMMA[] tmp = new SMMA[cacheSMMA == null ? 1 : cacheSMMA.Length + 1];
                if (cacheSMMA != null)
                {
                    cacheSMMA.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheSMMA           = tmp;
                return(indicator);
            }
        }
Beispiel #2
0
        /// <summary>
        /// The SMMA (Smoothed Moving Average) is an indicator that shows the average value of a security's price over a period of time.
        /// </summary>
        /// <returns></returns>
        public SMMA SMMA(Data.IDataSeries input, int period)
        {
            if (cacheSMMA != null)
                for (int idx = 0; idx < cacheSMMA.Length; idx++)
                    if (cacheSMMA[idx].Period == period && cacheSMMA[idx].EqualsInput(input))
                        return cacheSMMA[idx];

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

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

                SMMA indicator = new SMMA();
                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();

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