/// <summary> /// R-squared indicator /// </summary> /// <returns></returns> public RSquared RSquared(Data.IDataSeries input, int period) { if (cacheRSquared != null) { for (int idx = 0; idx < cacheRSquared.Length; idx++) { if (cacheRSquared[idx].Period == period && cacheRSquared[idx].EqualsInput(input)) { return(cacheRSquared[idx]); } } } lock (checkRSquared) { checkRSquared.Period = period; period = checkRSquared.Period; if (cacheRSquared != null) { for (int idx = 0; idx < cacheRSquared.Length; idx++) { if (cacheRSquared[idx].Period == period && cacheRSquared[idx].EqualsInput(input)) { return(cacheRSquared[idx]); } } } RSquared indicator = new RSquared(); 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(); RSquared[] tmp = new RSquared[cacheRSquared == null ? 1 : cacheRSquared.Length + 1]; if (cacheRSquared != null) { cacheRSquared.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheRSquared = tmp; return(indicator); } }
/// <summary> /// R-squared indicator /// </summary> /// <returns></returns> public RSquared RSquared(Data.IDataSeries input, int period) { if (cacheRSquared != null) for (int idx = 0; idx < cacheRSquared.Length; idx++) if (cacheRSquared[idx].Period == period && cacheRSquared[idx].EqualsInput(input)) return cacheRSquared[idx]; lock (checkRSquared) { checkRSquared.Period = period; period = checkRSquared.Period; if (cacheRSquared != null) for (int idx = 0; idx < cacheRSquared.Length; idx++) if (cacheRSquared[idx].Period == period && cacheRSquared[idx].EqualsInput(input)) return cacheRSquared[idx]; RSquared indicator = new RSquared(); 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(); RSquared[] tmp = new RSquared[cacheRSquared == null ? 1 : cacheRSquared.Length + 1]; if (cacheRSquared != null) cacheRSquared.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheRSquared = tmp; return indicator; } }