Download MetaTrader 5
To add comments, please log in or register
Publish your article. Millions of traders are looking for good ideas!
Ulrich
77
Ulrich 2014.04.07 16:00 

Hi,

my ea works like it should but 1 of 100 orders i get Order send failed with error 138

Today i had a sell order this is the code, i even have a second order for the problem.

this is my insurance... but today it does not work.

ticket=OrderSend(Symbol(),OP_SELL,Einsatz*Lot,Bid,100,slk-Psycho-Verschiebung,0,"Baer ",Expert_ID,0,Green);

if(ticket<0)

{

Print("OrderSend failed with error #",GetLastError());

RefreshRates();

ticket=OrderSend(Symbol(),OP_SELL,Einsatz*Lot,Bid,100,slk-Psycho-Verschiebung,0,"Baer ",Expert_ID,0,Green);

return(ticket);

}

return (Lot); 
Alain Verleyen
Moderator
28518
Alain Verleyen 2014.04.07 16:11  

Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.

qjol
3243
qjol 2014.04.07 23:03  
ERR_REQUOTE 138 The requested price has become out of date or bid and ask prices have been mixed up. The data can be refreshed without any delay using the RefreshRates function and make a retry. If the error does not disappear, all attempts to trade must be stopped, the program logic must be changed.


may be you should try to use something like:

while (ticket<0)
   {
   RefreshRates();
   ticket = OrderSend(....);
   }

or maybe something like:

while (true)
   {
   RefreshRates();
   ticket = OrderSend(....);
   if (ticket > -1)
   break;
   }
Ulrich
77
Ulrich 2014.04.08 16:03  
Very good i improve my code ..thx
Simon Gniadkowski
Moderator
17962
Simon Gniadkowski 2014.04.08 22:03  
qjol:
ERR_REQUOTE 138 The requested price has become out of date or bid and ask prices have been mixed up. The data can be refreshed without any delay using the RefreshRates function and make a retry. If the error does not disappear, all attempts to trade must be stopped, the program logic must be changed.


may be you should try to use something like:

or maybe something like:

No, you shouldn't . . what you should do is . . .

The data can be refreshed without any delay using the RefreshRates function and make a retry. If the error does not disappear, all attempts to trade must be stopped, the program logic must be changed.

qjol
3243
qjol 2014.04.08 22:26  
RaptorUK:

No, you shouldn't . . what you should do is . . .


the reason behind my suggestion is because he wrote

AiGelb:


[...]but 1 of 100 orders i get Order send failed with error 138



i realized he uses a broker that intentionally feeds the terminal with a delay
and if i'm not mistaken (and i'm not) this type of brokers are doing it just for a few minutes
mostly when the market makes sharp movements (like NFP...)
Daniel Petrovai
440
Daniel Petrovai 2014.04.10 01:48  
AiGelb:

Hi,

my ea works like it should but 1 of 100 orders i get Order send failed with error 138

Today i had a sell order this is the code, i even have a second order for the problem.

this is my insurance... but today it does not work.


I guess there's nothing you can do about it. It's not the EA request at a wrong price, it's the broker or your internet connection or the markets moving fast.

With 100 points slippage and your request is out of date, makes me wonder how jumpy are the markets you trade or how often your broker updates the price.

"If the requested open price is fully out of date, the error 138 (ERR_REQUOTE) will be generated independently on the slippage parameter. If the requested price is out of date, but present in the thread, the order will be opened at the current price and only if the current price lies within the range of price+-slippage."

Your code says Sell at Bid and the server says the bid you know is far away now, let me update you on that (requote).

I fail to see anything that point to your EA.

/
To add comments, please log in or register