WcciChart_v4
Download scriptThis script is a specialized technical analysis tool designed to help traders visualize and identify market trends by analyzing price momentum. It utilizes a modified version of the "Woodies CCI" (Commodity Channel Index) logic, which compares different speeds of price movement to provide a clearer picture of the current market direction.
Core Logic Overview
The indicator works by tracking two distinct speeds of momentum: a Fast component and a Slow component. By comparing these two, the tool helps filter out "market noise" (minor price fluctuations) to reveal the underlying trend.
Key Visual Components
To help you interpret the market, the script displays five different data points on your chart:
- The Fast CCI Line: This represents immediate price momentum. It reacts quickly to every minor change in the market.
- The Slow CCI Line: This represents longer-term momentum. It is smoother and less reactive, providing a steady view of where the price is heading over a larger timeframe.
- The Slow CCI Histogram: This provides a visual "fill" for the slow momentum, making it easier to see the baseline movement.
- UpTrend & DownTrend Histograms: These are specialized visual cues. They highlight specific zones of strength:
- UpTrend: Activated when the slow momentum is consistently positive over a series of recent price points.
- DownTrend: Activated when the slow momentum is consistently negative over a series of recent price points.
How it Determines Trend Direction
The "intelligence" of this script lies in how it confirms trends. Rather than simply looking at whether a value is above or below zero, the script looks back at a small sequence of previous data points (a look-back window).
For a trend to be officially flagged as an UpTrend or DownTrend, the majority of those recent data points must align in one direction. This mathematical "voting" system ensures that the indicator only highlights a trend when there is consistent momentum, helping traders avoid false signals caused by temporary price spikes.
Summary for the User
Essentially, this tool acts as a momentum filter. It allows you to see the "heartbeat" of the market: the Fast lines show the immediate pulse, while the Slow lines and Histograms show the overall health of the trend. When the UpTrend or DownTrend highlights appear, it signifies that the market has enough consistent momentum to move in that specific direction.
//+------------------------------------------------------------------+
//| |
//| Copyright © 2000-2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.ru |
//+------------------------------------------------------------------+
#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 Black
//
#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,3);
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