Download MetaTrader 5

Sleep() ?

To add comments, please log in or register
maryfernanda1
15
maryfernanda1  

Hiii gus, My name is Mary and I'm loving develop MQL.
I'm a big doubt. I'm programming that after the first order, wait 10 seconds

 

if(OrdersTotal()==0)
      {
         ticket   =      OrderSend(Symbol(),OP_BUY,Lots1,Ask,0,0,0,NULL,NULL,0,Blue);
         Sleep(10000);
         ticket   =      OrderSend(Symbol(),OP_BUY,Lots1,Ask,0,0,0,NULL,NULL,0,Red);
      }

 It doesn't work. What my error?

thank you. The forum is perfect to study. =**** 

Keith Watford
Moderator
10369
Keith Watford  

Maybe slippage at 0 causes a problem.

After 10 seconds, Ask may no longer be up to date, use RefreshRates().

maryfernanda1
15
maryfernanda1  
Hello Gumrai. thanks for info slippage.

if(OrdersTotal()==0)
      {
         ticket   =      OrderSend(Symbol(),OP_BUY,Lots1,Ask,0,0,0,NULL,NULL,0,Blue);
         Sleep(10000);
         RefreshRates();


         ticket   =      OrderSend(Symbol(),OP_BUY,Lots1,Ask,0,0,0,NULL,NULL,0,Red);
      }
correct?
Keith Watford
Moderator
10369
Keith Watford  
You haven't  changed anything
maryfernanda1
15
maryfernanda1  
I am beginner please help me =(
Carl Schreiber
6989
Carl Schreiber  
maryfernanda1:

Hiii gus, My name is Mary and I'm loving develop MQL.
I'm a big doubt. I'm programming that after the first order, wait 10 seconds

 

 It doesn't work. What my error?

thank you. The forum is perfect to study. =**** 

What does not work?

have you checked the errors?

Keith Watford
Moderator
10369
Keith Watford  
   if(OrdersTotal()==0)
     {
      ticket   =      OrderSend(Symbol(),OP_BUY,Lots1,Ask,10,0,0,NULL,0,0,Blue);
      if(ticket==-1)
         Print("Error Placing Buy Order, Error code ",GetLastError());
      Sleep(10000);
      RefreshRates();
      ticket   =      OrderSend(Symbol(),OP_BUY,Lots1,Ask,10,0,0,NULL,0,0,Red);
      if(ticket==-1)
         Print("Error Placing Buy Order, Error code ",GetLastError());
     }

Is Lots1 a valid lotsize?

Tecuciztecatl
70
Tecuciztecatl  
ResetLastError();
ticket=-1;
while (ticket<0 && !IsStopped())
   {
   ticket=OrderSend(Symbol(),OP_BUY,Lots1,Ask,10,0,0,NULL,0,0,Blue);
   
   // break if order send
   if (ticket>0) {break;}                                                  
   
   // else send again 
      Print("Error Placing Buy Order, Error code ",GetLastError());
      Sleep(100);
      RefreshRates();
      continue;
   }
and Lots must be normalized (NormalizeDouble)
whroeder1
15331
whroeder1  
ticket=OrderSend(Symbol(),OP_BUY,Lots1,Ask,10,0,0,NULL,NULL,0,Blue);
NULL is not a valid int for magic.
Tecuciztecatl
70
Tecuciztecatl  
Yes, sorry, I copied it from the first message.
To add comments, please log in or register