This script is designed to function as a specialized technical analysis tool that helps traders identify price momentum and potential trend reversals. It achieves this by combining two well-known mathematical concepts: the Commodity Channel Index (CCI) and a Triple Exponential Smoothing (T3) filter.
Core Logic Overview
The primary objective of this tool is to "smooth out" the natural noise and volatility of market data. While raw price action can be erratic, this script processes that data through multiple layers of calculation to highlight clearer, more reliable signals.
How the Data is Processed
The logic follows a structured three-step progression:
1. The Foundation (CCI) The script begins by looking at the Commodity Channel Index. This provides a baseline measurement of how far the current price is moving relative to its average range over a specific period. It helps determine if the market is currently overbought, oversold, or in a neutral state.
2. The Smoothing Layer (T3 Filtering) Instead of reacting immediately to every minor fluctuation in the CCI value, the script passes that data through a series of complex smoothing calculations (represented by multiple buffers). This "Triple Exponential" approach acts like a high-quality lens: it removes "market jitter" while preserving the essential shape of the trend. By layering these filters, the script ensures that the final output is much more stable than standard indicators.
3. The Signal Generation The final stage of the logic interprets the smoothed data to provide visual cues for the user:
- Dynamic Value: It calculates a specific numerical value based on the weighted average of the smoothed data.
- Trigger Levels: The script compares this calculated value against predefined boundaries (upper and lower limits). If the smoothed trend crosses these specific thresholds, it generates a distinct "trigger" signal.
Summary for the User
In practical terms, this tool doesn't just show you where the price is; it shows you the underlying momentum of the price after stripping away the distractions. By using the T3 smoothing method on the CCI base, the script aims to provide a clearer picture of whether a trend is gaining strength or beginning to exhaust itself, helping traders make more informed decisions based on filtered market movements.
//+------------------------------------------------------------------+
//| SmCCI.mq4 |
//| MetaQuotes |
//| http://forum.alpari-idc.ru/viewtopic.php?t=48186 |
//+------------------------------------------------------------------+
#property copyright "MetaQuotes"
#property link "http://forum.alpari-idc.ru/viewtopic.php?t=48186"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Gold
#property indicator_color2 Blue
//---- input parameters
extern double t3_period=8.0;
extern int per=14;
extern double ppor=100.0;
extern double mpor=-100.0;
extern double b=0.7;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double e1Buffer[];
double e2Buffer[];
double e3Buffer[];
double e4Buffer[];
double e5Buffer[];
double e6Buffer[];
double e1,e2,e3,e4,e5,e6,c1,c2,c3,c4,n,w1,w2,b2,b3;
double dpo,t3,cci,trig;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(8);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,e1Buffer);
SetIndexBuffer(3,e2Buffer);
SetIndexBuffer(4,e3Buffer);
SetIndexBuffer(5,e4Buffer);
SetIndexBuffer(6,e5Buffer);
SetIndexBuffer(7,e6Buffer);
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
SetIndexEmptyValue(2,0.0);
SetIndexEmptyValue(3,0.0);
SetIndexEmptyValue(4,0.0);
SetIndexEmptyValue(5,0.0);
SetIndexEmptyValue(6,0.0);
SetIndexEmptyValue(7,0.0);
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 deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int shift,limit;
if (counted_bars==0) limit=Bars-per;
if (counted_bars>=0) limit=Bars-counted_bars;
limit--;
//----
/*
for( shift=Bars-1;shift>=0;shift--)
{// Begin
ExtMapBuffer1[shift]=0.0; //SetIndexValue(shift, 0);
ExtMapBuffer2[shift]=0.0; //SetIndexValue2(shift, 0);
} // End
*/
for (shift=limit;shift>=0;shift--)
{//Begin
cci=iCCI(NULL,0,per,PRICE_CLOSE,shift);
dpo=cci;
e1Buffer[shift] = w1*dpo + w2*e1Buffer[shift+1];
e2Buffer[shift] = w1*e1Buffer[shift] + w2*e2Buffer[shift+1];
e3Buffer[shift] = w1*e2Buffer[shift] + w2*e3Buffer[shift+1];
e4Buffer[shift] = w1*e3Buffer[shift] + w2*e4Buffer[shift+1];
e5Buffer[shift] = w1*e4Buffer[shift] + w2*e5Buffer[shift+1];
e6Buffer[shift] = w1*e5Buffer[shift] + w2*e6Buffer[shift+1];
t3 = c1*e6Buffer[shift] + c2*e5Buffer[shift] + c3*e4Buffer[shift] + c4*e3Buffer[shift];
if (t3==0) t3=0.0001;
if (t3>0) trig=ppor;
if (t3<0) trig=mpor;
/*
if(shift==0) // âûâîäèì â ëîã òîëüêî íà íóëåâîì áàðå
{
Print("Bars=",Bars," e1=",e1," e2=",e2," e3=",e3," e4=",e4,
" e5=",e5," e6=",e6," t3=",t3);
}
*/
ExtMapBuffer1[shift]=trig; //SetIndexValue2(shift,trig);
ExtMapBuffer2[shift]=t3; //SetIndexValue(shift,t3);
}//end;
//----
return(0);
}
//+------------------------------------------------------------------+
Comments