This technical indicator is designed to provide traders with a highly refined and smoothed view of market price action. By utilizing a specialized mathematical approach known as a Triple Exponential Moving Average (TeMA), the tool aims to reduce "market noise"—the small, erratic price fluctuations that can often trigger false signals—while maintaining high responsiveness to actual trend changes.
Core Logic and Functionality
The script operates by passing the market price through several layers of calculation. Instead of simply looking at a raw average of recent prices, it performs the following sequential steps:
- Data Selection: The user can choose which specific price data to analyze (such as the Closing price, Open price, High, Low, or a weighted average of these values). This allows the indicator to be tailored to different trading styles.
- Multi-Layer Smoothing: The script calculates a series of moving averages based on three distinct periods defined by the user. By nesting these calculations (an average of an average of an average), the indicator filters out minor price "hiccups" more effectively than standard moving averages.
- Weighted Calculation: Rather than treating every data point with equal importance, the logic applies a specific weight to these smoothed layers. This helps ensure that the resulting line remains as close to the current price action as possible without becoming jagged or erratic.
- Final Refinement: A final smoothing pass is applied to the result, ensuring that the visual output on the chart is fluid and clear.
Visual Interpretation
The indicator produces a dynamic line on the trading chart. Because of its complex "triple" smoothing logic, it provides a more "stable" trend line than standard indicators. It is designed to help traders identify the primary direction of the market with greater clarity, making it easier to see where a trend is gaining strength or beginning to pivot.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| Double - Triple Exponential Moving Average.mq4 |
//| Copyright © 2006, Ronald Verwer/ROVERCOM |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Ronald Verwer/ROVERCOM"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_width1 2
#property indicator_width2 2
//---- indicator parameters
extern int Apply_To_Price=0; //0=close 1=Open 2=High 3=Low 4=(H+L)/2 5=(H+L+C)/3 6=(H+L+C+C)/4extern int MA1_FirstPeriod=10;
extern int TeMA_Method=3; //0=Simple 1=Exponential 2=Smoothed 3=linear weighted
extern int TeMA_FirstPeriod=3;
extern int TeMA_SecondPeriod=6;
extern int TeMA_ThirdPeriod=15;
extern int TeMA_SmoothingPeriod=3;
//---- indicator buffers
double x0[];
double x1[];
double x[];
double y[];
double z[];
double q[];
string txt;
int clr1,clr2;
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
int draw_begin;
//---- drawing settings
IndicatorBuffers(8);
SetIndexStyle(0,DRAW_LINE,0,2);
SetIndexStyle(1,DRAW_LINE,0,2);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//if(TeMA_FirstPeriod<2) TeMA_FirstPeriod=13;
draw_begin=TeMA_SecondPeriod-1;
//---- indicator short name
SetIndexDrawBegin(0,draw_begin);
//---- indicator buffers mapping
SetIndexBuffer(0,x0);
SetIndexBuffer(1,x1);
SetIndexBuffer(2,x);
SetIndexBuffer(3,y);
SetIndexBuffer(4,z);
SetIndexBuffer(5,q);
switch(Apply_To_Price)
{
case 1:
{txt="Open";break;}
case 2:
{txt="High";break;}
case 3:
{txt="Low"; break;}
case 4:
{txt="Median"; break;}
case 5:
{txt="Typical"; break;}
case 6:
{txt="WghtdClose"; break;}
default:
{txt="Close";}
}
IndicatorShortName("TeMa/"+txt+"("+TeMA_FirstPeriod+")");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int i,limit,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--)
x[i]=iMA(NULL,0,TeMA_FirstPeriod,0,TeMA_Method,Apply_To_Price,i);
for(i=limit;i>=0;i--)
y[i]=iMAOnArray(x,0,TeMA_SecondPeriod,0,TeMA_Method,i);
for(i=limit;i>=0;i--)
z[i]=iMAOnArray(y,0,TeMA_ThirdPeriod,0,TeMA_Method,i);
for(i=limit;i>=0;i--)
q[i]=x[i]*3-y[i]*3+z[i];
for(i=limit;i>=0;i--)
{
x0[i]=iMAOnArray(q,0,TeMA_SmoothingPeriod,0,TeMA_Method,i);
x1[i]=x0[i];
if(x0[i]>x0[i+1])
x1[i+1]=EMPTY_VALUE;
}
return(0);
}
//+------------------------------------------------------------------+
Comments