trading-signals
Version:
Technical indicators to run technical analysis with JavaScript / TypeScript.
34 lines • 987 B
JavaScript
import { DX } from '../DX/DX.js';
import { IndicatorSeries } from '../../base/Indicator.js';
import { WSMA } from '../WSMA/WSMA.js';
export class ADX extends IndicatorSeries {
#dx;
#smoothed;
interval;
constructor(interval, SmoothingIndicator = WSMA) {
super();
this.interval = interval;
this.#smoothed = new SmoothingIndicator(this.interval);
this.#dx = new DX(interval, SmoothingIndicator);
}
get mdi() {
return this.#dx.mdi;
}
get pdi() {
return this.#dx.pdi;
}
getRequiredInputs() {
return this.interval * 2 - 1;
}
update(candle, replace) {
const result = this.#dx.update(candle, replace);
if (result !== null) {
this.#smoothed.update(result, replace);
}
if (this.#smoothed.isStable) {
return this.setResult(this.#smoothed.getResultOrThrow(), replace);
}
return null;
}
}
//# sourceMappingURL=ADX.js.map