stock-indicator
Version:
Stock Indicator Library
23 lines • 941 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TRIX = TRIX;
const common_1 = require("../common");
function TRIX(CLOSE, N = 12, M = 9) {
// check input data
(0, common_1.checkArrayOfNumbers)(CLOSE, "CLOSE");
// check n and m parameters
(0, common_1.checkNumber)(N, 2, CLOSE, "N", "CLOSE");
(0, common_1.checkNumber)(M, 2, CLOSE, "M", "CLOSE");
const MTR = (0, common_1.funEMA)((0, common_1.funEMA)((0, common_1.funEMA)(CLOSE, N), N), N);
const TRIX = [null];
for (let i = 1; i < MTR.length; i++) {
TRIX.push(MTR[i] !== null && MTR[i - 1] !== null
? ((MTR[i] - MTR[i - 1]) /
MTR[i - 1]) *
100
: null);
}
const MATRIX = (0, common_1.funMA)(TRIX, M).map((v) => (0, common_1.funRound)(v, 3));
return { TRIX: TRIX.map((v) => (0, common_1.funRound)(v, 3)), MATRIX };
}
//# sourceMappingURL=trix.js.map