/// <summary> /// TSSuperTrend Indicator developed by TradingStudies.com (Vertsion 2.3) /// </summary> /// <returns></returns> public TSSuperTrend TSSuperTrend(Data.IDataSeries input, int length, MovingAverageType maType, double multiplier, int smooth, SuperTrendMode stMode) { if (cacheTSSuperTrend != null) for (int idx = 0; idx < cacheTSSuperTrend.Length; idx++) if (cacheTSSuperTrend[idx].Length == length && cacheTSSuperTrend[idx].MaType == maType && Math.Abs(cacheTSSuperTrend[idx].Multiplier - multiplier) <= double.Epsilon && cacheTSSuperTrend[idx].Smooth == smooth && cacheTSSuperTrend[idx].StMode == stMode && cacheTSSuperTrend[idx].EqualsInput(input)) return cacheTSSuperTrend[idx]; lock (checkTSSuperTrend) { checkTSSuperTrend.Length = length; length = checkTSSuperTrend.Length; checkTSSuperTrend.MaType = maType; maType = checkTSSuperTrend.MaType; checkTSSuperTrend.Multiplier = multiplier; multiplier = checkTSSuperTrend.Multiplier; checkTSSuperTrend.Smooth = smooth; smooth = checkTSSuperTrend.Smooth; checkTSSuperTrend.StMode = stMode; stMode = checkTSSuperTrend.StMode; if (cacheTSSuperTrend != null) for (int idx = 0; idx < cacheTSSuperTrend.Length; idx++) if (cacheTSSuperTrend[idx].Length == length && cacheTSSuperTrend[idx].MaType == maType && Math.Abs(cacheTSSuperTrend[idx].Multiplier - multiplier) <= double.Epsilon && cacheTSSuperTrend[idx].Smooth == smooth && cacheTSSuperTrend[idx].StMode == stMode && cacheTSSuperTrend[idx].EqualsInput(input)) return cacheTSSuperTrend[idx]; TSSuperTrend indicator = new TSSuperTrend(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.Length = length; indicator.MaType = maType; indicator.Multiplier = multiplier; indicator.Smooth = smooth; indicator.StMode = stMode; Indicators.Add(indicator); indicator.SetUp(); TSSuperTrend[] tmp = new TSSuperTrend[cacheTSSuperTrend == null ? 1 : cacheTSSuperTrend.Length + 1]; if (cacheTSSuperTrend != null) cacheTSSuperTrend.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheTSSuperTrend = tmp; return indicator; } }
/// <summary> /// TSSuperTrend Indicator developed by TradingStudies.com (Version 2.5) /// </summary> /// <returns></returns> public TSSuperTrend TSSuperTrend(Data.IDataSeries input, int length, MovingAverageType maType, double multiplier, int smooth, SuperTrendMode stMode) { if (cacheTSSuperTrend != null) for (int idx = 0; idx < cacheTSSuperTrend.Length; idx++) if (cacheTSSuperTrend[idx].Length == length && cacheTSSuperTrend[idx].MaType == maType && Math.Abs(cacheTSSuperTrend[idx].Multiplier - multiplier) <= double.Epsilon && cacheTSSuperTrend[idx].Smooth == smooth && cacheTSSuperTrend[idx].StMode == stMode && cacheTSSuperTrend[idx].EqualsInput(input)) return cacheTSSuperTrend[idx]; lock (checkTSSuperTrend) { checkTSSuperTrend.Length = length; length = checkTSSuperTrend.Length; checkTSSuperTrend.MaType = maType; maType = checkTSSuperTrend.MaType; checkTSSuperTrend.Multiplier = multiplier; multiplier = checkTSSuperTrend.Multiplier; checkTSSuperTrend.Smooth = smooth; smooth = checkTSSuperTrend.Smooth; checkTSSuperTrend.StMode = stMode; stMode = checkTSSuperTrend.StMode; if (cacheTSSuperTrend != null) for (int idx = 0; idx < cacheTSSuperTrend.Length; idx++) if (cacheTSSuperTrend[idx].Length == length && cacheTSSuperTrend[idx].MaType == maType && Math.Abs(cacheTSSuperTrend[idx].Multiplier - multiplier) <= double.Epsilon && cacheTSSuperTrend[idx].Smooth == smooth && cacheTSSuperTrend[idx].StMode == stMode && cacheTSSuperTrend[idx].EqualsInput(input)) return cacheTSSuperTrend[idx]; TSSuperTrend indicator = new TSSuperTrend(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.Length = length; indicator.MaType = maType; indicator.Multiplier = multiplier; indicator.Smooth = smooth; indicator.StMode = stMode; Indicators.Add(indicator); indicator.SetUp(); TSSuperTrend[] tmp = new TSSuperTrend[cacheTSSuperTrend == null ? 1 : cacheTSSuperTrend.Length + 1]; if (cacheTSSuperTrend != null) cacheTSSuperTrend.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheTSSuperTrend = tmp; return indicator; } }