Author: Copyright � 2005, Nick Bilak
T3MAopt_v2

The T3MAopt tool is a sophisticated technical analysis indicator designed to provide a smoother, more refined view of price action compared to standard moving averages. While traditional moving averages often suffer from "lag"—where the line reacts too slowly to new price changes—or "noise," where the line jumps around erratically due to minor market fluctuations, this script uses a specific mathematical approach called the T3 data-fitting technique to achieve a balance between the two.

How the Logic Works

The core logic of this script relies on a multi-layered smoothing process. Instead of simply averaging the most recent prices, it performs the following steps:

1. Sequential Smoothing (Layering) The script takes the closing price and processes it through six successive layers of calculation. Think of this like filtering water through multiple different filters; each layer removes more "noise" from the previous one. By the time the data reaches the sixth layer, the resulting figure is significantly smoother than the raw market price.

2. Weighted Amplification To ensure that the indicator doesn't become so smooth that it loses touch with current market reality, the script uses an amplification factor. This allows the tool to remain responsive to significant trends while still filtering out the tiny, insignificant price wiggles that often trigger false signals for traders.

3. Advanced Polynomial Calculation The final output is generated using a specific polynomial formula. By applying different weights (coefficients) to those six layers of smoothed data, the script calculates a single, fluid line. This creates a "best-fit" curve that follows the underlying trend of the asset more accurately than a standard moving average could.

Summary for the User

In practical terms, this script is designed to help you identify clear trends on your chart. Because it uses the T3 methodology, the resulting red line on your screen is intended to stay "closer" to the actual price action than traditional indicators, while remaining steady enough to prevent you from being distracted by minor, temporary market volatility.

Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
T3MAopt_v2
//+------------------------------------------------------------------+
//|                                                      T3MAopt.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  Red
/*
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)
Close1 = N-days EMA of Close Prices 
Close3 = N-days EMA of Close2 
Close3 = N-days EMA of Close2 
Close4 = N-days EMA of Close3 
Close5 = N-days EMA of Close4 
Close6 = N-days EMA of Close5
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 * Close6 + c2 * Close5 + c3 * Close4 + c4 * Close3
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 FastMA_Period=4;
extern int SlowMA_Period=6;
//----
double Close1,Close2,Close3,Close4,Close5,Close6;
//---- indicator buffers
double FastMABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(1);
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexDrawBegin(0,FastMA_Period);
   if(!SetIndexBuffer(0,FastMABuffer) )
      Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("T3MAopt("+FastMA_Period+")");
   Comment("T3MAopt("+FastMA_Period+")");
//---- 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-FastMA_Period-1-counted_bars;
//---- main loop
   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;
   double pr=2.0/(FastMA_Period+1);
   Close1=Close[limit+1];
   Close2=Close1;
   Close3=Close2;
   Close4=Close3;
   Close5=Close4;
   Close6=Close5;
     for(i=limit; i>=0; i--) 
     {
      Close1=Close[i]*pr+Close1*(1-pr);
      Close2=Close1*pr+Close2*(1-pr);
      Close3=Close2*pr+Close3*(1-pr);
      Close4=Close3*pr+Close4*(1-pr);
      Close5=Close4*pr+Close5*(1-pr);
      Close6=Close5*pr+Close6*(1-pr);
      FastMABuffer[i]=c1*Close6+c2*Close5+c3*Close4+c4*Close3;
     }
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments