ma_TemaDemaTrixCD_rlh
Download scriptThis technical indicator is designed to provide traders with a more refined and responsive view of market trends by utilizing advanced smoothing techniques. Rather than relying on standard moving averages, which can often lag behind actual price action, this script calculates several layers of "exponential" data to identify momentum and price shifts more accurately.
The Core Methodology
The logic is built upon a three-layered progression of Exponential Moving Averages (EMA). By layering these averages over one another, the tool creates a hierarchy of data:
- The Primary Layer: A standard smoothed average of current prices.
- The Secondary Layer: An average of the primary layer.
- The Tertiary Layer: An average of the secondary layer.
Key Components & Calculations
The script processes these layers to generate several distinct data points used for market analysis:
- TEMA (Triple Exponential Moving Average): This is a sophisticated calculation that combines all three layers (Primary, Secondary, and Tertiary). By subtracting the secondary layer from the primary and adding back the tertiary, it eliminates the "lag" typically found in standard averages, making it much more reactive to sudden price changes.
- DEMA (Double Exponential Moving Average): The script also calculates a double-layered average. This provides a baseline for comparison against the TEMA.
- TDCD (Trend Detection Correlation): By comparing the TEMA and the DEMA, the script calculates a specific variance. This helps in visualizing the relationship between different smoothing methods to confirm trend strength.
- Matrix & OSMA Dynamics: Depending on your settings, the script can calculate "Matrix" values. These represent the percentage of change between the different layers (e.g., comparing the current secondary layer to its previous value). This highlights the velocity and acceleration of a trend.
Practical Application
Instead of just showing you where the price was, this logic aims to show you where the price is going by filtering out "market noise." By viewing the relationship between these smoothed layers, traders can better identify:
- Momentum Shifts: Seeing how quickly the averages are moving relative to one another.
- Trend Confirmation: Using the interaction between the Triple and Double averages to confirm if a move has real weight behind it.
- Smooth Transitions: Providing a cleaner visual of market direction than standard indicators, which can often be jagged or slow to react to new information.
//+------------------------------------------------------------------+
//| 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 temadematrix cd osma
#property copyright "Copyright © 2006, Robert Hill "
#property link "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 DodgerBlue
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
//----
extern int EMA_Period =9;
extern bool tdOsma = false; // tdosma\dematrix
//---- buffer
double Ema[];
double EmaOfEma[];
double EmaOfEmaOfEma[];
double Dema[];
double Tema[];
double dematrix[];
double tematrix[];
double tdcd[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(8);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexDrawBegin(0,EMA_Period);
SetIndexDrawBegin(1,EMA_Period);
SetIndexDrawBegin(2,EMA_Period);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
//---- 3 indicator buffers mapping
if(!SetIndexBuffer(7,Ema) &&
!SetIndexBuffer(6,EmaOfEma) &&
!SetIndexBuffer(5,EmaOfEmaOfEma) &&
!SetIndexBuffer(4,Dema)&&
!SetIndexBuffer(3,Tema)&&
!SetIndexBuffer(2,dematrix)&&
!SetIndexBuffer(1,tematrix)&&
!SetIndexBuffer(0,tdcd))
Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("TDCD TD trix ("+EMA_Period+") ");
// Tema[i]=3 * Ema[i] - 3 * EmaOfEma[i] + EmaOfEmaOfEma[i];
SetIndexLabel(0,"tdcd ");
SetIndexLabel(1,"tematrix ");
SetIndexLabel(2,"tdosma/dematrix");
//---- 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--)if (Dema[i]||Tema[i]!=0)
{
Tema[i]=3 * Ema[i] - 3 * EmaOfEma[i] + EmaOfEmaOfEma[i];
tdcd [i]=10*(Tema[i]-Dema[i])/Dema[i]*3;
}
if (!tdOsma) {
for(i=limit; i >=0; i--) if (EmaOfEma[i+1]!=0)
dematrix[i] =100*(EmaOfEma[i]-EmaOfEma[i+1])/EmaOfEma[i+1];
}
else
for(i=limit; i >=0; i--) if (EmaOfEmaOfEma[i]!=0)
dematrix[i] =10*(EmaOfEma[i]-EmaOfEmaOfEma[i])/EmaOfEmaOfEma[i];
for(i=limit; i >=0; i--) if (EmaOfEmaOfEma[i+1]!=0)
tematrix[i] =100*(EmaOfEmaOfEma[i]-EmaOfEmaOfEma[i+1])/EmaOfEmaOfEma[i+1];
//----
return(0);
}
//+------------------------------------------------------------------+
Comments