Category Trend  Published on 03/12/2021

Double Exponential Moving Average (DEMA)

Description

The Double Exponential Moving Average (DEMA) reduces the lag of traditional EMAs, making it more responsive and better-suited for short-term traders. DEMA was developed by Patrick Mulloy, and introduced in the January 1994 issue of Technical Analysis of Stocks & Commodities magazine.

The overlay uses the lag difference between a single-smoothed EMA and a double-smoothed EMA to offset the single-smoothed EMA. This offset produces a moving average that remains smooth, but stays closer to the price bars than either the single- or double-smoothed traditional EMA.

 

Github: GitHub - Doustzadeh/cTrader-Indicator

 


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

namespace cAlgo
{
    [Indicator(IsOverlay = true, AutoRescale = false, AccessRights = AccessRights.None)]
    public class DoubleExponentialMovingAverage : Indicator
    {
        // Single and Double-Smoothed EMAs:
        // EMA1 = EMA of price
        // EMA2 = EMA of EMA1
        // DEMA = (2 x EMA1) - EMA2

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

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

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

        private ExponentialMovingAverage EMA1, EMA2;

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

        public override void Calculate(int index)
        {
            DEMA[index] = (2 * EMA1.Result[index]) - EMA2.Result[index];
        }
    }
}


Doustzadeh's avatar
Doustzadeh

Joined on 20.03.2016

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Double Exponential Moving Average.algo
  • Rating: 0
  • Installs: 1588
Comments
Log in to add a comment.
No comments found.