Author: Copyright � 2005, Nick Bilak
T3MA_v2

This technical tool is designed to provide a smoother, more responsive moving average for analyzing market trends. Unlike standard moving averages that can sometimes lag significantly behind current price action or produce "noisy" visual data, this specific logic—known as the T3—is engineered to filter out market fluctuations while maintaining a close relationship with actual price movements.

How the Logic Works

The core principle behind this script is a multi-layered smoothing process. Instead of calculating a single average of the price, the script performs a sophisticated "nesting" technique:

  1. Sequential Averaging: The logic starts by taking the closing price and calculating an Exponential Moving Average (EMA). It then takes that result and calculates another EMA from it. This process is repeated several times in succession. By layering these averages on top of one another, the tool progressively removes "market noise" and creates a much smoother line.
  2. Amplification and Weighting: To ensure that the resulting line doesn't become too sluggish or disconnected from the current price, the script applies specific mathematical coefficients (weights). These weights are designed to balance the smoothness of the multi-layered averages with the speed required to react to new market trends quickly.
  3. Final Synthesis: The final output displayed on your chart is a weighted combination of these multiple layers. By blending these specific components together, the tool creates a moving average that offers a cleaner visual path than standard indicators, helping traders identify the underlying direction of a trend with greater clarity.

Key Benefits for the User

  • Reduced Noise: By smoothing out minor, insignificant price flickers, it helps in identifying the true direction of the market.
  • Balanced Responsiveness: It aims to solve the common problem where an indicator is either too fast (resulting in false signals) or too slow (resulting in late entries).
  • Enhanced Trend Clarity: Because the line is derived from multiple layers of data, it provides a more stable "road map" for following price action over time.
Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
T3MA_v2
/*-----------------------------+
|			       |
| 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

/*
Overview
T3 is an excellent data-fitting technique by Tim Tillson (cf. ``Smoothing Techniques For More Accurate Signals'' in Technical Analysis of Stocks and Commodities - January 1998)

Calculation
N is the Exponential Moving Average Period a is the amplification percentage of the filter's response to price movement (0 < a < 1)

e1 = N-days EMA of Close Prices 
e2 = N-days EMA of e1 
e3 = N-days EMA of e2 
e4 = N-days EMA of e3 
e5 = N-days EMA of e4 
e6 = N-days EMA of e5

c1 = (-a)^3 
c2 = 3 * a^2 
c3 = - 6 * a^2 - 3 * a - 3 * a^3 
c4 = 1 + 3 * a + a^3 + 3 * a^2

T3 = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3

Parameters
The default values are : N = 5 a = 0.7

Examples
GT::Indicators::T3->new() GT::Indicators::T3->new([5, 0.7])

*/

//---- 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(5,e6) &&
   	!SetIndexBuffer(6,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);
   }
	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