expMovingAvg: use window size as param

This commit is contained in:
Alexander Zobnin
2017-07-04 10:16:41 +03:00
parent 0b8cb0b23c
commit e0466ea780
4 changed files with 13 additions and 1 deletions

View File

@@ -270,6 +270,10 @@ function simpleMovingAverage(datapoints, n) {
}
function expMovingAverage(datapoints, a) {
// Calculate a from window size
if (a > 1) {
a = 2 / (a + 1);
}
let ema = [datapoints[0]];
let ema_prev = datapoints[0][POINT_VALUE];
let ema_cur;