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()); }
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())); }