Category Trend  Published on 04/12/2021

Triple Exponential Moving Average (TEMA)

Description

The Triple Exponential Moving Average (TEMA) reduces the lag of traditional EMAs, making it more responsive and better-suited for short-term trading. Shortly after developing the Double Exponential Moving Average (DEMA) in 1994, Patrick Mulloy took the concept a step further and created the Triple Exponential Moving Average (TEMA).

Like its predecessor DEMA, the TEMA overlay uses the lag difference between different EMAs to adjust a traditional EMA. However, TEMA's formula uses a triple-smoothed EMA in addition to the single- and double-smoothed EMAs employed in the formula for DEMA. The offset created using these three EMAs produces a moving average that stays even closer to the price bars than DEMA.

 

Github: GitHub - Doustzadeh/cTrader-Indicator

 


using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, AutoRescale = false, AccessRights = AccessRights.None)]
    public class TripleExponentialMovingAverage : Indicator
    {
        // Single-, Double-, and Triple-Smoothed EMAs:
        // EMA1 = EMA of price
        // EMA2 = EMA of EMA1
        // EMA3 = EMA of EMA2
        // TEMA = (3 x EMA1) - (3 x EMA2) + (EMA3)

        [Parameter("Source")]
        public DataSeries Source { get; set; }

        [Parameter("Periods", DefaultValue = 14)]
        public int Periods { get; set; }

        [Output("TEMA", LineColor = "DodgerBlue", Thickness = 2)]
        public IndicatorDataSeries TEMA { get; set; }

        private ExponentialMovingAverage EMA1, EMA2, EMA3;

        protected override void Initialize()
        {
            EMA1 = Indicators.ExponentialMovingAverage(Source, Periods);
            EMA2 = Indicators.ExponentialMovingAverage(EMA1.Result, Periods);
            EMA3 = Indicators.ExponentialMovingAverage(EMA2.Result, Periods);
        }

        public override void Calculate(int index)
        {
            TEMA[index] = (3 * EMA1.Result[index]) - (3 * EMA2.Result[index]) + EMA3.Result[index];
        }
    }
}


Doustzadeh's avatar
Doustzadeh

Joined on 20.03.2016

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Triple Exponential Moving Average.algo
  • Rating: 0
  • Installs: 1665
  • Modified: 04/12/2021 00:00
Comments
Log in to add a comment.
No comments found.