private void ComputeMomentum(HistoricPrice historicPrice, out double momentum, out double volatility) { var closingPrices = historicPrice.Candles.Select(r => Math.Log((double)r.Close)).ToArray(); var seqNumbers = Enumerable.Range(0, closingPrices.Count()).Select <int, double>(i => i).ToArray(); var leastSquaresFitting = Fit.Line(seqNumbers, closingPrices); var correlationCoff = GoodnessOfFit.R(seqNumbers, closingPrices); var annualizedSlope = (Math.Pow(Math.Exp(leastSquaresFitting.Item2), 252) - 1) * 100; var score = annualizedSlope * correlationCoff * correlationCoff; momentum = score; var r = Math.Exp(leastSquaresFitting.Item2) * correlationCoff * correlationCoff * 100; volatility = r; }