trading-signals
Version:
Technical indicators to run technical analysis with JavaScript / TypeScript.
17 lines • 570 B
JavaScript
import { MovingAverage } from '../MA/MovingAverage.js';
import { getAverage } from '../../util/getAverage.js';
import { pushUpdate } from '../../util/pushUpdate.js';
export class SMA extends MovingAverage {
prices = [];
getRequiredInputs() {
return this.interval;
}
update(price, replace) {
pushUpdate(this.prices, replace, price, this.interval);
if (this.prices.length === this.interval) {
return this.setResult(getAverage(this.prices), replace);
}
return null;
}
}
//# sourceMappingURL=SMA.js.map