UNPKG

react-financial-charts

Version:
26 lines 1 kB
import { atr } from "../calculator"; import { merge, rebind } from "../utils"; import baseIndicator from "./baseIndicator"; const ALGORITHM_TYPE = "ATR"; export default function () { const base = baseIndicator() .type(ALGORITHM_TYPE); const underlyingAlgorithm = atr(); const mergedAlgorithm = merge() .algorithm(underlyingAlgorithm) .merge((datum, i) => { datum.atr = i; }); const indicator = (data, options = { merge: true }) => { if (options.merge) { if (!base.accessor()) { throw new Error(`Set an accessor to ${ALGORITHM_TYPE} before calculating`); } return mergedAlgorithm(data); } return underlyingAlgorithm(data); }; rebind(indicator, base, "id", "accessor", "stroke", "fill", "echo", "type"); rebind(indicator, underlyingAlgorithm, "options"); rebind(indicator, mergedAlgorithm, "merge", "skipUndefined"); return indicator; } //# sourceMappingURL=atr.js.map