FX Sniper's T3 CCI_002
Download scriptThe FX Sniper's T3 CCI is a customized technical analysis tool designed for the MetaTrader platform. It functions by taking a standard momentum indicator—the Commodity Channel Index (CCI)—and refining it through a sophisticated smoothing process to provide clearer, more stable market signals.
Core Logic and Functionality
The primary objective of this script is to reduce the "noise" often found in raw price data. While standard indicators can sometimes fluctuate erratically, this tool applies a specific mathematical filter known as the T3MA (T3 Moving Average) logic to the CCI values.
How it works step-by-step:
- Data Foundation: The script starts by calculating the standard CCI based on a user-defined period. This provides the raw momentum data regarding whether an asset is overbought, oversold, or trending.
- Advanced Smoothing: Instead of using a simple average, the tool utilizes a multi-stage weighted calculation. It passes the raw data through several layers of weighting (represented by variables like e1 through e6). This specific sequence allows the indicator to follow price trends more closely than a traditional moving average while remaining much smoother.
- Weighting Factors: The script incorporates a "Beta" coefficient (set at 0.618, a common ratio in technical analysis) to balance how quickly the indicator reacts to new price movements versus how much it relies on past data.
- Visual Separation: To make the data easier for traders to interpret, the tool splits the resulting information into three distinct visual components:
- The Main Trend Line: A smooth, primary line that represents the filtered momentum of the market.
- Upper Histogram: This captures and highlights only the positive (above zero) momentum values.
- Lower Histogram: This captures and highlights only the negative (below zero) momentum values.
Summary for the User
By combining these elements, the FX Sniper's T3 CCI provides a cleaner visual representation of market strength. It helps traders identify the underlying trend by filtering out minor price spikes, making it easier to spot sustained momentum shifts in both upward and downward directions.
//+------------------------------------------------------------------+
//| FX Sniper's T3 CCI.mq4 |
//| FX Sniper |
//| |
//+------------------------------------------------------------------+
#property copyright "FX Sniper: T3-CCI :-)"
#property link "http://dunno.com :-)/"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Green
#property indicator_color3 Red
//----
extern int CCI_Period = 14;
extern int T3_Period = 5;
extern double b = 0.618;
//----
double e1, e2, e3, e4, e5, e6;
double c1, c2, c3, c4;
double n, w1, w2, b2, b3;
double cci[];
double cciHup[];
double cciHdn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators setting
SetIndexBuffer(0, cci);
SetIndexBuffer(1, cciHup);
SetIndexBuffer(2, cciHdn);
//----
SetIndexStyle(0, DRAW_LINE,0,2);
SetIndexStyle(1, DRAW_HISTOGRAM,0,2);
SetIndexStyle(2, DRAW_HISTOGRAM,0,2);
//----
IndicatorShortName("FXST3CCI(" + CCI_Period + ", " + T3_Period + ")");
SetIndexLabel(0, "FXST3CCI");
SetIndexLabel(1, NULL);
SetIndexLabel(2, NULL);
//---- variable reset
b2 = b*b;
b3 = b2*b;
c1 = -b3;
c2 = (3*(b2 + b3));
c3 = -3*(2*b2 + b + b3);
c4 = (1 + 3*b + b3 + 3*b2);
n = T3_Period;
//----
if(n < 1)
n = 1;
n = 1 + 0.5*(n - 1);
w1 = 2 / (n + 1);
w2 = 1 - w1;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int 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;
//---- indicator calculation
for(int i = Bars - 1; i >= 0; i--)
{
cci[i] = iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, i);
e1 = w1*cci[i] + w2*e1;
e2 = w1*e1 + w2*e2;
e3 = w1*e2 + w2*e3;
e4 = w1*e3 + w2*e4;
e5 = w1*e4 + w2*e5;
e6 = w1*e5 + w2*e6;
cci[i] = c1*e6 + c2*e5 + c3*e4 + c4*e3;
//----
if(cci[i] >= 0)
cciHup[i] = cci[i];
else
cciHup[i] = 0;
//----
if(cci[i] < 0 )
cciHdn[i] = cci[i];
else
cciHdn[i] = 0;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments