Download MetaTrader 5
To add comments, please log in or register
Do you need a trading robot? Orderit via Freelance service!
maryfernanda1
15
maryfernanda1 2016.03.31 14: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. =**** 

Keith Watford
Moderator
7887
Keith Watford 2016.03.31 21:03  

Maybe slippage at 0 causes a problem.

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

maryfernanda1
15
maryfernanda1 2016.03.31 23: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?
Keith Watford
Moderator
7887
Keith Watford 2016.03.31 23:56  
You haven't  changed anything
maryfernanda1
15
maryfernanda1 2016.04.03 20:03  
I am beginner please help me =(
Carl Schreiber
5934
Carl Schreiber 2016.04.03 20: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?

Keith Watford
Moderator
7887
Keith Watford 2016.04.04 00: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?

Tecuciztecatl
70
Tecuciztecatl 2016.04.05 19: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)
whroeder1
13596
whroeder1 2016.04.05 19:43  
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 2016.04.05 20:05  
Yes, sorry, I copied it from the first message.
/
To add comments, please log in or register