Sleep() ?

Back to topics list To post a new topic, please log in or register
avatar
3
maryfernanda1 2016.03.31 16:13
 

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. =**** 

avatar
Moderator
3408
GumRai 2016.03.31 23:03 #
 

Maybe slippage at 0 causes a problem.

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

avatar
3
maryfernanda1 2016.04.01 01:51 #
 
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?
avatar
Moderator
3408
GumRai 2016.04.01 01:56 #
 
You haven't  changed anything
avatar
3
maryfernanda1 2016.04.03 22:03 #
 
I am beginner please help me =(
avatar
2017
gooly 2016.04.03 22:07 #
 
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?

avatar
Moderator
3408
GumRai 2016.04.04 02:59 #
 
   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?

avatar
69
Tecuciztecatl 2016.04.05 21:07 #
 
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)
avatar
12988
WHRoeder 2016.04.05 21:43 #
 
ticket=OrderSend(Symbol(),OP_BUY,Lots1,Ask,10,0,0,NULL,NULL,0,Blue);
NULL is not a valid int for magic.
avatar
69
Tecuciztecatl 2016.04.05 22:05 #
 
Yes, sorry, I copied it from the first message.
Back to topics list  

To add comments, please log in or register