I have an array of daily closing prices for a stock (historical data) formatted as such:
var close = [39, 40.133, 38.23, .... , 45.38]
these are in order chronologically by date. I am trying to make an array of EMA (exponential moving average) values of the closing price to correlate with the date chronologically.
I’m doing this in nodejs; any help would be greatly appreciated!
P.S. Here is something that I've tried:
var gauss = require('gauss');
var test = [39, 40.133, 38.23, 45.38, 43.83, 42.1, 48, 47, 44.12, 44.33, 46.9];
var vec = test.toVector();
var ma = vec.ema(10);
console.log(ma); // Outputs [ 43.2123, 43.88279090909091 ]
Why does it output this?