UNPKG

trading-signals

Version:

Technical indicators to run technical analysis with JavaScript / TypeScript.

17 lines 607 B
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({ array: this.prices, item: price, maxLength: this.interval, replace: replace }); if (this.prices.length === this.interval) { return this.setResult(getAverage(this.prices), replace); } return null; } } //# sourceMappingURL=SMA.js.map