trading-signals
Version:
Technical indicators to run technical analysis with JavaScript / TypeScript.
32 lines • 1.01 kB
JavaScript
import { IndicatorSeries } from '../../base/Indicator.js';
import { EMA } from '../EMA/EMA.js';
export class TEMA extends IndicatorSeries {
#single;
#double;
#triple;
interval;
constructor(interval) {
super();
this.interval = interval;
this.#single = new EMA(interval);
this.#double = new EMA(interval);
this.#triple = new EMA(interval);
}
getRequiredInputs() {
return 3 * (this.interval - 1) + 1;
}
update(price, replace) {
const single = this.#single.update(price, replace);
if (this.#single.isStable) {
const double = this.#double.update(single, replace);
if (this.#double.isStable) {
const triple = this.#triple.update(double, replace);
if (this.#triple.isStable) {
return this.setResult(3 * single - 3 * double + triple, replace);
}
}
}
return null;
}
}
//# sourceMappingURL=TEMA.js.map