Пример #1
0
        public static List <decimal?> PlusDi(this IEnumerable <ICandle> candles, int?period)
        {
            period = period ?? 14;

            IIndicatorOptions options = new PlusDiOptions(period.Value);
            PlusDi            plusDi  = new PlusDi();

            return(plusDi.Get(candles, options));
        }
Пример #2
0
        public override dynamic Get(IEnumerable <ICandle> source, IIndicatorOptions options = null)
        {
            PlusDiOptions config = options != null ? (PlusDiOptions)options.Options : new PlusDiOptions(14);

            double[] diValues = new double[source.Count()];

            double[] highs  = source.Select(x => Convert.ToDouble(x.High)).ToArray();
            double[] lows   = source.Select(x => Convert.ToDouble(x.Low)).ToArray();
            double[] closes = source.Select(x => Convert.ToDouble(x.Close)).ToArray();

            TicTacTec.TA.Library.Core.RetCode plusDi = TicTacTec.TA.Library.Core.PlusDI(0, source.Count() - 1, highs, lows, closes, config.Period, out int outBegIdx, out int outNbElement, diValues);

            if (plusDi == TicTacTec.TA.Library.Core.RetCode.Success)
            {
                return(FixIndicatorOrdering(diValues.ToList(), outBegIdx, outNbElement));
            }

            throw new Exception("Could not calculate +DI!");
        }