/// <summary> /// customizable JMA /// </summary> /// <returns></returns> public Jurik_JMA_custom Jurik_JMA_custom(Data.IDataSeries input, int j_lag, double j_len, double j_phase) { if (cacheJurik_JMA_custom != null) { for (int idx = 0; idx < cacheJurik_JMA_custom.Length; idx++) { if (cacheJurik_JMA_custom[idx].J_lag == j_lag && Math.Abs(cacheJurik_JMA_custom[idx].J_len - j_len) <= double.Epsilon && Math.Abs(cacheJurik_JMA_custom[idx].J_phase - j_phase) <= double.Epsilon && cacheJurik_JMA_custom[idx].EqualsInput(input)) { return(cacheJurik_JMA_custom[idx]); } } } lock (checkJurik_JMA_custom) { checkJurik_JMA_custom.J_lag = j_lag; j_lag = checkJurik_JMA_custom.J_lag; checkJurik_JMA_custom.J_len = j_len; j_len = checkJurik_JMA_custom.J_len; checkJurik_JMA_custom.J_phase = j_phase; j_phase = checkJurik_JMA_custom.J_phase; if (cacheJurik_JMA_custom != null) { for (int idx = 0; idx < cacheJurik_JMA_custom.Length; idx++) { if (cacheJurik_JMA_custom[idx].J_lag == j_lag && Math.Abs(cacheJurik_JMA_custom[idx].J_len - j_len) <= double.Epsilon && Math.Abs(cacheJurik_JMA_custom[idx].J_phase - j_phase) <= double.Epsilon && cacheJurik_JMA_custom[idx].EqualsInput(input)) { return(cacheJurik_JMA_custom[idx]); } } } Jurik_JMA_custom indicator = new Jurik_JMA_custom(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.J_lag = j_lag; indicator.J_len = j_len; indicator.J_phase = j_phase; Indicators.Add(indicator); indicator.SetUp(); Jurik_JMA_custom[] tmp = new Jurik_JMA_custom[cacheJurik_JMA_custom == null ? 1 : cacheJurik_JMA_custom.Length + 1]; if (cacheJurik_JMA_custom != null) { cacheJurik_JMA_custom.CopyTo(tmp, 0); } tmp[tmp.Length - 1] = indicator; cacheJurik_JMA_custom = tmp; return(indicator); } }
/// <summary> /// customizable JMA /// </summary> /// <returns></returns> public Jurik_JMA_custom Jurik_JMA_custom(Data.IDataSeries input, int j_lag, double j_len, double j_phase) { if (cacheJurik_JMA_custom != null) for (int idx = 0; idx < cacheJurik_JMA_custom.Length; idx++) if (cacheJurik_JMA_custom[idx].J_lag == j_lag && Math.Abs(cacheJurik_JMA_custom[idx].J_len - j_len) <= double.Epsilon && Math.Abs(cacheJurik_JMA_custom[idx].J_phase - j_phase) <= double.Epsilon && cacheJurik_JMA_custom[idx].EqualsInput(input)) return cacheJurik_JMA_custom[idx]; lock (checkJurik_JMA_custom) { checkJurik_JMA_custom.J_lag = j_lag; j_lag = checkJurik_JMA_custom.J_lag; checkJurik_JMA_custom.J_len = j_len; j_len = checkJurik_JMA_custom.J_len; checkJurik_JMA_custom.J_phase = j_phase; j_phase = checkJurik_JMA_custom.J_phase; if (cacheJurik_JMA_custom != null) for (int idx = 0; idx < cacheJurik_JMA_custom.Length; idx++) if (cacheJurik_JMA_custom[idx].J_lag == j_lag && Math.Abs(cacheJurik_JMA_custom[idx].J_len - j_len) <= double.Epsilon && Math.Abs(cacheJurik_JMA_custom[idx].J_phase - j_phase) <= double.Epsilon && cacheJurik_JMA_custom[idx].EqualsInput(input)) return cacheJurik_JMA_custom[idx]; Jurik_JMA_custom indicator = new Jurik_JMA_custom(); indicator.BarsRequired = BarsRequired; indicator.CalculateOnBarClose = CalculateOnBarClose; #if NT7 indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256; indicator.MaximumBarsLookBack = MaximumBarsLookBack; #endif indicator.Input = input; indicator.J_lag = j_lag; indicator.J_len = j_len; indicator.J_phase = j_phase; Indicators.Add(indicator); indicator.SetUp(); Jurik_JMA_custom[] tmp = new Jurik_JMA_custom[cacheJurik_JMA_custom == null ? 1 : cacheJurik_JMA_custom.Length + 1]; if (cacheJurik_JMA_custom != null) cacheJurik_JMA_custom.CopyTo(tmp, 0); tmp[tmp.Length - 1] = indicator; cacheJurik_JMA_custom = tmp; return indicator; } }