public static List <decimal?> Sar(this IEnumerable <ICandle> candles, double?accelerationFactor = null, double?maximumAccelerationFactor = null) { accelerationFactor = accelerationFactor ?? 0.02; maximumAccelerationFactor = maximumAccelerationFactor ?? 0.2; IIndicatorOptions options = new SarOptions(accelerationFactor.Value, maximumAccelerationFactor.Value); Sar sar = new Sar(); return(sar.Get(candles, options)); }
public override dynamic Get(IEnumerable <ICandle> source, IIndicatorOptions options = null) { SarOptions config = options != null ? (SarOptions)options.Options : new SarOptions(0.02, 02); double[] sarValues = new double[source.Count()]; double[] highs = source.Select(x => Convert.ToDouble(x.High)).ToArray(); double[] lows = source.Select(x => Convert.ToDouble(x.Low)).ToArray(); TicTacTec.TA.Library.Core.RetCode sar = TicTacTec.TA.Library.Core.Sar(0, source.Count() - 1, highs, lows, 0.02, 0.2, out int outBegIdx, out int outNbElement, sarValues); if (sar == TicTacTec.TA.Library.Core.RetCode.Success) { // party return(FixIndicatorOrdering(sarValues.ToList(), outBegIdx, outNbElement)); } throw new Exception("Could not calculate SAR"); }