2CCI_ZeroCross_Alert_001

Author: Copyright � 2005, Jason Robinson (jnrtrading).
2CCI_ZeroCross_Alert_001

This script is a specialized technical analysis tool designed to monitor price momentum and provide real-time notifications when specific market conditions are met. It works by tracking two different versions of the "Commodity Channel Index" (CCI), which is a standard momentum oscillator used by traders to determine if an asset is overbought, oversold, or moving in a specific direction.

How the Logic Works

The tool operates by comparing two distinct layers of market data simultaneously:

  1. The Trend Layer: It monitors a "Long-Term" CCI (set to 50 periods). This represents the broader direction of the market trend.
  2. The Entry Layer: It monitors a "Short-Term" CCI (set to 14 periods). This represents immediate, fast-moving price action.

Instead of just looking at one indicator, the script looks for a specific type of harmony between these two layers. It identifies "Zero Cross" events—moments where the momentum shifts from negative to positive, or vice versa.

The Alert Criteria

The script is programmed to trigger an alert only when both the long-term trend and the short-term entry agree on a move. It looks for two specific scenarios:

  • Bullish Momentum (Upward Move): The script watches for the moment the short-term CCI moves into positive territory. At that exact moment, it checks if the long-term trend CCI has also successfully crossed above zero. If both are positive, it issues an alert confirming that the market may be shifting toward an upward move.
  • Bearish Momentum (Downward Move): Conversely, if the short-term CCI drops into negative territory, the script checks if the long-term trend CCI has also crossed below zero. If both are negative, it alerts the user to a potential downward shift in the market.

Visual Feedback

To help the user keep track of the current data without waiting for an alert, the script provides a real-time text display on the trading chart. This display constantly updates the current numerical values for both the Trend CCI and the Entry CCI, allowing you to see exactly how close the market is to triggering a notification.

In summary, this tool acts as a confirmation filter. It ignores minor price fluctuations and only notifies the user when both short-term momentum and long-term trends align in the same direction simultaneously.

Indicators Used
Commodity channel index
Miscellaneous
It issuies visual alerts to the screen
12 Views
0 Downloads
0 Favorites
2CCI_ZeroCross_Alert_001
//+------------------------------------------------------------------+
//|                                         2CCI_ZeroCross_Alert.mq4 |
//|                   Copyright © 2005, Jason Robinson (jnrtrading). |
//|                                      http://www.jnrtrading.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)."
#property link      "http://www.jnrtrading.co.uk"

#property indicator_chart_window

extern int CCI_Trend = 50;
extern int CCI_Entry = 14;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   double cciTrendNow, cciTrendPrevious, cciEntry;
   
   cciTrendNow = iCCI(NULL, 0, CCI_Trend, PRICE_TYPICAL, 0);
   cciTrendPrevious = iCCI(NULL, 0, CCI_Trend, PRICE_TYPICAL, 1);
   cciEntry = iCCI(NULL, 0, CCI_Entry, PRICE_TYPICAL, 0);
   
//---- 
   //Print(cciTrendNow, "...", cciTrendPrevious, "...", cciEntry);

   if(cciEntry < 0) {
      if((cciTrendNow < 0) && (cciTrendPrevious >= 0)) {
         Alert(Symbol(), " M", Period(), " Trend & Entry CCI Have both crossed below zero");
      }
   }
   else if(cciEntry > 0) {
      if((cciTrendNow > 0) && (cciTrendPrevious <= 0)) {
         Alert(Symbol(), " M", Period(), " Trend & Entry CCI Have both crossed above zero");
      }
   }
   Comment("Trend CCI: ", cciTrendNow, " Entry CCI: ", cciEntry);

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

Comments