# Triple Exponential Moving Average (TEMA)

Would anyone be willing/able to code this for me? The formula:

Triple Exponential Moving Average (TEMA) = (3∗EMA1​)−(3∗EMA2​)+EMA3​

where:
EMA1​ = Exponential Moving Average (EMA)
EMA2​ = EMA of EMA1
​EMA3​ = EMA of EMA2​​

I also have a version of the code from Tradingview if that is at all helpful. Thanks!

Just wanted to bump this to see if anyone would be willing to code it for me…

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")
};``````

Someone just marked it as the solution - please make sure you grab the EDITED version. First version didn’t RETURN the tema, it only calculated it. Jumped the gun on publishing, and edited it accordingly.

Edit: also “shared” in community indicators through the trading platform.

Loaded it up and it looks great! Thank you so much for coding this! I really appreciate it!

Gust

1 Like