Triple Exponential Moving Average (TEMA) free

by Doustzadeh in category Trend at 04/12/2021
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.

How to install
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
```﻿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];
}
}
}
```