Exemplo n.º 1
0
        public static List <decimal?> Rsi(this IEnumerable <ICandle> candles, int?period = null)
        {
            period ??= 14;

            IIndicatorOptions options = new RsiOptions(period.Value);
            Rsi rsi = new Rsi();

            return(rsi.Get(candles, options));
        }
Exemplo n.º 2
0
        public override dynamic Get(IEnumerable <decimal?> source, IIndicatorOptions options = null)
        {
            RsiOptions config = options != null ? (RsiOptions)options.Options : new RsiOptions(14);

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

            double[] sourceFix = source.Select(x => Convert.ToDouble(x)).ToArray();

            TicTacTec.TA.Library.Core.RetCode rsi = TicTacTec.TA.Library.Core.Rsi(0, source.Count() - 1, sourceFix, config.Period, out int outBegIdx, out int outNbElement, rsiValues);

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

            throw new Exception("Could not calculate RSI");
        }