protected override void InitExecuteContext() { if (IsSimple) { return; } m_tema1 = new TEMA { Context = Context, Period = Period }; m_tema2 = new TEMA { Context = Context, Period = Period }; }
public static IList <double> Calc(IList <double> source, int period, IMemoryContext context = null) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (period <= 0) { throw new ArgumentOutOfRangeException(nameof(period)); } var result = context?.GetArray <double>(source.Count) ?? new double[source.Count]; if (result.Length > 0) { if (period == 1 || result.Length == 1) { source.CopyTo(result, 0); } else { var tema1 = TEMA.Calc(source, period, context); var tema2 = TEMA.Calc(tema1, period, context); for (var i = 0; i < source.Count; i++) { result[i] = 2 * tema1[i] - tema2[i]; } context?.ReleaseArray((Array)tema1); context?.ReleaseArray((Array)tema2); } } return(result); }
protected override void ClearExecuteContext() { m_tema1 = null; m_tema2 = null; }