This tool is a specialized technical analysis indicator designed to provide a smoother and more accurate representation of price trends on a trading chart. It utilizes a sophisticated mathematical technique known as the "T3" moving average, which aims to reduce the "lag" typically found in standard moving averages while simultaneously filtering out market noise.
Core Logic and Methodology
The logic behind this script can be broken down into three main stages:
1. Multi-Layered Smoothing Instead of calculating a single moving average based directly on current prices, the script performs a process of "nested" smoothing. It takes the closing price and passes it through six consecutive layers of Exponential Moving Average (EMA) calculations. By stacking these layers, the tool creates a highly refined data set where each subsequent layer becomes progressively smoother than the last.
2. Weighted Price Modeling Once the six layers of smoothed data are generated, the script applies a specific mathematical formula to combine them into a single output line. It assigns unique weights (coefficients) to each of the six layers based on an amplification factor. This ensures that the final result isn't just a simple average, but a weighted model that balances responsiveness to new price changes with the stability of historical data.
3. Dynamic Responsiveness The script is configured with specific user-adjustable periods (Fast and Slow) and a fixed internal amplification constant. This allows it to "fit" the price action more closely than traditional indicators. Because it uses these specialized coefficients, the resulting line attempts to stay closer to the actual price movement during trends while remaining less erratic during periods of sideways market fluctuation.
Summary for Traders
In practical terms, this indicator provides a cleaner visual path of where the price is heading. By utilizing six layers of calculations and a weighted distribution model, it seeks to identify the "true" trend of an asset, helping traders see through minor price spikes that might otherwise trigger false signals in standard moving average tools.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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 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)
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