Beispiel #1
0
        /// <summary>
        /// The Sum shows the summation of the last n data points.
        /// </summary>
        /// <returns></returns>
        public SUM SUM(Data.IDataSeries input, int period)
        {
            if (cacheSUM != null)
            {
                for (int idx = 0; idx < cacheSUM.Length; idx++)
                {
                    if (cacheSUM[idx].Period == period && cacheSUM[idx].EqualsInput(input))
                    {
                        return(cacheSUM[idx]);
                    }
                }
            }

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

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

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

                SUM[] tmp = new SUM[cacheSUM == null ? 1 : cacheSUM.Length + 1];
                if (cacheSUM != null)
                {
                    cacheSUM.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheSUM            = tmp;
                return(indicator);
            }
        }
Beispiel #2
0
        /// <summary>
        /// The Sum shows the summation of the last n data points.
        /// </summary>
        /// <returns></returns>
        public SUM SUM(Data.IDataSeries input, int period)
        {
            if (cacheSUM != null)
                for (int idx = 0; idx < cacheSUM.Length; idx++)
                    if (cacheSUM[idx].Period == period && cacheSUM[idx].EqualsInput(input))
                        return cacheSUM[idx];

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

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

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

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