UNPKG

stock-indicator

Version:

Stock Indicator Library

21 lines 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.EXPMA = EXPMA; const index_1 = require("../common/index"); /** * - Exponential Moving Average (EMA) * @param {number[]} CLOSE - closing prices of the stock * @param {number} M1 - number of periods to calculate the EMA,must be greater than 1 and less than the length of the CLOSE array,default is 12 * @param {number} M2 - number of periods to calculate the initial EMA, default is 1,must be less than N,default is 50 * @returns {{ EMA: TMixed[] }} - object with the EMA values,rounded to 3 decimal places */ function EXPMA(CLOSE, M1 = 12, M2 = 50) { // - check input data (0, index_1.checkArrayOfNumbers)(CLOSE, "CLOSE"); (0, index_1.checkNumber)(M1, 2, CLOSE, "M1", "CLOSE"); (0, index_1.checkNumber)(M2, 2, CLOSE, "M2", "CLOSE"); const EMA1 = (0, index_1.funEMA)(CLOSE, M1, 1).map((item) => (0, index_1.funRound)(item, 3)); const EMA2 = (0, index_1.funEMA)(CLOSE, M2, 1).map((item) => (0, index_1.funRound)(item, 3)); return { EMA1, EMA2 }; } //# sourceMappingURL=expma.js.map