big delay in order execution. Please help!

 

I wrote an EA for MT4 that should open at the same time 3 trades for 3 different pairs.  On demo account, when volatility is high there is a delay of 20 seconds between order open times, same happens for order close (orders should close at the same time)

 

 void ……….()

  {

  SO_EURUSD=OrderSend("EURUSD",OP_SELL,…….,Bid,….,NULL,NULL,NULL,160001,clrRed);

  BO_GBPUSD=OrderSend("GBPUSD",OP_BUY,……,Ask,….,NULL,NULL,NULL,160001,clrNONE);

  BO_EURGBP=OrderSend("EURGBP",OP_BUY,….,Ask,….,NULL,NULL,NULL,160001,clrBlue);

  }

 There are no condutions that should introduce a delay.

Below the result:

131493512

2018.07.06 15:30:30

sell

0.01

eurusd

1.17375

0.00000

0.00000

2018.07.06 15:31:46

1.17354

0.00

0.00

0.00

0.83

131493697

2018.07.06 15:30:50

buy

0.01

gbpusd

1.32444

0.00000

0.00000

2018.07.06 15:31:59

1.32453

0.00

0.00

0.00

0.36

131493814

2018.07.06 15:31:09

buy

0.01

eurgbp

0.88594

0.00000

0.00000

2018.07.06 15:32:15

0.88598

0.00

0.00

0.00

0.21


20 seconds difference, and I can figure why. It happens all the time (of course sometimes are only 1 or 2 seconds difference, but still too much).

 

Has anybody any idea why?

Thank you in advance for your help.

 
  1. Laszlo Hermanovski: volatility is high there is a delay of 20 seconds between order open times
    It can take seconds to open an order. During news, it can takes minutes. Connection problems, more minutes.
    1. You have network delays (usually MS range,) but if you loose connection just before the send, it will take 30+ seconds for the timeout, reconnect, resend.
    2. Then you sit in the server queue, while it processes all older requests. Then it must check your account and free margin and if that passes, the current market value is the price you get. Normally only a fraction of a second, during news releases, this can take minutes and the market can move continuously.
    Live with it, it's your broker's server's queue.

  2. SO_EURUSD=OrderSend("EURUSD",OP_SELL,…….,Bid,….,NULL,NULL,NULL,160001,clrRed);
    
    BO_GBPUSD=OrderSend("GBPUSD",OP_BUY,……,Ask,….,NULL,NULL,NULL,160001,clrNONE);
    
    BO_EURGBP=OrderSend("EURGBP",OP_BUY,….,Ask,….,NULL,NULL,NULL,160001,clrBlue);
    When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor
  3. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.
  4. Bid and Ask are predefined variables for the current chart. You are asking to open a order using bad prices.
  5. Check your return codes for errors, report them and you would know why. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.

 
whroeder1:
  1. It can take seconds to open an order. During news, it can takes minutes. Connection problems, more minutes.
    1. You have network delays (usually MS range,) but if you loose connection just before the send, it will take 30+ seconds for the timeout, reconnect, resend.
    2. Then you sit in the server queue, while it processes all older requests. Then it must check your account and free margin and if that passes, the current market value is the price you get. Normally only a fraction of a second, during news releases, this can take minutes and the market can move continuously.
    Live with it, it's your broker's server's queue.

  2. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor
  3. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.
  4. Bid and Ask are predefined variables for the current chart. You are asking to open a order using bad prices.
  5. Check your return codes for errors, report them and you would know why. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.

Thank you for your detailed answer.