Ejemplo n.º 1
0
        /// <summary>
        /// Linear Regression Slope
        /// </summary>
        /// <returns></returns>
        public LinRegSlope LinRegSlope(Data.IDataSeries input, int period)
        {
            if (cacheLinRegSlope != null)
            {
                for (int idx = 0; idx < cacheLinRegSlope.Length; idx++)
                {
                    if (cacheLinRegSlope[idx].Period == period && cacheLinRegSlope[idx].EqualsInput(input))
                    {
                        return(cacheLinRegSlope[idx]);
                    }
                }
            }

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

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

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

                LinRegSlope[] tmp = new LinRegSlope[cacheLinRegSlope == null ? 1 : cacheLinRegSlope.Length + 1];
                if (cacheLinRegSlope != null)
                {
                    cacheLinRegSlope.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1] = indicator;
                cacheLinRegSlope    = tmp;
                return(indicator);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Linear Regression Slope
        /// </summary>
        /// <returns></returns>
        public LinRegSlope LinRegSlope(Data.IDataSeries input, int period)
        {
            if (cacheLinRegSlope != null)
                for (int idx = 0; idx < cacheLinRegSlope.Length; idx++)
                    if (cacheLinRegSlope[idx].Period == period && cacheLinRegSlope[idx].EqualsInput(input))
                        return cacheLinRegSlope[idx];

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

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

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

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