/// <summary> /// The Linear Regression is an indicator that 'predicts' the value of a security's price. /// </summary> /// <returns></returns> public LinReg LinReg(Data.IDataSeries input, int period) { if (cacheLinReg != null) { for (int idx = 0; idx < cacheLinReg.Length; idx++) { if (cacheLinReg[idx].Period == period && cacheLinReg[idx].EqualsInput(input)) { return(cacheLinReg[idx]); } } } lock (checkLinReg) { checkLinReg.Period = period; period = checkLinReg.Period; if (cacheLinReg != null) { for (int idx = 0; idx < cacheLinReg.Length; idx++) { if (cacheLinReg[idx].Period == period && cacheLinReg[idx].EqualsInput(input)) { return(cacheLinReg[idx]); } } } LinReg indicator = new LinReg(); 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(); LinReg[] tmp = new LinReg[cacheLinReg == null ? 1 : cacheLinReg.Length + 1]; if (cacheLinReg != null) { cacheLinReg.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheLinReg = tmp; return(indicator); } }
/// <summary> /// The Linear Regression is an indicator that 'predicts' the value of a security's price. /// </summary> /// <returns></returns> public LinReg LinReg(Data.IDataSeries input, int period) { if (cacheLinReg != null) for (int idx = 0; idx < cacheLinReg.Length; idx++) if (cacheLinReg[idx].Period == period && cacheLinReg[idx].EqualsInput(input)) return cacheLinReg[idx]; lock (checkLinReg) { checkLinReg.Period = period; period = checkLinReg.Period; if (cacheLinReg != null) for (int idx = 0; idx < cacheLinReg.Length; idx++) if (cacheLinReg[idx].Period == period && cacheLinReg[idx].EqualsInput(input)) return cacheLinReg[idx]; LinReg indicator = new LinReg(); 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(); LinReg[] tmp = new LinReg[cacheLinReg == null ? 1 : cacheLinReg.Length + 1]; if (cacheLinReg != null) cacheLinReg.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheLinReg = tmp; return indicator; } }