Author: Copyright � 2005, Nick Bilak
mT3

This tool is designed to provide a highly smoothed trend line on your trading chart. While standard moving averages are often criticized for being "laggy" (reacting too slowly to price changes) or "noisy" (jumping around too much), this script utilizes a sophisticated multi-layered calculation method to find a balance between the two.

How the Logic Works

The core logic of this script follows a process of "nested smoothing." Instead of calculating a single average of the price, the tool performs the following steps:

1. Successive Layering The script starts by calculating a standard Exponential Moving Average (EMA) based on the closing prices. However, it does not stop there. It takes that first average and calculates another average of that result. It repeats this process several times, creating a chain of nested averages.

2. The Smoothing Effect By layering these calculations, each subsequent level removes more "market noise." This prevents the indicator from reacting to every tiny, insignificant price flicker, ensuring that only significant movements are captured.

3. Weighted Synthesis (The T3 Calculation) In the final stage, the script doesn't just show you the last average in the chain. It uses a specific mathematical formula to combine the data from all the different layers it created. By applying specific weights to these various levels of smoothing, it produces the "T3MA" result.

The Final Result

The end product is a smooth, flowing line on your chart that represents the underlying trend of the asset.

  • Stability: Because of the multi-layered approach, the line is much less erratic than a standard moving average.
  • Responsiveness: Because it uses an exponential weighting system rather than a simple linear one, it maintains a better connection to current price action than many other smoothed indicators.
  • Visual Guidance: The tool provides a clear visual path of the trend, helping traders distinguish between temporary market fluctuations and actual directional shifts.
Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
mT3
//+------------------------------------------------------------------+
//|                                     T3MA.mq4   |
//|                                     Copyright © 2005, Nick Bilak |
//|                                   http://www.forex-tsd.com/ 
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Nick Bilak"
#property link      "http://www.forex-tsd.com/"

//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 1
#property  indicator_color1  Green
#property indicator_width1 2
extern double a = 0.7;

//---- indicator parameters
extern int Periods=10;
//---- indicator buffers
double e1[];
double e2[];
double e3[];
double e4[];
double e5[];
double e6[];
double e7[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(7);
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexDrawBegin(0,Periods);
   if(
   	!SetIndexBuffer(0,e7) &&
      !SetIndexBuffer(1,e2) &&
      !SetIndexBuffer(2,e3) &&
      !SetIndexBuffer(3,e4) &&
      !SetIndexBuffer(4,e5) &&
      !SetIndexBuffer(5,e6) &&
   	!SetIndexBuffer(6,e1)
      )
      Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("mT3MA("+Periods+")");
//---- initialization done
   return(0);
   
  }
//+------------------------------------------------------------------+
//| Moving Average of Oscillator                                     |
//+------------------------------------------------------------------+
int start()
  {
   int i,limit;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

//---- main loop
   for(i=limit; i>=0; i--) {
   	e1[i]=iMA(NULL,0,Periods,0,MODE_EMA,PRICE_CLOSE,i);
   }
   for(i=limit; i>=0; i--) {
   	e2[i]=iMAOnArray(e1,0,Periods,0,MODE_EMA,i);
   }
   for(i=limit; i>=0; i--) {
   	e3[i]=iMAOnArray(e2,0,Periods,0,MODE_EMA,i);
   }
   for(i=limit; i>=0; i--) {
   	e4[i]=iMAOnArray(e3,0,Periods,0,MODE_EMA,i);
   }
   for(i=limit; i>=0; i--) {
   	e5[i]=iMAOnArray(e4,0,Periods,0,MODE_EMA,i);
   }
	//double a=0.8;
	double c1=-a*a*a;
	double c2=3*a*a+3*a*a*a;
	double c3=-6*a*a-3*a-3*a*a*a;
	double c4=1+3*a+a*a*a+3*a*a;
	//T3MA=c1*e6+c2*e5+c3*e4+c4*e3;
   for(i=limit; i>=0; i--) {
   	e6[i]=iMAOnArray(e5,0,Periods,0,MODE_EMA,i);
   	e7[i]=c1*e6[i]+c2*e5[i]+c3*e4[i]+c4*e3[i];
   }
   string tComment="";
   tComment="e1[0]="+DoubleToStr(e1[0],4)+" e2[0]="+DoubleToStr(e2[0],4)+" e3[0]="+DoubleToStr(e3[0],4)+" e4[0]="+DoubleToStr(e4[0],4)+" e5[0]="+DoubleToStr(e5[0],4)+" e6[0]="+DoubleToStr(e6[0],4)+" e7[0]="+DoubleToStr(e7[0],4);
   if(e7[0]<Ask) tComment="mT3 under price. "+tComment;
   else tComment="MT3 above price. "+tComment;
   //Comment(tComment);
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments