TDCD_TemaDema_rlh

Download script
TDCD_TemaDema_rlh

This tool is designed to provide a more responsive and refined view of price action by utilizing advanced smoothing techniques. Rather than simply tracking the average price over a set period, it uses a sophisticated multi-layered calculation to filter out "market noise" while attempting to maintain a closer proximity to the actual price movement.

How the Logic Works

The core of this script relies on a technique called "Triple Exponential Moving Average" (TEMA). To understand how this achieves its goals, we can look at the process in three stages:

1. The Layered Smoothing Process The script doesn't just calculate one average; it calculates three nested layers of averages based on your chosen time period:

  • Layer 1: A standard Exponential Moving Average (EMA).
  • Layer 2: An average calculated from the first average.
  • Layer 3: An average calculated from the second average.

By combining these three layers using a specific mathematical formula, the tool produces a "Triple" average. The benefit of this approach is that it significantly reduces the lag typically found in standard moving averages, allowing the indicator to react faster to new price trends without becoming erratic.

2. The Difference Analysis (DEMA vs. TEMA) The script takes the logic a step further by introducing a second calculation known as DEMA (Double Exponential Moving Average). It then performs a comparison between the Triple average and this Double average.

By calculating the difference between these two specific types of averages, the script isolates the "delta" or the unique variance in price momentum. This helps highlight the underlying strength or exhaustion of a move more clearly than a single line would.

3. Final Trend Smoothing To ensure the final output is readable and provides clear signals, the script takes that calculated difference and applies one final smoothing pass. This results in a polished data line that reflects the core momentum of the market.

Summary for the User

Instead of looking at raw price fluctuations, this tool provides a smoothed "signature" of the market's direction. By layering multiple averages and then calculating the variance between different types of exponential moving averages, it aims to provide a clearer picture of trend direction, helping you identify the primary flow of the market with less visual clutter and delay.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
TDCD_TemaDema_rlh
//+------------------------------------------------------------------+
//|                                                       TEMA_RLH   |
//|                                    Copyright © 2006, Robert Hill |
//|                                       http://www.metaquotes.net/ |
//|                                                                  |
//| Based on the formula developed by Patrick Mulloy                 |
//|                                                                  |
//| It can be used in place of EMA or to smooth other indicators.    |
//|                                                                  |
//| TEMA = 3 * EMA - 3 * (EMA of EMA) + EMA of EMA of EMA            |
//|                                                                  |
//|  Red is EMA, Green is EMA of EMA, Yellow is Ema of Ema of Ema    |
//|  Aqua is TEMA                                                    |
//|                                                                  |
//+------------------------------------------------------------------+
//mod2009fxtsd    tdcd (tema-dema)
#property  copyright "Copyright © 2006, Robert Hill "
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Blue
#property  indicator_color2  DodgerBlue


#property  indicator_width1  1
#property  indicator_width2  1


//----
extern int EMA_Period =14;
extern int temaSigLperiod =14;
//---- buffer
double Ema[];
double EmaOfEma[];
double EmaOfEmaOfEma[];
double Dema[];
double Tema[];
double tdcd[];
double Temasln[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(7); 
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexDrawBegin(0,EMA_Period);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
//---- 3 indicator buffers mapping
   if(!SetIndexBuffer(6,Ema) &&
      !SetIndexBuffer(5,EmaOfEma) &&
      !SetIndexBuffer(4,EmaOfEmaOfEma) &&
      !SetIndexBuffer(3,Dema)&&
      !SetIndexBuffer(2,Tema)&&
      !SetIndexBuffer(1,tdcd)&&
      !SetIndexBuffer(0,Temasln))
      Print("cannot set indicator buffers!");
   //   if(!SetIndexBuffer(0,Tema) )
   //      Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("TDCD("+EMA_Period+")");
//      Tema[i]=3 * Ema[i] - 3 * EmaOfEma[i] + EmaOfEmaOfEma[i];

   SetIndexLabel(0,"tdcd sln");
   SetIndexLabel(1,"tdcd ");



//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i, limit;
   int    counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(i=limit; i>=0; i--)
      Ema[i]=iMA(NULL,0,EMA_Period,0,MODE_EMA,PRICE_CLOSE,i);
   for(i=limit; i >=0; i--)
      EmaOfEma[i]=iMAOnArray(Ema,Bars,EMA_Period,0,MODE_EMA,i);

   for(i=limit; i >=0; i--)
      EmaOfEmaOfEma[i]=iMAOnArray(EmaOfEma,Bars,EMA_Period,0,MODE_EMA,i);
   //==========             

   for(i=limit; i >=0; i--)
      Dema[i]=2 * Ema[i] - EmaOfEma[i];


   for(i=limit; i >=0; i--)
   {
   Tema[i]=3 * Ema[i] - 3 * EmaOfEma[i] + EmaOfEmaOfEma[i];
   tdcd [i]=Tema[i]-Dema[i];
   }
//  int  per=( EMA_Period -1)/2;
   for(i=limit; i >=0; i--)
      Temasln[i]=iMAOnArray(tdcd,Bars,temaSigLperiod,0,MODE_EMA,i);



//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments