SuperWoodieCCI_v3
Download scriptThe SuperWoodiesCCI is a specialized technical analysis tool designed to help traders identify market trends and momentum by analyzing the Commodity Channel Index (CCI). Rather than just providing a single line of data, this indicator translates complex price movements into a visual "histogram" that highlights the direction and strength of the current trend.
Core Mechanics
The logic operates by processing two distinct layers of information:
1. Base Data Processing The script calculates the standard CCI values based on specific timeframes provided by the user. It tracks these values to understand how far the current price is deviating from its statistical average. This serves as the foundation for all subsequent visual signals.
2. Trend Detection Logic Instead of reacting instantly to every small price flicker, the script looks at a sequence of recent data points (a "window" of the last 6 bars). It performs two specific checks:
- Uptrend Identification: The logic scans to see if the CCI values have remained consistently positive over several consecutive periods. If the trend persists with enough consistency, it confirms an upward move.
- Downtrend Identification: Conversely, the script looks for a sustained sequence of negative CCI values. If the price maintains this downward momentum over the same window, it confirms a bearish move.
Visual Output
The indicator communicates these findings through a multi-colored visual system in a separate window below your main chart:
- Trend Lines: The primary lines show the raw movement of the CCI data, providing a clear view of the current momentum.
- Dynamic Histogram: This is the core "visual summary" of the script. It changes color based on the trend detected by the logic:
- Lime Green: Appears when the logic confirms a sustained Uptrend.
- Red: Appears when the logic confirms a sustained Downtrend.
- Blue/Neutral: Represents periods where neither a strong uptrend nor a strong downtrend is confirmed, indicating a "flat" or indecisive market state.
By using this logic, the tool helps filter out market "noise," allowing traders to see the broader direction of the price action more clearly through color-coded trends.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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 White // 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 Blue // No Trend Histogram Colour
//---- input parameters
extern int CCI_Period=50;
extern int TCCI_Period=0;
//---- buffers
double ExtCCIBuffer[];
double ExtTCCIBuffer[];
double ExtLongHistBuffer[];
double ExtShortHistBuffer[];
double ExtFlatHistBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init(){
//---- indicators
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(0,ExtCCIBuffer);
SetIndexStyle(1,DRAW_LINE);
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++;
} else if(ExtCCIBuffer[i+j] < 0){
uptrending=0;
}
}
if(uptrending>5){
ExtLongHistBuffer[i]=ExtCCIBuffer[i];
ExtShortHistBuffer[i]=0;
ExtFlatHistBuffer[i]=0;
}
}
for(i=0;i<limit;i++){
for(j=0;j<6;j++){
if(ExtCCIBuffer[i+j] < 0){
downtrending++;
} else if(ExtCCIBuffer[i+j] > 0){
downtrending=0;
}
}
if(downtrending>5){
ExtShortHistBuffer[i]=ExtCCIBuffer[i];
ExtLongHistBuffer[i]=0;
ExtFlatHistBuffer[i]=0;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments