public static List <decimal?> Mom(this IEnumerable <ICandle> candles, int?period) { period = period ?? 10; IIndicatorOptions options = new MomOptions(period.Value); Mom mom = new Mom(); return(mom.Get(candles, options)); }
public override dynamic Get(IEnumerable <ICandle> source, IIndicatorOptions options = null) { MomOptions config = options != null ? (MomOptions)options.Options : new MomOptions(10); double[] momValues = new double[source.Count()]; double[] closes = source.Select(x => Convert.ToDouble(x.Close)).ToArray(); TicTacTec.TA.Library.Core.RetCode mom = TicTacTec.TA.Library.Core.Mom(0, source.Count() - 1, closes, config.Period, out int outBegIdx, out int outNbElement, momValues); if (mom == TicTacTec.TA.Library.Core.RetCode.Success) { return(FixIndicatorOrdering(momValues.ToList(), outBegIdx, outNbElement)); } throw new Exception("Could not calculate MOM!"); }