Author: Copyright � 2005, Nick Bilak
T3MA_mod_3

This tool is a specialized technical analysis indicator designed to track price trends on your trading charts. It works by calculating a sophisticated type of moving average known as the T3 Moving Average.

Unlike standard moving averages, which can sometimes react too slowly to price changes or create "choppy" lines that give false signals, this script uses a multi-layered smoothing process to provide a much cleaner and more responsive visual representation of the market trend.

How the Logic Works

To achieve its smooth results, the script performs a sequential "nesting" calculation. Instead of calculating a single average of the price, it follows these steps:

  • Layered Smoothing: The script takes the current price and calculates an initial Exponential Moving Average (EMA). It then takes that result and calculates another EMA on top of it. It repeats this process multiple times in a chain.
  • Compounding Data: By layering the averages, the script filters out "market noise"—those small, insignificant price flickers—while still maintaining the core direction of the trend.
  • The Volume Factor: The script includes a specific mathematical constant (the Volume Factor). This acts as a weight to determine exactly how much "weight" is given to the smoothing process. It allows the indicator to balance responsiveness against smoothness.
  • Weighted Calculation: In the final stage, the script combines the results of all these layers using a specific polynomial formula. This produces the final line you see on your chart.

Key Benefits for Traders

  1. Reduced Lag: Because of its unique mathematical structure, it aims to stay closer to the actual price action than traditional moving averages, helping you identify trend changes more quickly.
  2. Visual Clarity: The resulting line is much smoother than a standard average. This makes it easier for traders to identify the underlying "flow" of the market without being distracted by minor price fluctuations.
  3. Trend Identification: By providing a cleaner visual path, it helps you clearly see whether the current market momentum is bullish (upward) or bearish (downward), making it a useful tool for determining entry and exit points.
Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
T3MA_mod_3
//+------------------------------------------------------------------+
//|                                                         T3MA.mq4 |
//|                                     Copyright © 2005, Nick Bilak |
//|                                        http://www.forex-tsd.com/ |
//|                                modified for VolumeFactor by: ben |
//|                                                 updates properly |
//|                                                  thanks to Bilak |
//+------------------------------------------------------------------+
#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  Red
//---- indicator parameters
extern int Periods=5; //12 
extern double VolumeFactor= 0.5; //0.8
//---- 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,DRAW_LINE,2);
   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-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= VolumeFactor; //0.618;
	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