WoodiesCCI_v2

Download script
Author: created by Luis Damiani
WoodiesCCI_v2

The Woodies CCI script is a specialized technical analysis tool designed to help traders identify momentum and potential trend reversals by comparing two different speeds of price movement. It works by creating a visual representation of market "strength" through three distinct components: a fast line, a slow line, and a histogram.

Core Logic and Mechanics

The logic behind this script relies on the Commodity Channel Index (CCI), which is a momentum-based oscillator that measures how far the current price of an asset deviates from its statistical average. The script takes this standard indicator and modifies it into a "dual-speed" system:

  • The Fast Component: This captures immediate, short-term market fluctuations. By using a shorter look-back period, it reacts quickly to every minor price tick, highlighting rapid momentum shifts.
  • The Slow Component: This represents the broader, longer-term trend. By using a larger look-back period, it smooths out the "noise" of the market to show the underlying direction of the price.
  • The Histogram: This is the visual difference between the fast and slow components. It essentially acts as a "momentum gap" indicator—showing how much the current short-term price is pulling away from (or returning toward) the long-term average.

How the Script Processes Data

When you apply this script to a chart, it performs the following automated tasks:

  1. Data Synchronization: The script constantly monitors new price data as it arrives on the live chart. It checks if the settings have been changed by the user; if everything remains constant, it only updates the most recent candle to save processing power.
  2. Historical Calculation: Upon initial loading, the script scans back through a specific number of past bars (defined by the user) to ensure that the lines and histogram are fully drawn and accurate from the start of the visible chart.
  3. Real-Time Mapping: As new candles form, the script calculates two distinct CCI values for every price point. It then subtracts the slow value from the fast value to generate the histogram.

Practical Use for the Trader

From a visual standpoint, this logic allows a trader to see not just where the price is going, but how "aggressive" that movement is. When the fast line moves significantly away from the slow line, the histogram expands, signaling strong momentum. When the lines begin to converge or the histogram shrinks, it suggests that the current move may be losing steam, potentially signaling a coming trend reversal or a period of consolidation.

Indicators Used
Commodity channel index
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
WoodiesCCI_v2
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                   WoodiesCCI.mq4 |
//|                                                             Rosh |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "created by Luis Damiani; converted by Rosh"
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 DeepSkyBlue
#property indicator_color3 DimGray
//---- input parameters
extern int       A_period=14;
extern int       B_period=6;
extern int       num_bars=550;
// parameters
int shift=0;
bool initDone=true; // áûëî init
int bar=0;
int prevbars=0;
int startpar=0;  // áûëî start
int cs=0;
int prevcs=0;
string commodt="nonono";
int frame=0;
int bars=0;

//---- buffers
double FastWoodieCCI[];
double SlowWoodieCCI[];
double HistoWoodieCCI[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,FastWoodieCCI);
   SetIndexStyle(1,DRAW_LINE,1,3);
   SetIndexBuffer(1,SlowWoodieCCI);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexBuffer(2,HistoWoodieCCI);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//---- TODO: add your code here
cs= A_period+B_period+num_bars; //checksum used to see if parameters have been changed
if ((cs==prevcs)&&(commodt==Symbol())&&(frame==(Time[4]-Time[5]))&&((Bars-prevbars)<2)) startpar=Bars-prevbars; else startpar=-1;  //params haven't changed only need to calculate new bar
commodt=Symbol();
frame=Time[4]-Time[5];
prevbars = Bars;
prevcs = cs;
if (startpar==1 | startpar==0)  bar=startpar; else initDone = true;

if (initDone)
   {
   FastWoodieCCI[num_bars-1]=0;
   SlowWoodieCCI[num_bars-1]=0;
   HistoWoodieCCI[num_bars-1]=0;  
   //SetIndexValue(num_bars-1, 0);
   //SetIndexValue2(num_bars-1, 0);
   bar=num_bars-2;
   initDone=false;
   }

//SetLoopCount(0);
for (shift = bar;shift>=0;shift--)
   {
   FastWoodieCCI[shift]=iCCI(NULL,0,B_period,PRICE_TYPICAL,shift);
   SlowWoodieCCI[shift]=iCCI(NULL,0,A_period,PRICE_TYPICAL,shift);
   HistoWoodieCCI[shift]=iCCI(NULL,0,A_period,PRICE_TYPICAL,shift);  
   //SetIndexValue(shift,iCCIEx(A_period,PRICE_TYPICAL,shift));
   //SetIndexValue2(shift,iCCIEx(B_period,PRICE_TYPICAL,shift));
   }

//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments