stock-indicator
Version:
Stock Indicator Library
23 lines • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BRAR = BRAR;
const common_1 = require("../common");
function BRAR(CLOSE, HIGH, LOW, OPEN, N = 26) {
// check input
(0, common_1.checkArrayOfNumbers)(CLOSE, "CLOSE");
(0, common_1.checkArrayOfNumbers)(HIGH, "HIGH");
(0, common_1.checkArrayOfNumbers)(LOW, "LOW");
(0, common_1.checkArrayOfNumbers)(OPEN, "OPEN");
(0, common_1.checkNumber)(N, 1, CLOSE, "N", "CLOSE");
// calculate BR and AR
const BR = (0, common_1.funArrDiv)((0, common_1.funMS)([
null,
...HIGH.slice(1).map((item, index) => Math.max(0, item - CLOSE[index])),
], N), (0, common_1.funMS)([
0,
...LOW.slice(1).map((item, index) => Math.max(0, CLOSE[index] - item)),
], N)).map((item) => (0, common_1.funRound)(item !== null ? 100 * item : null, 3));
const AR = (0, common_1.funArrDiv)((0, common_1.funMS)((0, common_1.funArrSub)(HIGH, OPEN), N), (0, common_1.funMS)((0, common_1.funArrSub)(OPEN, LOW), N)).map((item) => (0, common_1.funRound)(item !== null ? 100 * item : null, 3));
return { BR, AR };
}
//# sourceMappingURL=brar.js.map