public static Pine Ema(Pine source, int period) { double[] emaValues = new double[source.Count]; var sourceFix = source.ToArray(); var sma = TA.Ema(0, source.Count - 1, sourceFix, period, out int outBegIdx, out int outNbElement, emaValues); if (sma == TA.RetCode.Success) { return(emaValues.Take(outNbElement).ToPine()); } throw new Exception("Could not calculate EMA!"); }
public static List <double> Ema(List <double> source, int period) { // int outBegIdx, outNbElement; double[] emaValues = new double[source.Count]; //List<double?> outValues = new List<double?>(); var sourceFix = source.ToArray(); var sma = TA.Ema(0, source.Count - 1, sourceFix, period, out int outBegIdx, out int outNbElement, emaValues); if (sma == TA.RetCode.Success) { return(emaValues.Take(outNbElement).ToList()); } throw new Exception("Could not calculate EMA!"); }