trading-signals
Version:
Technical indicators to run technical analysis with JavaScript / TypeScript.
29 lines • 859 B
JavaScript
import { TechnicalIndicator } from '../../base/Indicator.js';
import { SMA } from '../SMA/SMA.js';
export class DMA extends TechnicalIndicator {
short;
long;
constructor(short, long, SmoothingIndicator = SMA) {
super();
this.short = new SmoothingIndicator(short);
this.long = new SmoothingIndicator(long);
}
get isStable() {
return this.long.isStable;
}
getRequiredInputs() {
return this.long.getRequiredInputs();
}
update(price, replace) {
this.short.update(price, replace);
this.long.update(price, replace);
if (this.isStable) {
return (this.result = {
long: this.long.getResultOrThrow(),
short: this.short.getResultOrThrow(),
});
}
return null;
}
}
//# sourceMappingURL=DMA.js.map