Multiple EA's on MT4

 

Hi,

I have an EA for each Pair that i trade - all of these EA's contain this code:

   int order_type;
   
   while(deleted == 0)
   {
      //Ticket_1 closes ticket 2, BUY_LIMIT = 2, SELL_LIMIT =3, BUY=0, SELL=1

      if (OrderSelect (ticket_b1,SELECT_BY_TICKET)==True)
      {
         order_type = OrderType();
         Print ("-------------------------Ticketb1: ", order_type);
   
         if (order_type == 1||0)
         {
            OrderDelete (ticket_b2);
            ObjectCreate("Deleted",OBJ_LABEL,0,0,0,0,0);
            ObjectSet ("Deleted",OBJPROP_XDISTANCE,20);
            ObjectSet ("Deleted", OBJPROP_YDISTANCE,80);
            ObjectSetText("Deleted","Pending Deleted",10,"Tahoma", Black);
            deleted = 1;
         }
      }

      //=================================================   
   
      //Ticket_2 closes ticket 1
      if (OrderSelect (ticket_b2,SELECT_BY_TICKET)==True)
      {
         order_type = OrderType();
         Print ("-------------------------Ticketb2: ", order_type);
   
         if (order_type == 1||0)
         {
            OrderDelete (ticket_b1);
            ObjectCreate("Deleted",OBJ_LABEL,0,0,0,0,0);
            ObjectSet ("Deleted",OBJPROP_XDISTANCE,20);
            ObjectSet ("Deleted", OBJPROP_YDISTANCE,80);
            ObjectSetText("Deleted","Pending Deleted",10,"Tahoma", Black);
            deleted = 1;
         }
      }

The order_type is 1 or 0 if one of the two orders was triggered, but the OrderDelete doesn't work.

Does anybody know what the problem is?

Thank you all in advance!

Kind regards,

John

 
  1.   if (order_type == 1||0)
    false = 0, true = nonzero, therefor you have
      if (order_type == 1||false)
    which means it only executes on order type 1. Use:
      if (order_type == OP_SELL || order_type == OP_BUY)

  2. order_type is 1 or 0 if one of the two orders was triggered, but the OrderDelete doesn't work.
    You can't delete open orders only pending orders.
  3. What are Function return values ? How do I use them ? - MQL4 forum



 

Hi WHRoeder,

thank you very much for your fast and detailed answer!

I will give it a try now, but I am sure that it will work as you mentioned it above.

Edit: Works, thx again!

Kind regards,

John

Reason: