# Triple Exponential Moving Average (TEMA)

**URL:** <https://community.tradovate.com/t/triple-exponential-moving-average-tema/1242>\
**Category:** Custom Indicators\
**Tags:** complete\
**Created:** [December 7, 2020, 8:29pm UTC](https://community.tradovate.com/t/triple-exponential-moving-average-tema/1242 "2020-12-07T20:29:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gustyle](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/gustyle/32/203_2.png) [@gustyle](https://community.tradovate.com/u/gustyle)\
**Post date:** [December 7, 2020, 8:29pm UTC](https://community.tradovate.com/t/triple-exponential-moving-average-tema/1242/1 "2020-12-07T20:29:07Z")

</div>

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​​

Link to [Investopedia explanation](https://www.investopedia.com/terms/t/triple-exponential-moving-average.asp)

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

---

<div class="post-metadata">

**Author:** ![gustyle](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/gustyle/32/203_2.png) [@gustyle](https://community.tradovate.com/u/gustyle)\
**Post date:** [January 13, 2021, 9:30pm UTC](https://community.tradovate.com/t/triple-exponential-moving-average-tema/1242/2 "2021-01-13T21:30:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KalD](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/kald/32/975_2.png) [@KalD](https://community.tradovate.com/u/KalD)\
**Post date:** [March 26, 2021, 4:13pm UTC](https://community.tradovate.com/t/triple-exponential-moving-average-tema/1242/3 "2021-03-26T16:13:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KalD](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/kald/32/975_2.png) [@KalD](https://community.tradovate.com/u/KalD)\
**Post date:** [March 26, 2021, 4:21pm UTC](https://community.tradovate.com/t/triple-exponential-moving-average-tema/1242/4 "2021-03-26T16:21:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gustyle](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/gustyle/32/203_2.png) [@gustyle](https://community.tradovate.com/u/gustyle)\
**Post date:** [March 29, 2021, 3:09pm UTC](https://community.tradovate.com/t/triple-exponential-moving-average-tema/1242/5 "2021-03-29T15:09:23Z")

</div>

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

Gust

---

<div class="post-metadata">

**Author:** ![MrInternationalBanks](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@MrInternationalBanks](https://community.tradovate.com/u/MrInternationalBanks)\
**Post date:** [October 30, 2022, 5:03am UTC](https://community.tradovate.com/t/triple-exponential-moving-average-tema/1242/6 "2022-10-30T05:03:02Z")

</div>

I figured I would ask something similar on the same thread. Would anyone know/be willing to code this for me to use in tradovate? I got it off trading view. EMAX5

 ![Screenshot 2022-10-29 at 9.49.23 PM](https://us1.discourse-cdn.com/flex015/uploads/tradingforum/original/2X/e/e5b42e7087faca4c70cce8abf8b9ce960ac37020.jpeg)

---

<div class="post-metadata">

**Author:** ![PhineasAndFerb](https://sea1.discourse-cdn.com/flex015/user_avatar/community.tradovate.com/phineasandferb/32/127_2.png) [@PhineasAndFerb](https://community.tradovate.com/u/PhineasAndFerb)\
**Post date:** [May 8, 2023, 1:30pm UTC](https://community.tradovate.com/t/triple-exponential-moving-average-tema/1242/7 "2023-05-08T13:30:00Z")

</div>

Thank you - this works great! 💪
