trading-signals
Version:
Technical indicators to run technical analysis with JavaScript / TypeScript.
26 lines • 841 B
JavaScript
import { IndicatorSeries } from '../../base/Indicator.js';
import { TR } from '../TR/TR.js';
import { WSMA } from '../../trend/WSMA/WSMA.js';
export class ATR extends IndicatorSeries {
#tr;
#smoothing;
interval;
constructor(interval, SmoothingIndicator = WSMA) {
super();
this.interval = interval;
this.#tr = new TR();
this.#smoothing = new SmoothingIndicator(interval);
}
getRequiredInputs() {
return this.#smoothing.getRequiredInputs();
}
update(candle, replace) {
const trueRange = this.#tr.update(candle, replace);
this.#smoothing.update(trueRange, replace);
if (this.#smoothing.isStable) {
return this.setResult(this.#smoothing.getResultOrThrow(), replace);
}
return null;
}
}
//# sourceMappingURL=ATR.js.map