Author: Copyright � 2005, Nick Bilak
T3MA_v1

This technical indicator is designed to provide a smoothed representation of price action on a trading chart. While standard moving averages are often used to identify trends, they can sometimes be "laggy" (reacting slowly to new information) or "noisy" (reacting too sharply to minor price fluctuations). This specific script, the T3 Moving Average, uses a multi-layered mathematical approach to solve these issues simultaneously.

How the Logic Works

The core logic of this script relies on a process of recursive smoothing. Instead of calculating a single average of the price, the script performs the following steps:

  1. Layered Calculations: The tool calculates an Exponential Moving Average (EMA) based on your chosen time period. However, it doesn't stop there. It takes that first average and calculates another average of those results, repeating this process multiple times.
  2. The "T3" Formula: By nesting these averages within one another, the script creates a highly refined data set. The final output is derived from a specific weighted combination of these nested layers.
  3. Optimization for Accuracy: The script applies specific coefficients (mathematical multipliers) to each layer of the calculation. These coefficients are balanced to ensure that the resulting line follows the price closely enough to be relevant, but remains smooth enough to filter out "market noise" that might trigger false signals.

Key Benefits for the User

  • Reduced Lag: By using this specific mathematical weighting, the indicator attempts to provide a trend line that reacts faster than a standard moving average of the same length.
  • Enhanced Smoothness: Because the logic passes through multiple layers of calculation, the resulting line is much cleaner. It eliminates the "jitter" often seen in fast-moving markets, making it easier for a trader to identify the true direction of the trend.
  • Customizable Sensitivity: The user can adjust the "Periods" parameter to determine how much historical data the tool looks at, allowing you to switch between identifying short-term momentum or long-term structural trends.

In summary, this script acts as a sophisticated filter. It takes raw price data, runs it through a series of smoothing "filters," and presents you with a refined trend line that aims to balance speed and stability more effectively than a traditional moving average.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
17 Views
0 Downloads
0 Favorites
T3MA_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                         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  Aqua
//---- indicator parameters
extern int Periods=12;
//---- 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(4,e6) &&
   	!SetIndexBuffer(5,e1)
      )
      Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("T3MA("+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-Periods-1-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);
   }
   for(i=limit; i>=0; i--) {
   	e6[i]=iMAOnArray(e5,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];
   }
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments