CCI_Cross_New-2 only
Download scriptThis script is a technical analysis tool designed to identify specific momentum shifts in the financial markets. It works by monitoring three different "speeds" of the Commodity Channel Index (CCI), which is a standard momentum oscillator used to determine whether an asset is overbought, oversold, or experiencing a trend change.
Core Logic Overview
The primary objective of this script is to detect when the market crosses from negative territory into positive territory (potential upward movement) or vice versa (potential downward movement). It does this by analyzing three distinct timeframes or "speeds" simultaneously:
- Fast Momentum: Reacts quickly to immediate price changes.
- Slow Momentum: Provides a more balanced view of the current trend.
- Very Slow Momentum: Offers a broad perspective on long-term market direction.
How the Signals Work
The script looks for specific "crossings" where the momentum value flips from one side of the zero line to the other. It categorizes these signals into three levels:
- Level 1 (Fast): This triggers an alert as soon as the fastest momentum indicator crosses the zero line. These are high-sensitivity signals intended to catch early moves.
- Level 2 (Slow): This requires a more confirmed move. The signal only triggers if the slow momentum has been negative for at least two periods and then turns positive (or vice versa).
- Level 3 (Very Slow): This is the most conservative signal. It confirms that the very slow momentum has remained in a specific state for several periods before flipping, indicating a more established trend change.
Visual and Audio Feedback
To help the user identify these movements on a trading chart, the script performs the following actions:
- On-Chart Markers: When a crossing condition is met, the script places visual arrows directly on the chart. These appear slightly above or below the price candles to indicate the direction of the signal (Up or Down).
- Real-time Labels: The script displays a text comment in the corner of the chart area, identifying which specific level of signal has been triggered (e.g., "1st UP," "2nd Down," etc.).
- Audio Alerts: The script is configured to play a sound notification whenever a new signal appears on a new price candle, ensuring the trader is notified immediately of a momentum shift.
- Logging: It records the specific trend signal into the trading platform's log for later review.
Summary of User Experience
For a visitor using this tool, the logic provides a layered filtering system. Instead of relying on just one indicator, it gives you three layers of confirmation—ranging from "fast" alerts to "slow" and "very slow" confirmations—allowing you to decide how much momentum change you require before making a trading decision.
//+------------------------------------------------------------------+
//| CCI_Cross.mq4 |
//| Copyright © 2006, Eli Hayun |
//| http://www.elihayun.com |
//| Built for ValeoFX |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Eli Hayun"
#property link "http://www.elihayun.com"
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Red// 5-CCi
#property indicator_width1 2
#property indicator_color2 Red//5-CCi
#property indicator_width2 2
#property indicator_color3 EMPTY//Red//15-CCi
#property indicator_color4 EMPTY//Red //15-CCi
#property indicator_color5 EMPTY//DodgerBlue//28-CCi
#property indicator_color6 EMPTY//Red
//---- input parameters
extern int FastCCI=5;
extern int SlowCCI=15;
extern int VerySlowCCI=28;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID, 2);
SetIndexArrow(0,241);//217
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID, 2);
SetIndexArrow(1,242);//218
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexEmptyValue(1,0.0);
SetIndexStyle(2,DRAW_ARROW,STYLE_SOLID, 2);
SetIndexArrow(2,233);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexEmptyValue(2,0.0);
SetIndexStyle(3,DRAW_NONE);
SetIndexArrow(3,234);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexEmptyValue(3,0.0);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(4,241);
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexEmptyValue(4,0.0);
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,242);
SetIndexBuffer(5,ExtMapBuffer6);
SetIndexEmptyValue(5,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int shift;
for(shift=Bars-1;shift>=0;shift--)
{
ExtMapBuffer1[shift] = 0; ExtMapBuffer2[shift] = 0; ExtMapBuffer3[shift] = 0;
ExtMapBuffer4[shift] = 0; ExtMapBuffer5[shift] = 0; ExtMapBuffer6[shift] = 0;
double fCCI_0 = iCCI(NULL, 0, FastCCI, PRICE_TYPICAL, shift);
double fCCI_1 = iCCI(NULL, 0, FastCCI, PRICE_TYPICAL, shift+1);
// double fCCI_2 = iCCI(NULL, 0, FastCCI, PRICE_TYPICAL, shift+2);
if (fCCI_0 > 0 && fCCI_1<0 )
ExtMapBuffer1[shift] = Low[shift] - 3 * Point;
if (fCCI_0 < 0 && fCCI_1>0 )
ExtMapBuffer2[shift] = High[shift] + 3 * Point;
double sCCI_0 = iCCI(NULL, 0, SlowCCI, PRICE_TYPICAL, shift);
double sCCI_1 = iCCI(NULL, 0, SlowCCI, PRICE_TYPICAL, shift+1);
double sCCI_2 = iCCI(NULL, 0, SlowCCI, PRICE_TYPICAL, shift+2);
if (sCCI_0 > 0 && sCCI_1<0 && sCCI_2 < 0)
ExtMapBuffer3[shift] = Low[shift] - 4 * Point;
if (sCCI_0 < 0 && sCCI_1>0 && sCCI_2 > 0)
ExtMapBuffer4[shift] = High[shift] + 4 * Point;
double vsCCI_0 = iCCI(NULL, 0, VerySlowCCI, PRICE_TYPICAL, shift);
double vsCCI_1 = iCCI(NULL, 0, VerySlowCCI, PRICE_TYPICAL, shift+1);
double vsCCI_2 = iCCI(NULL, 0, VerySlowCCI, PRICE_TYPICAL, shift+2);
if (vsCCI_0 > 0 && vsCCI_1<0 && vsCCI_2 < 0)
ExtMapBuffer5[shift] = Low[shift] - 5 * Point;
if (vsCCI_0 < 0 && vsCCI_1>0 && vsCCI_2 > 0)
ExtMapBuffer6[shift] = High[shift] + 5 * Point;
}
string sComment = "";
if (ExtMapBuffer1[0] != 0)
sComment = sComment + " 1st UP";
if (ExtMapBuffer2[0] != 0)
sComment = sComment + " 1st Down";
if (ExtMapBuffer3[0] != 0)
sComment = sComment + " 2nd UP";
if (ExtMapBuffer4[0] != 0)
sComment = sComment + " 2nd Down";
if (ExtMapBuffer5[0] != 0)
sComment = sComment + " 3rd UP";
if (ExtMapBuffer6[0] != 0)
sComment = sComment + " 3rd Down";
if ((sComment != "") && (!IsTesting()))
{
if (NewBar())
{
PlaySound("wait.wav");//"expert.wav");
Print(Symbol(), " ", sComment);
}
Comment(TimeToStr(CurTime()), " ", sComment);
}
if ((sComment == "") && (!IsTesting()))
{
Comment("");
}
return(0);
}
//+------------------------------------------------------------------+
bool NewBar()
{
static datetime dt = 0;
//if (dt == 0) dt = Time[0];
if (dt != Time[0])
{
dt = Time[0];
return(true);
}
return(false);
}
Comments