Try this:
I compared the output to what I get on tradingview and it seems the same. YMMV. Not responsible for losses. I eat crayons, you shouldn’t take indicator advice from me.
(edit: orig version missed ONE little thing that meant it just output a normal ema. It CALCULATED the tema, but didn’t return it. Resolved.)
const predef = require("./tools/predef");
const EMA = require("./tools/EMA");
class TEMA {
init() {
this.ema = EMA(this.props.period);
this.ema1 = EMA(this.props.period);
this.ema2 = EMA(this.props.period);
}
map(d) {
var emav1 = this.ema(d.value());
var emav2 = this.ema1(emav1);
var emav3 = this.ema2(emav2);
var temav = 3 * (emav1 - emav2) + emav3;
return temav;
}
}
module.exports = {
name: "Triple EMA",
description: "Triple Exponential Moving Average",
calculator: TEMA,
params: {
period: predef.paramSpecs.period(14)
},
tags: [predef.tags.MovingAverage],
schemeStyles: predef.styles.solidLine("#8cecff")
};