Zee Zee i
Download scriptThe Zee Zee i indicator is a technical analysis tool designed to measure the momentum of a financial asset by calculating its price strength relative to its historical average. It helps traders identify whether an asset is overextended, trending strongly, or experiencing a potential reversal.
Core Logic and Calculation Process
The script operates by processing historical price data through several distinct layers of calculation:
1. Establishing a Baseline (Moving Average) First, the indicator identifies a "typical price" for every candle, which is derived from the average of the high, low, and closing prices. It then calculates a Simple Moving Average (SMA) based on a user-defined period (defaulting to 14). This acts as the baseline, representing the "normal" equilibrium of the market.
2. Measuring Variance (Standard Deviation) To understand how much the price is deviating from that baseline, the script calculates the distance between the current typical price and the moving average over the specified period. It then applies a mathematical multiplier to this sum. This creates a measure of volatility—essentially determining how "stretched" the price is from its average.
3. Calculating Relative Strength (CCI) By taking the difference between the current price and the moving average, and then dividing it by the variance calculated in the previous step, the indicator produces a Commodity Channel Index (CCI) value. This value represents how many standard deviations the current price is away from its mean.
Visual Indicators and Signals
The script translates these complex calculations into visual elements on your chart to make them easy to interpret:
- Trend Line: The primary line tracks the relative strength of the asset.
- Overbought Threshold (+100): When the price moves significantly higher than the average, the indicator identifies it as a "High" zone. If the value exceeds 100, it highlights this area (indicated in yellow), suggesting the asset may be overextended to the upside.
- Oversold Threshold (-100): Conversely, when the price drops significantly below the average, the indicator identifies a "Low" zone. If the value falls below -100, it marks this area (indicated in red), suggesting the asset may be stretched to the downside.
Summary for Traders
In essence, this script filters out market "noise" to show you the relationship between price and volatility. It tells you not just where the price is, but how much "energy" is behind the current move relative to recent history, helping you identify potential exhaustion points in a trend.
//+------------------------------------------------------------------+
//| Zee Zee i.mq4 |
//| Copyright © 2007, Carlos J. Rivas |
//| carlos@vealo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Carlos J. Rivas"
#property link "carlos@vealo.com"
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color5 Yellow
#property indicator_color4 CLR_NONE
#property indicator_color3 CLR_NONE
#property indicator_color2 CLR_NONE
#property indicator_color1 Chocolate
#property indicator_color6 Red
#property indicator_level1 100
#property indicator_level2 -100
#property indicator_levelcolor DimGray
//---- input parameters
extern int CCIPeriod=14;
//---- buffers
double CCIBuffer[];
double CCIBufferHi[];
double CCIBufferLow[];
double RelBuffer[];
double DevBuffer[];
double MovBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- 3 additional buffers are used for counting.
//IndicatorBuffers(6);
SetIndexBuffer(1, RelBuffer);
SetIndexBuffer(2, DevBuffer);
SetIndexBuffer(3, MovBuffer);
SetIndexBuffer(4, CCIBufferHi);
SetIndexBuffer(5, CCIBufferLow);
//---- indicator lines
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,CCIBuffer);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,CCIBufferHi);
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,CCIBufferLow);
//---- name for DataWindow and indicator subwindow label
short_name="ZZI("+CCIPeriod+")";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
//SetIndexDrawBegin(0,CCIPeriod);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Commodity Channel Index |
//+------------------------------------------------------------------+
int start()
{
int i,k,counted_bars=IndicatorCounted();
double price,sum,mul;
if(Bars<=CCIPeriod) return(0);
//---- initial zero
if(counted_bars<1)
{
for(i=1;i<=CCIPeriod;i++) CCIBuffer[Bars-i]=0.0;
for(i=1;i<=CCIPeriod;i++) DevBuffer[Bars-i]=0.0;
for(i=1;i<=CCIPeriod;i++) MovBuffer[Bars-i]=0.0;
}
//---- last counted bar will be recounted
int limit=Bars-counted_bars;
if(counted_bars>0) limit++;
//---- moving average
for(i=0; i<limit; i++)
MovBuffer[i]=iMA(NULL,0,CCIPeriod,0,MODE_SMA,PRICE_TYPICAL,i);
//---- standard deviations
i=Bars-CCIPeriod+1;
if(counted_bars>CCIPeriod-1) i=Bars-counted_bars-1;
mul=0.015/CCIPeriod;
while(i>=0)
{
sum=0.0;
k=i+CCIPeriod-1;
while(k>=i)
{
price=(High[k]+Low[k]+Close[k])/3;
sum+=MathAbs(price-MovBuffer[i]);
k--;
}
DevBuffer[i]=sum*mul;
i--;
}
i=Bars-CCIPeriod+1;
if(counted_bars>CCIPeriod-1) i=Bars-counted_bars-1;
while(i>=0)
{
price=(High[i]+Low[i]+Close[i])/3;
RelBuffer[i]=price-MovBuffer[i];
i--;
}
//---- cci counting
i=Bars-CCIPeriod+1;
if(counted_bars>CCIPeriod-1) i=Bars-counted_bars-1;
while(i>=0)
{
if(DevBuffer[i]==0.0) CCIBuffer[i]=0.0;
else CCIBuffer[i]=RelBuffer[i]/DevBuffer[i];
if (CCIBuffer[i] >= 100) {
CCIBufferHi[i]=CCIBuffer[i];
//CCIBuffer[i]=0.0;
}
if (CCIBuffer[i] <= -100) {
CCIBufferLow[i]=CCIBuffer[i];
//CCIBuffer[i]=0.0;
}
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments