Exemplo n.º 1
0
        public static void CalculateRSI()
        {
            IList <double> closePricesData = new List <double>();

            closePricesData.Add(23.83);
            closePricesData.Add(23.95);
            closePricesData.Add(23.63);
            closePricesData.Add(23.82);
            closePricesData.Add(23.87);
            RelativeStrengthIndex.Calculate(closePricesData.ToArray());
        }
Exemplo n.º 2
0
        public static double[] CalculateRSI(string symbol, int window)
        {
            double[] closePrices = null;

            using (InvestmentAnalysisContext context = new InvestmentAnalysisContext())
            {
                closePrices = context.HistoricalDataBlocks
                              .Where(q => q.Symbol.Equals(symbol))
                              .OrderByDescending(q => q.RecordDate)
                              .Take(window)
                              .Select(c => (double)c.LastPrice)
                              .ToArray();
            }

            return(RelativeStrengthIndex.Calculate(closePrices.Reverse().ToArray()));
        }