trading-signals
Version:
Technical indicators to run technical analysis with JavaScript / TypeScript.
35 lines • 945 B
JavaScript
import { TechnicalIndicator } from './Indicator.js';
import { pushUpdate } from '../util/pushUpdate.js';
export class Period extends TechnicalIndicator {
values;
#highest;
#lowest;
get highest() {
return this.#highest;
}
get lowest() {
return this.#lowest;
}
interval;
constructor(interval) {
super();
this.interval = interval;
this.values = [];
}
getRequiredInputs() {
return this.interval;
}
update(value, replace) {
pushUpdate(this.values, replace, value, this.interval);
if (this.values.length === this.interval) {
this.#lowest = Math.min(...this.values);
this.#highest = Math.max(...this.values);
return (this.result = {
highest: this.#highest,
lowest: this.#lowest,
});
}
return null;
}
}
//# sourceMappingURL=Period.js.map