This tool is designed to provide traders with a visual aid for identifying market trends and momentum by analyzing price fluctuations. It works by processing standard technical data and transforming it into a color-coded system that highlights whether the market is moving upward, downward, or remaining neutral.
Core Components
The script utilizes two primary types of calculations:
- Standard Momentum (CCI): A baseline measurement used to gauge the current price relative to its recent average.
- Fast Momentum (TCCI): A quicker, more sensitive version of the same measurement that reacts rapidly to minor price shifts.
How the Logic Works
The indicator operates through a multi-step analysis of historical price data:
- Data Gathering: The script continuously monitors two different time horizons (defined by the "CCI_Period" and "TCCI_Period"). By looking at these different speeds, the tool can distinguish between long-term trends and immediate price noise.
- Trend Validation: Rather than simply reacting to a single moment in time, the logic performs a "look-back" check. It examines a sequence of recent data points to confirm a trend. For a trend to be officially recognized as "Long" (Upward) or "Short" (Downward), it requires consistent movement over a specific number of bars.
- Dynamic Coloring System: Based on the trend validation, the script paints the chart in different colors to give you an instant visual cue:
- Green (Long Trend): Appears when the data confirms sustained upward momentum.
- Red (Short Trend): Appears when the data confirms sustained downward momentum.
- Gray (Flat/Neutral): Appears during periods of uncertainty or consolidation where the trend is not strong enough to be categorized as either up or down.
Summary for the User
Essentially, this script filters out "market noise." Instead of showing you every tiny wobble in price, it looks for consistent patterns of movement. By using different colors, it tells you at a glance whether the current market environment favors an upward bias (Green), a downward bias (Red), or if the market is currently indecisive (Gray).
//+------------------------------------------------------------------+
//| SuperWoodiesCCI.mq4 |
//| duckfu |
//| http://www.dopeness.org |
//+------------------------------------------------------------------+
#property copyright "duckfu"
#property link "http://www.dopeness.org"
#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Blue // CCI Colour (note the superfluous vowel, cheers mates ;)
#property indicator_color2 Yellow // TCCI Colour
#property indicator_color3 LimeGreen // Long Trend Histogram Colour
#property indicator_color4 Red // Short Trend Histogram Colour
#property indicator_color5 Gray // No Trend Histogram Colour
#property indicator_level1 200
#property indicator_level2 100
#property indicator_level3 -100
#property indicator_level4 -200
//---- input parameters
extern int CCI_Period=14;
extern int TCCI_Period=6;
//---- buffers
double ExtCCIBuffer[];
double ExtTCCIBuffer[];
double ExtLongHistBuffer[];
double ExtShortHistBuffer[];
double ExtFlatHistBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init(){
//---- indicators
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(0,ExtCCIBuffer);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
SetIndexBuffer(1,ExtTCCIBuffer);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexBuffer(2,ExtLongHistBuffer);
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexBuffer(3,ExtShortHistBuffer);
SetIndexStyle(4,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexBuffer(4,ExtFlatHistBuffer);
ArrayInitialize(ExtCCIBuffer,0);
ArrayInitialize(ExtTCCIBuffer,0);
ArrayInitialize(ExtLongHistBuffer,0);
ArrayInitialize(ExtShortHistBuffer,0);
ArrayInitialize(ExtFlatHistBuffer,0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit(){
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start(){
int i,j,limit,counted_bars=IndicatorCounted();
int uptrending=0,downtrending=0;
//---- TODO: add your code here
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=0; i<limit; i++){
ExtCCIBuffer[i]=iCCI(NULL,0,CCI_Period,PRICE_TYPICAL,i);
ExtTCCIBuffer[i]=iCCI(NULL,0,TCCI_Period,PRICE_TYPICAL,i);
ExtFlatHistBuffer[i]=ExtCCIBuffer[i];
}
for(i=0;i<limit;i++){
for(j=0;j<6;j++){
if(ExtCCIBuffer[i+j] > 0){
uptrending++;
downtrending=0;
} else if(ExtCCIBuffer[i+j] < 0){
uptrending=0;
downtrending++;
}
}
if(uptrending>5){
ExtLongHistBuffer[i]=ExtCCIBuffer[i];
ExtShortHistBuffer[i]=0;
ExtFlatHistBuffer[i]=0;
} else if(downtrending>5){
ExtShortHistBuffer[i]=ExtCCIBuffer[i];
ExtLongHistBuffer[i]=0;
ExtFlatHistBuffer[i]=0;
} else {
ExtShortHistBuffer[i]=0;
ExtLongHistBuffer[i]=0;
ExtFlatHistBuffer[i]=ExtCCIBuffer[i];
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments