/// <summary> /// PTS trend indicator. /// </summary> /// <returns></returns> public AbTrend ABTrend(Data.IDataSeries input, int period, double phase) { if (cacheABTrend != null) { for (int idx = 0; idx < cacheABTrend.Length; idx++) { if (cacheABTrend[idx].Period == period && Math.Abs(cacheABTrend[idx].Phase - phase) <= double.Epsilon && cacheABTrend[idx].EqualsInput(input)) { return(cacheABTrend[idx]); } } } lock (checkABTrend) { checkABTrend.Period = period; period = checkABTrend.Period; checkABTrend.Phase = phase; phase = checkABTrend.Phase; if (cacheABTrend != null) { for (int idx = 0; idx < cacheABTrend.Length; idx++) { if (cacheABTrend[idx].Period == period && Math.Abs(cacheABTrend[idx].Phase - phase) <= double.Epsilon && cacheABTrend[idx].EqualsInput(input)) { return(cacheABTrend[idx]); } } } AbTrend indicator = new AbTrend(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.Period = period; indicator.Phase = phase; Indicators.Add(indicator); indicator.SetUp(); AbTrend[] tmp = new AbTrend[cacheABTrend == null ? 1 : cacheABTrend.Length + 1]; if (cacheABTrend != null) { cacheABTrend.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheABTrend = tmp; return(indicator); } }
/// <summary> /// PTS trend indicator. /// </summary> /// <returns></returns> public AbTrend ABTrend(Data.IDataSeries input, int period, double phase) { if (cacheABTrend != null) for (int idx = 0; idx < cacheABTrend.Length; idx++) if (cacheABTrend[idx].Period == period && Math.Abs(cacheABTrend[idx].Phase - phase) <= double.Epsilon && cacheABTrend[idx].EqualsInput(input)) return cacheABTrend[idx]; lock (checkABTrend) { checkABTrend.Period = period; period = checkABTrend.Period; checkABTrend.Phase = phase; phase = checkABTrend.Phase; if (cacheABTrend != null) for (int idx = 0; idx < cacheABTrend.Length; idx++) if (cacheABTrend[idx].Period == period && Math.Abs(cacheABTrend[idx].Phase - phase) <= double.Epsilon && cacheABTrend[idx].EqualsInput(input)) return cacheABTrend[idx]; AbTrend indicator = new AbTrend(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.Period = period; indicator.Phase = phase; Indicators.Add(indicator); indicator.SetUp(); AbTrend[] tmp = new AbTrend[cacheABTrend == null ? 1 : cacheABTrend.Length + 1]; if (cacheABTrend != null) cacheABTrend.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheABTrend = tmp; return indicator; } }