Expert Advsi

 
Trying to make an expert advisor with zigzag indicator but it is not working properly! The code is as follows.
Please let me know if you have alternative solutions in mq4.  


extern int StartHour = 9;
extern double Lots=1;
extern int TakeProfit=40;
extern int StopLoss=40;
input int depth=12;
input int deviation=5;
input int backstep=3;
//+------------------------------------------------------------------+
void OnTick()
  {
 
      
      static int ticket=0;
 
      double zigzag=iCustom(_Symbol,0,"ZigZag",depth,deviation,backstep,0,1);

      double open=iOpen(Symbol(),0,1);

   
                     
                         if(( zigzag>0) && (zigzag<EMPTY_VALUE))
                              {
                                  if(zigzag>open)
                                      {
                                         ticket=OrderSend(Symbol(),OP_SELL, Lots,Bid,10, Ask+StopLoss*Point,Ask-TakeProfit*Point,"Set by System");
                                         if(ticket<0)
                                         {
                                             Alert("Error Sending order!");
                                         }
                                      }
                                  else if (zigzag<open)
                                       {
                                         ticket=OrderSend(Symbol(),OP_BUY, Lots,Ask,10, Bid-StopLoss*Point,Bid+TakeProfit*Point,"Set by System");
                                         if(ticket<0)
                                         {
                                             Alert("Error Sending order!");
                                         }
                                       }
   
  
                     }
}
  


 
Good! Thanks!
 
bdsipon: but it is not working properly!
  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless.

  2.       double zigzag=iCustom(_Symbol,0,"ZigZag",depth,deviation,backstep,0,1);
    ZZ is a repainting indicator. If you may get a signal on bar one, and if the current bar forms a higher high/lower low, then the signal on bar one is gone.