CCI_Cross_Alert_v1M

Download script
Author: Copyright � 2005, Jason Robinson (jnrtrading).
CCI_Cross_Alert_v1M

This script is a specialized technical analysis tool designed for the MetaTrader platform to help traders identify specific momentum shifts in the market. It functions by monitoring the Commodity Channel Index (CCI), which is a common indicator used to measure how far the current price of an asset is deviating from its statistical average.

Core Functionality

The primary objective of this script is to detect "Zero Crosses." In trading terms, this refers to the moment the momentum shifts from negative to positive, or vice versa. The tool automates the identification of these pivotal moments by constantly comparing the current momentum value against a predefined threshold (the Signal Level).

How the Logic Works

The script operates by analyzing two consecutive points in time: the most recent data point and the point immediately preceding it. It looks for very specific "cross-over" events:

  • Sell/Bearish Signals: The script watches for a situation where the momentum was previously above a certain level but has suddenly dropped below it. When this downward crossover occurs, the script places a visual marker (an arrow) on the chart above the candle's high price to alert the trader of a potential shift toward a downward trend.
  • Buy/Bullish Signals: Conversely, the script monitors for moments where the momentum was previously below a certain level but has jumped above it. When this upward crossover happens, the script places a visual marker (an arrow) on the chart below the candle's low price to signal a potential shift toward an upward trend.

Key Features for the User

  • Automated Monitoring: Instead of a trader having to manually watch the CCI lines move back and forth across the zero mark, the script scans every historical and current candle to find these occurrences automatically.
  • Visual Cues: The logic translates complex mathematical data into simple visual icons on the main price chart. This allows traders to see potential entry or exit points at a glance without needing to constantly switch between different windows or tabs.
  • Customizable Sensitivity: The logic is built with adjustable parameters (Trend and Signal Level), allowing users to fine-tune how "fast" or "slow" the indicator responds to market movements, ensuring it aligns with their specific trading style.
Indicators Used
Commodity channel index
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
CCI_Cross_Alert_v1M
//+------------------------------------------------------------------+
//|                                         2CCI_ZeroCross_Alert.mq4 |
//|                   Copyright © 2005, Jason Robinson (jnrtrading). |
//|                                      http://www.jnrtrading.co.uk |
//+-------------------------------------------------------------------------------------+
//mod2008fxtsd
#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)."
#property link      "http://www.jnrtrading.co.uk"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Yellow
#property indicator_width1 0 
#property indicator_color2 Yellow
#property indicator_width2 0

extern int CCI_Trend = 5;
extern int SignalLevel = 0;

double bBuffer1[];
double sBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexBuffer(0,bBuffer1);
   SetIndexEmptyValue(0,EMPTY_VALUE);
   SetIndexArrow(0,233);
   
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexBuffer(1,sBuffer1);
   SetIndexEmptyValue(1,EMPTY_VALUE);
   SetIndexArrow(1,234);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int  i, limit, counted_bars=IndicatorCounted();

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;

   double cciTrendNow, cciTrendPrevious;
   
 //  static datetime prevtime = 0;
   
 //  if(prevtime == Time[0]) {
 //     return(0);
 //  }
 //    prevtime = Time[0];
 
  for(i=limit;i>=0;i--)
   {
   cciTrendNow      = iCCI(NULL, 0, CCI_Trend, PRICE_TYPICAL, i);
   cciTrendPrevious = iCCI(NULL, 0, CCI_Trend, PRICE_TYPICAL, i+1);
 
   
//---- 
   
  
      if((cciTrendNow < SignalLevel ) && (cciTrendPrevious > SignalLevel))
      
      sBuffer1[i] = High[i]+ 5*Point;    else  sBuffer1[i]=EMPTY_VALUE;
  
     
      
  
      if((cciTrendNow > -SignalLevel) && (cciTrendPrevious < -SignalLevel))
     
       bBuffer1[i] = Low[i]- 5*Point;  else  bBuffer1[i]=EMPTY_VALUE;
     
 
   }
//----
   return(0);
}
//+--------------------------------------------------------------------------------------+

Comments