M & W pattern recognizer

 

Hello guys.

Im trying to build an alert system for M and W patterns...

My code surley looks messy, but im trying :)

Ive come to the point where the indicator plots 2 arrows on the zigzag tops/bottoms.

I want it to plot when the second M/W leg is higher/lower than the first one.

But, here comes my problem.... I want the alert to come when price crosses EMA13....

Im attaching printscreens of one live example, and one example where arrows already been plotted.


Here is the code i have so far:


   int ZigZagHighCount=0, ZigZagLowCount=0, ZigZagCount=0;
   int ZigZagShift = 0;
   double ZZHigh[2],ZZLow[2];
   datetime ZZHTime[2],ZZLTime[2];
   while(ZigZagHighCount < 3 && ZigZagLowCount < 3)
   {
      double ZigZag=iCustom(NULL,0,"ZigZag",9,5,3,0,ZigZagShift);
      if((ZigZag == High[ZigZagShift] || ZigZag == Low[ZigZagShift]) && ZigZagCount==0){ZigZagCount++; ZigZagShift++;}
      else 
      {
         if(ZigZag == High[ZigZagShift])
         {
            ZZHigh[ZigZagHighCount]=ZigZag;
            ZZHTime[ZigZagHighCount]=iTime(NULL,0,ZigZagShift);
            ZigZagHighCount++; ZigZagCount++;
         }
         //do reverse for short
         if(ZigZag == Low[ZigZagShift])
         {
            ZZLow[ZigZagLowCount]=ZigZag;
            ZZLTime[ZigZagHighCount]=iTime(NULL,0,ZigZagShift);
            ZigZagLowCount++; ZigZagCount++;      
         }
      }
      ZigZagShift++;
   } 
   
   if(ZZHigh[1] > Y_HIGH[0] && ZZHigh[0] > Y_HIGH[0] && ZZHigh[0] > ZZHigh[1]) {
      ObjectCreate("arrowDN",OBJ_ARROW,0,ZZHTime[1],ZZHigh[1],ZZHTime[0],ZZHigh[0]);          // Create an arrow
      ObjectSetInteger(0,"arrowDN",OBJPROP_ARROWCODE,234);    // Set the arrow code
      ObjectSetInteger(0,"arrowDN",OBJPROP_TIME,ZZHTime[1]);        // Set time
      ObjectSetDouble(0,"arrowDN",OBJPROP_PRICE,ZZHigh[1]);// Set price
      ChartRedraw(0); 
      
      ObjectCreate("arrowDN2",OBJ_ARROW,0,ZZHTime[1],ZZHigh[1],ZZHTime[0],ZZHigh[0]);          // Create an arrow
      ObjectSetInteger(0,"arrowDN2",OBJPROP_ARROWCODE,234);    // Set the arrow code
      ObjectSetInteger(0,"arrowDN2",OBJPROP_TIME,ZZHTime[0]);        // Set time
      ObjectSetDouble(0,"arrowDN2",OBJPROP_PRICE,ZZHigh[0]);// Set price
      ChartRedraw(0); 
      
     }
   
      if(ZZLow[1] < Y_LOW[0] && ZZLow[0] < Y_LOW[0] && ZZLow[0] < ZZLow[1]) {
      ObjectCreate("arrowUP",OBJ_ARROW,0,ZZHTime[1],ZZHigh[1],ZZHTime[0],ZZHigh[0]);          // Create an arrow
      ObjectSetInteger(0,"arrowUP",OBJPROP_ARROWCODE,233);    // Set the arrow code
      ObjectSetInteger(0,"arrowUP",OBJPROP_TIME,ZZLTime[1]);        // Set time
      ObjectSetDouble(0,"arrowUP",OBJPROP_PRICE,ZZLow[1]);// Set price
      ChartRedraw(0); 
      
      ObjectCreate("arrowUP2",OBJ_ARROW,0,ZZHTime[1],ZZHigh[1],ZZHTime[0],ZZHigh[0]);          // Create an arrow
      ObjectSetInteger(0,"arrowUP2",OBJPROP_ARROWCODE,233);    // Set the arrow code
      ObjectSetInteger(0,"arrowUP2",OBJPROP_TIME,ZZLTime[0]);        // Set time
      ObjectSetDouble(0,"arrowUP2",OBJPROP_PRICE,ZZLow[0]);// Set price
      ChartRedraw(0); 
      
     }


Im stuck from here... so i really appreciate all help i can get!

Thanks you

Reason: