WcciChart_v3

Download script
Author: Copyright � 2005, Gaba
WcciChart_v3

This tool is a technical analysis indicator designed to help traders visualize market momentum and identify underlying trends by using the Commodity Channel Index (CCI). Instead of showing a single simple line, it processes data to provide a multi-layered view of price movement, helping to distinguish between active trends and market noise.

Core Logic and Functionality

The script operates by calculating two different versions of the CCI: a "Fast" version and a "Slow" version. By comparing these two, the tool helps traders see both immediate price fluctuations and longer-term momentum.

1. Trend Identification (Histogram Layers) The indicator features a unique logic for identifying trends. It looks back at the most recent data points to determine the strength of the current movement:

  • Upward Trend: The script analyzes a series of preceding CCI values. If the majority of these values are positive, it highlights an upward trend using a specific histogram.
  • Downward Trend: Conversely, if the majority of those values are negative, it identifies a downward trend and displays it via a different histogram.
  • This means the visual "bars" on your chart actually represent the tool's confirmation of whether the current momentum is consistently moving in one direction.

2. Visual Signals (Lines and Buffers) The indicator provides five distinct visual components to help with analysis:

  • Fast & Slow CCI Lines: These show the raw data for both fast and slow calculations, allowing you to see how quickly the price is reacting compared to its historical average.
  • Trend Histograms: These provide the "smoothed" visual representation of whether the market is currently in an bullish or bearish state based on the logic mentioned above.

Key Features for the User

  • Dynamic Boundaries: The tool includes pre-defined levels (at 200, 100, -100, and -200). These act as visual markers to help you identify "overbought" or "oversold" conditions, where the price may be stretched too far in one direction.
  • Adjustable Sensitivity: The script allows you to customize the "Fast" and "Slow" periods. This means you can tweak the tool to be more responsive to quick price changes or more steady to focus on long-term shifts.
  • Automated Calculation: The logic automatically recalculates as new price data arrives, ensuring that the trend histograms and CCI lines stay updated with the latest market activity.

In summary, this script simplifies complex momentum math into a clear visual map. It tells you not just where the price is moving now, but confirms whether that movement has enough "weight" behind it to be considered a sustained trend.

Indicators Used
Commodity channel index
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
WcciChart_v3
#property copyright "Copyright © 2005, Gaba"
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Silver
#property indicator_color2 LimeGreen
#property indicator_color3 OrangeRed
#property indicator_color4 Silver
#property indicator_color5 Yellow

#property indicator_minimum -300
#property indicator_maximum  300

#property indicator_level1  200
#property indicator_level2  100
#property indicator_level3 -100
#property indicator_level4 -200


//////////////////////////////////////////////////////////////////////
// Ïàðåìåòû
//////////////////////////////////////////////////////////////////////

extern int fastPeriod  = 6;
extern int slowPeriod  = 14;
extern int histLength  = 500;

//////////////////////////////////////////////////////////////////////
// Áóôåðû äàííûõ
//////////////////////////////////////////////////////////////////////

double FastBuffer[];    // Áûñòðûé CCI
double SlowBuffer[];    // Ìåäëåííûé CCI
double HistBuffer[];
double UpTrBuffer[];
double DnTrBuffer[];

//////////////////////////////////////////////////////////////////////
// Èíèöèàëèçàöèÿ
//////////////////////////////////////////////////////////////////////

int init()
{
   string short_name;
   IndicatorBuffers(5);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   short_name="WoodiesCCI("+fastPeriod+","+slowPeriod+")";
   IndicatorShortName(short_name);
   // indicator lines ////////////////////////////////
   SetIndexStyle(0, DRAW_HISTOGRAM);   
   SetIndexBuffer(0, HistBuffer);
   SetIndexDrawBegin(0, slowPeriod);
   SetIndexLabel(0,"SlowCCI histogram");      
   SetIndexEmptyValue(0, EMPTY_VALUE);  
   //////////////////////////////////////////////////
   SetIndexStyle(1, DRAW_HISTOGRAM);   
   SetIndexBuffer(1, UpTrBuffer);
   SetIndexDrawBegin(1, slowPeriod); 
   SetIndexLabel(1,"UpTrend histogram");           
   SetIndexEmptyValue(1, EMPTY_VALUE);  
   //////////////////////////////////////////////////
   SetIndexStyle(2, DRAW_HISTOGRAM);   
   SetIndexBuffer(2, DnTrBuffer);
   SetIndexDrawBegin(2, slowPeriod);  
   SetIndexLabel(2,"DnTrend histogram");     
   SetIndexEmptyValue(2, EMPTY_VALUE);  
   //////////////////////////////////////////////////
   SetIndexStyle(3, DRAW_LINE,1,2);   
   SetIndexBuffer(3, SlowBuffer);
   SetIndexDrawBegin(3, slowPeriod);     
   SetIndexLabel(3,"SlowCCI("+slowPeriod+")");   
   SetIndexEmptyValue(3, EMPTY_VALUE);  
   //////////////////////////////////////////////////
   SetIndexStyle(4, DRAW_LINE);
   SetIndexBuffer(4, FastBuffer);
   SetIndexDrawBegin(4, slowPeriod);     
   SetIndexLabel(4,"FastCCI("+fastPeriod+")");  
   SetIndexEmptyValue(4, EMPTY_VALUE);  
   //////////////////////////////////////////////////
   return(0);
}
  
//////////////////////////////////////////////////////////////////////
// Custor indicator deinitialization function                       
//////////////////////////////////////////////////////////////////////

int deinit()
{
   // TODO: add your code here
   return(0);
}

//////////////////////////////////////////////////////////////////////
// Custom indicator iteration function                              
//////////////////////////////////////////////////////////////////////

int start()
{
   string symbolName;
   int i, shift, checksum, counted_bars=IndicatorCounted();
   double slowCCI=0.0;
   if (Bars<slowPeriod) return(0); 
   // check for possible errors
   if (counted_bars<0) return(-1);
   // last counted bar will be recounted
   if (counted_bars>0) counted_bars++;
   int limit=Bars-counted_bars;
   if (counted_bars<1 || checksum!=(histLength+fastPeriod+slowPeriod+Period()) || symbolName!=Symbol())
   {
      // Ïàðàìåòðû èçìåíåíû, ïðîâîäèì ðåèíèöèàëèçàöèþ 
      for(i=Bars-1; i<=Bars-histLength; i++) 
      {
         FastBuffer[i]=EMPTY_VALUE;    // Áûñòðûé CCI
         SlowBuffer[i]=EMPTY_VALUE;    // Ìåäëåííûé CCI
         HistBuffer[i]=EMPTY_VALUE;    // Ãèñòîãðàììà ìåäëåííîãî CCI
         UpTrBuffer[i]=EMPTY_VALUE;    // Íàïðàâëåíèå òðåíäà
         DnTrBuffer[i]=EMPTY_VALUE;    // Íàïðàâëåíèå òðåíäà
      }
      checksum = histLength+fastPeriod+slowPeriod+Period(); 
      symbolName=Symbol();
      limit = histLength;
   }   
   for (shift=limit; shift>=0; shift--)
   {
      FastBuffer[shift] = iCCI(NULL,0,fastPeriod,PRICE_TYPICAL,shift);
      SlowBuffer[shift] = iCCI(NULL,0,slowPeriod,PRICE_TYPICAL,shift);
      HistBuffer[shift] = SlowBuffer[shift];
      UpTrBuffer[shift] = EMPTY_VALUE;
      DnTrBuffer[shift] = EMPTY_VALUE;         
      //	Çàïîëíåíèå ìàññèâà òî÷åê è îïðåäåëåíèå òðåíäà
      int a, up=0, dn=0;
      for (a=0;a<8;a++)
      {  
         slowCCI=iCCI(NULL,0,slowPeriod,PRICE_TYPICAL,shift+a);
         if (slowCCI>0) up++;
         if (slowCCI<=0) dn++;		         
		}
      if (up>=6) UpTrBuffer[shift]=SlowBuffer[shift];
      if (dn>=6) DnTrBuffer[shift]=SlowBuffer[shift];      
   }    
   return(0);
}

//////////////////////////////////////////////////////////////////////




Comments