/// <summary> /// My specialized indicator /// </summary> /// <returns></returns> public GekkoTrendByMAIndicator GekkoTrendByMAIndicator(Data.IDataSeries input, int aTRPeriod, int sMAPeriod1, int sMAPeriod2) { if (cacheGekkoTrendByMAIndicator != null) { for (int idx = 0; idx < cacheGekkoTrendByMAIndicator.Length; idx++) { if (cacheGekkoTrendByMAIndicator[idx].ATRPeriod == aTRPeriod && cacheGekkoTrendByMAIndicator[idx].SMAPeriod1 == sMAPeriod1 && cacheGekkoTrendByMAIndicator[idx].SMAPeriod2 == sMAPeriod2 && cacheGekkoTrendByMAIndicator[idx].EqualsInput(input)) { return(cacheGekkoTrendByMAIndicator[idx]); } } } lock (checkGekkoTrendByMAIndicator) { checkGekkoTrendByMAIndicator.ATRPeriod = aTRPeriod; aTRPeriod = checkGekkoTrendByMAIndicator.ATRPeriod; checkGekkoTrendByMAIndicator.SMAPeriod1 = sMAPeriod1; sMAPeriod1 = checkGekkoTrendByMAIndicator.SMAPeriod1; checkGekkoTrendByMAIndicator.SMAPeriod2 = sMAPeriod2; sMAPeriod2 = checkGekkoTrendByMAIndicator.SMAPeriod2; if (cacheGekkoTrendByMAIndicator != null) { for (int idx = 0; idx < cacheGekkoTrendByMAIndicator.Length; idx++) { if (cacheGekkoTrendByMAIndicator[idx].ATRPeriod == aTRPeriod && cacheGekkoTrendByMAIndicator[idx].SMAPeriod1 == sMAPeriod1 && cacheGekkoTrendByMAIndicator[idx].SMAPeriod2 == sMAPeriod2 && cacheGekkoTrendByMAIndicator[idx].EqualsInput(input)) { return(cacheGekkoTrendByMAIndicator[idx]); } } } GekkoTrendByMAIndicator indicator = new GekkoTrendByMAIndicator(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.ATRPeriod = aTRPeriod; indicator.SMAPeriod1 = sMAPeriod1; indicator.SMAPeriod2 = sMAPeriod2; Indicators.Add(indicator); indicator.SetUp(); GekkoTrendByMAIndicator[] tmp = new GekkoTrendByMAIndicator[cacheGekkoTrendByMAIndicator == null ? 1 : cacheGekkoTrendByMAIndicator.Length + 1]; if (cacheGekkoTrendByMAIndicator != null) { cacheGekkoTrendByMAIndicator.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheGekkoTrendByMAIndicator = tmp; return(indicator); } }
/// <summary> /// My specialized indicator /// </summary> /// <returns></returns> public GekkoTrendByMAIndicator GekkoTrendByMAIndicator(Data.IDataSeries input, int aTRPeriod, int sMAPeriod1, int sMAPeriod2) { if (cacheGekkoTrendByMAIndicator != null) for (int idx = 0; idx < cacheGekkoTrendByMAIndicator.Length; idx++) if (cacheGekkoTrendByMAIndicator[idx].ATRPeriod == aTRPeriod && cacheGekkoTrendByMAIndicator[idx].SMAPeriod1 == sMAPeriod1 && cacheGekkoTrendByMAIndicator[idx].SMAPeriod2 == sMAPeriod2 && cacheGekkoTrendByMAIndicator[idx].EqualsInput(input)) return cacheGekkoTrendByMAIndicator[idx]; lock (checkGekkoTrendByMAIndicator) { checkGekkoTrendByMAIndicator.ATRPeriod = aTRPeriod; aTRPeriod = checkGekkoTrendByMAIndicator.ATRPeriod; checkGekkoTrendByMAIndicator.SMAPeriod1 = sMAPeriod1; sMAPeriod1 = checkGekkoTrendByMAIndicator.SMAPeriod1; checkGekkoTrendByMAIndicator.SMAPeriod2 = sMAPeriod2; sMAPeriod2 = checkGekkoTrendByMAIndicator.SMAPeriod2; if (cacheGekkoTrendByMAIndicator != null) for (int idx = 0; idx < cacheGekkoTrendByMAIndicator.Length; idx++) if (cacheGekkoTrendByMAIndicator[idx].ATRPeriod == aTRPeriod && cacheGekkoTrendByMAIndicator[idx].SMAPeriod1 == sMAPeriod1 && cacheGekkoTrendByMAIndicator[idx].SMAPeriod2 == sMAPeriod2 && cacheGekkoTrendByMAIndicator[idx].EqualsInput(input)) return cacheGekkoTrendByMAIndicator[idx]; GekkoTrendByMAIndicator indicator = new GekkoTrendByMAIndicator(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.ATRPeriod = aTRPeriod; indicator.SMAPeriod1 = sMAPeriod1; indicator.SMAPeriod2 = sMAPeriod2; Indicators.Add(indicator); indicator.SetUp(); GekkoTrendByMAIndicator[] tmp = new GekkoTrendByMAIndicator[cacheGekkoTrendByMAIndicator == null ? 1 : cacheGekkoTrendByMAIndicator.Length + 1]; if (cacheGekkoTrendByMAIndicator != null) cacheGekkoTrendByMAIndicator.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheGekkoTrendByMAIndicator = tmp; return indicator; } }