Help

 

Hi,


I'm new to MQL4 and am trying to learn.  I need help trying to setup a basic EA.  Keep in mind I am doing this one so I can learn how and not necessarily because it will be profitable.  I want to set up an EA that opens two trades simultaneously, one buy and one sell and as soon as both trades close I want it to immediately execute another buy and another sell.  This is the code that I have so far:

void OnTick()
  {
   static int  ticket1= 0;
   static int ticket2 = 0;
   static bool trade=True;

   if(trade==True)
     {

      ticket1 = OrderSend(***);
      ticket2 = OrderSend(***);
      trade=False;

     }
   else if(trade==False)
     {
      if(ticket1<0 && ticket2<0)
        {
         trade=True;
        }

     }
  }

When I do this it will open the trade in the first if statement.  Those two trades will then close out but I cannot get it to enter into trades afterwords.  After the trades close the ticket1 and ticket2 are set back to -1, I verified this with an Alert command.  What do I do so this will work?


Thanks in advance

 

Please use the </> button to insert your above code.


 
if(ticket1<=0 && ticket2<=0)
 
jsavage6:

Hi,


I'm new to MQL4 and am trying to learn.  I need help trying to setup a basic EA.  Keep in mind I am doing this one so I can learn how and not necessarily because it will be profitable.  I want to set up an EA that opens two trades simultaneously, one buy and one sell and as soon as both trades close I want it to immediately execute another buy and another sell.  This is the code that I have so far:

When I do this it will open the trade in the first if statement.  Those two trades will then close out but I cannot get it to enter into trades afterwords.  After the trades close the ticket1 and ticket2 are set back to -1, I verified this with an Alert command.  What do I do so this will work?

Show the code that resets the values.

Reason: