예제 #1
0
        public static List <double> RSI(IEnumerable <double> source, int period)
        {
            // int outBegIdx, outNbElement;
            double[] rsiValues = new double[source.Count()];

            var sourceFix = source.ToArray();

            var ema = TA.Rsi(0, source.Count() - 1, sourceFix, period, out int outBegIdx, out int outNbElement, rsiValues);

            if (ema == TA.RetCode.Success)
            {
                return(rsiValues.Take(outNbElement).ToList());
            }

            throw new Exception("Could not calculate RSI!");
        }
예제 #2
0
        public static List <double> RSI(List <decimal> source, int period)
        {
            // int outBegIdx, outNbElement;
            double[] rsiValues = new double[source.Count];

            var sourceFix = source.Select(x => Convert.ToDouble(x)).ToArray();

            var ema = TA.Rsi(0, source.Count - 1, sourceFix, period, out int outBegIdx, out int outNbElement, rsiValues);

            if (ema == TA.RetCode.Success)
            {
                return(rsiValues.Take(outNbElement).ToList());
            }

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