jesse-indicators
Version:
A Technical indicator library for TypeScript.
14 lines • 450 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function SMA(values, period) {
if (values.length !== period) {
throw new Error(`Number of values(${values.length}) must be the same as the period(${period}).`);
}
let sum = 0;
for (let index = 0; index < values.length; index++) {
sum += values[index];
}
return sum / period;
}
exports.default = SMA;
//# sourceMappingURL=index.js.map