XO_ALERT_cci_cross

Download script
Author: Kalenzo
XO_ALERT_cci_cross

This script is an automated trading tool designed to identify specific momentum shifts by analyzing multiple timeframes simultaneously. It functions as a multi-layered filtering system that looks for "confluence"—a situation where several different market conditions align to suggest a high-probability trade.

Multi-Timeframe Analysis

The core logic of the script relies on monitoring four distinct timeframes: 60 minutes, 30 minutes, 15 minutes, and 5 minutes. Instead of looking at these in isolation, the script gathers data from an external technical indicator across all four periods to determine the prevailing market trend.

The "Signal" Logic

The tool identifies potential trading opportunities based on a specific transition of signals:

  • Long Opportunities (Buy): The script looks for a moment where all four timeframes (60, 30, 15, and 5 minutes) simultaneously display a positive ("green") signal, while the previous state was not fully aligned.
  • Short Opportunities (Sell): Conversely, it looks for a moment where all four timeframes simultaneously display a negative ("red") signal, triggered by a transition from a non-aligned previous state.

By requiring all four timeframes to agree, the script aims to filter out "noise" and ensure that a trade is only signaled when the short-term momentum is in harmony with the longer-term trend.

Secondary Confirmation (CCI Filter)

Once a primary direction (Long or Short) has been established by the multi-timeframe analysis, the script applies a second layer of verification using the Commodity Channel Index (CCI). This acts as a "trigger" to confirm the entry:

  • For Longs: It waits for the CCI value to cross from a negative to a positive state.
  • For Shorts: It waits for the CCI value to cross from a positive to a negative state.

Execution Flow

  1. Scanning: The script constantly monitors the interaction between the various timeframe signals.
  2. Directional Identification: It determines if the market is currently trending toward a "Long" or "Short" bias based on the multi-timeframe alignment.
  3. Alerting: Only when both the multi-timeframe alignment and the specific CCI crossover occur does the script trigger a notification to the user.

In summary, this script acts as a sophisticated filter that requires broad market agreement across multiple time horizons before confirming a trade signal with a technical momentum oscillator.

Indicators Used
Commodity channel index
Miscellaneous
It issuies visual alerts to the screen
11 Views
0 Downloads
0 Favorites
XO_ALERT_cci_cross
//+------------------------------------------------------------------+
//|                                                    XO_EA_FTP.mq4 |
//|                                                          Kalenzo |
//|                                      bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"
#property indicator_chart_window

extern int barToCheck = 1;
extern int cci = 39;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
  
  
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start(){
   static int dir = 0;
   static int mode = 0;

//----
   
   
   if(Bars>mode){
      double xo60g = iCustom(Symbol(),0,"ZZ  MTF  XO  A",60,5,0,barToCheck);//green 60
      double xo60r = iCustom(Symbol(),0,"ZZ  MTF  XO  A",60,5,1,barToCheck);//red 60

      double xo30g = iCustom(Symbol(),0,"ZZ  MTF  XO  A",30,6,0,barToCheck);//green 30
      double xo30r = iCustom(Symbol(),0,"ZZ  MTF  XO  A",30,6,1,barToCheck);//red 30

      double xo15g = iCustom(Symbol(),0,"ZZ  MTF  XO  A",15,5,0,barToCheck);//green 15
      double xo15r = iCustom(Symbol(),0,"ZZ  MTF  XO  A",15,5,1,barToCheck);//red 15

      double xo5g = iCustom(Symbol(),0,"ZZ  MTF  XO  A",5,5,0,barToCheck);//green 5
      double xo5r = iCustom(Symbol(),0,"ZZ  MTF  XO  A",5,5,1,barToCheck);//red 5

      double pxo60g = iCustom(Symbol(),0,"ZZ  MTF  XO  A",60,5,0,barToCheck+1);//green 60
      double pxo60r = iCustom(Symbol(),0,"ZZ  MTF  XO  A",60,5,1,barToCheck+1);//red 60

      double pxo30g = iCustom(Symbol(),0,"ZZ  MTF  XO  A",30,6,0,barToCheck+1);//green 30
      double pxo30r = iCustom(Symbol(),0,"ZZ  MTF  XO  A",30,6,1,barToCheck+1);//red 30

      double pxo15g = iCustom(Symbol(),0,"ZZ  MTF  XO  A",15,5,0,barToCheck+1);//green 15
      double pxo15r = iCustom(Symbol(),0,"ZZ  MTF  XO  A",15,5,1,barToCheck+1);//red 15

      double pxo5g = iCustom(Symbol(),0,"ZZ  MTF  XO  A",5,5,0,barToCheck+1);//green 5
      double pxo5r = iCustom(Symbol(),0,"ZZ  MTF  XO  A",5,5,1,barToCheck+1);//red 5

   
    
   
      //green open signal
      if(xo60g != 0 && xo30g != 0 && xo15g != 0 && xo5g != 0 && (pxo60g == 0 || pxo30g == 0 || pxo15g == 0 || pxo5g == 0) ){
         //Alert(Symbol()+" "+Period()+" XO Long ",Bid); 
         mode = Bars;
         dir = 1;
         }//red open signal
      else if(xo60r != 0 && xo30r != 0 && xo15r != 0 && xo5r != 0 && (pxo60r == 0 || pxo30r == 0 || pxo15r == 0 || pxo5r == 0) ){
         //Alert(Symbol()+" "+Period()+" XO Short ",Bid); 
         mode = Bars;
         dir = -1;
         }
      }   
   if(dir!=0){
      static int ltime = 0;
      if(ltime!=Bars){
         double cci0 = iCCI(NULL,0,cci,PRICE_CLOSE,barToCheck);
         double cci1 = iCCI(NULL,0,cci,PRICE_CLOSE,barToCheck+1);
         if(dir==1 && cci0>0 && cci1<0){
            ltime=Bars;
           Alert(Symbol()+" "+Period()+" XO Long ",Bid); 
            }
         else if(dir==-1 && cci0<0 && cci1>0){
            ltime=Bars;
            Alert(Symbol()+" "+Period()+" XO Short ",Bid); 
            } 
         }
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments