Esempio n. 1
0
        /// <summary>
        /// Linnear Regression Intercept
        /// </summary>
        /// <returns></returns>
        public LinRegIntercept LinRegIntercept(Data.IDataSeries input, int period)
        {
            if (cacheLinRegIntercept != null)
            {
                for (int idx = 0; idx < cacheLinRegIntercept.Length; idx++)
                {
                    if (cacheLinRegIntercept[idx].Period == period && cacheLinRegIntercept[idx].EqualsInput(input))
                    {
                        return(cacheLinRegIntercept[idx]);
                    }
                }
            }

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

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

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

                LinRegIntercept[] tmp = new LinRegIntercept[cacheLinRegIntercept == null ? 1 : cacheLinRegIntercept.Length + 1];
                if (cacheLinRegIntercept != null)
                {
                    cacheLinRegIntercept.CopyTo(tmp, 0);
                }
                tmp[tmp.Length - 1]  = indicator;
                cacheLinRegIntercept = tmp;
                return(indicator);
            }
        }
		/// <summary>
		/// Linnear Regression Intercept
		/// </summary>
		/// <returns></returns>
		public LinRegIntercept LinRegIntercept(Data.IDataSeries input, int period)
		{
			if (cacheLinRegIntercept != null)
				for (int idx = 0; idx < cacheLinRegIntercept.Length; idx++)
					if (cacheLinRegIntercept[idx].Period == period && cacheLinRegIntercept[idx].EqualsInput(input))
						return cacheLinRegIntercept[idx];

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

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

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

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