How to handle broker "requotes"

 

Hi Guys,

This is my attempt at trying to handle broker requotes. Recently my EA took 2 buy trades almost at the same time. I'm guessing that while the server was thinking about accepting the first request the 2nd loop kicked in and made a 2nd request - result was they both got accepted!!

Has anybody got more elegant code to handle requotes?

while(tries < 3)
{
if(OrderSend(Symbol(),OP_BUY, lots, Ask,3, Bid - stop * pointvalue, 0,"EA",0,0,Blue) > 0)
{
tries = 3;
continue;
}
tries++;
Sleep(500);
RefreshRates();
}

thanks

 

I use ordersendreliable to capture and handle requotes. Never had a double-order while using it.

https://c.mql5.com/mql4/forum/2010/10/OrderReliable_2010.10.12.mqh

 
sd59:

This is my attempt at trying to handle broker requotes. Recently my EA took 2 buy trades almost at the same time. I'm guessing that while the server was thinking about accepting the first request the 2nd loop kicked in and made a 2nd request - result was they both got accepted!!

If orderSend returns positive the order was excepted and the loop exits. The orderSend doesn't return untill the server finishes. The problem is elsewhere (double triggering)
 
1005phillip:

I use ordersendreliable to capture and handle requotes. Never had a double-order while using it.

https://c.mql5.com/mql4/forum/2010/10/OrderReliable_2010.10.12.mqh


thanks 1005phillip - i suspect as WHRoeder says i may have another problem...you know one of those that has just suddenly appeared after changing nothing!

The OrderReliable() looks very useful. Do you literally use this form as a direct replacment for Ordersend(), Ordermodify() & Ordeclose()?

So all i need to do is include the file at the top of the EA and change the commands?

thanks

 
WHRoeder:
If orderSend returns positive the order was excepted and the loop exits. The orderSend doesn't return untill the server finishes. The problem is elsewhere (double triggering)


Hi WHRoeder,

Just to be clear when adding code i should click SRC first - then cut and paste from my code to the box - then insert?

thanks

 
sd59:


thanks 1005phillip - i suspect as WHRoeder says i may have another problem...you know one of those that has just suddenly appeared after changing nothing!

The OrderReliable() looks very useful. Do you literally use this form as a direct replacment for Ordersend(), Ordermodify() & Ordeclose()?

So all i need to do is include the file at the top of the EA and change the commands?

thanks


Pretty much. Include the file at the top of the EA and change your existing commands - ordersend(xyz) -> ordersendreliable(xyz)

When I first implemented it, years ago now, I literally did nothing more than adding the include line at the top and then did a "find and replace" for "OrderSend" with "OrderSendReliable"...and so on for OrderClose and OrderModify.

It makes all the difference on live accounts...makes no difference on demo accounts of course because the brokers don't really synthesize reality on their demo servers when it comes to order management. They replicate market pricing pretty well, but not so much all the other stuff that matters. That is where the OrderReliable include file comes in.
 
1005phillip:

Pretty much. Include the file at the top of the EA and change your existing commands - ordersend(xyz) -> ordersendreliable(xyz)

When I first implemented it, years ago now, I literally did nothing more than adding the include line at the top and then did a "find and replace" for "OrderSend" with "OrderSendReliable"...and so on for OrderClose and OrderModify.

It makes all the difference on live accounts...makes no difference on demo accounts of course because the brokers don't really synthesize reality on their demo servers when it comes to order management. They replicate market pricing pretty well, but not so much all the other stuff that matters. That is where the OrderReliable include file comes in.


thanks again - one last question...it states in the include file that it is under development and of course it does not appear in the intellisense list - nevertheless you think it is reliable code?

Why has it not been implemented in the intellisense list if it is quite old now?

 

No idea, I've used it for years, the one I linked/uploaded is actually modified by me in a few ways but I've never bothered to update the credits. Naturally it is a "use at your own risk" code...its free, right? You get what you pay for when you get something for free :)

 
1005phillip:

Pretty much. Include the file at the top of the EA and change your existing commands - ordersend(xyz) -> ordersendreliable(xyz)

When I first implemented it, years ago now, I literally did nothing more than adding the include line at the top and then did a "find and replace" for "OrderSend" with "OrderSendReliable"...and so on for OrderClose and OrderModify.

It makes all the difference on live accounts...makes no difference on demo accounts of course because the brokers don't really synthesize reality on their demo servers when it comes to order management. They replicate market pricing pretty well, but not so much all the other stuff that matters. That is where the OrderReliable include file comes in.

is this thread still active? is anyone still listening?

This is exactly what I need, but being a novice programer, I need more step by step.

I can do the "find and replace", but what I need is exactly what to do with the "#include " at the top.

I clicked on the link, and downloaded the file from https://c.mql5.com/mql4/forum/2010/10/OrderReliable_2010.10.12.mqh

which produced the download file "OrderReliable_2010.10.12.mqh".

Now what? Where do I put this file?

how exactly does the include statement look?

Sorry to be so naive... your help is greatly appreciated.

 

You would place the file in your MT4\experts\include folder.

At the top of your EA code you will want:

#include <OrderReliable_2010.10.12.mqh>
 

Here's a newer version that I modified to dynamically identify when a broker is using ECN bridge that requires the order be placed without specifying the SL/TP and then be modified to include the SL/TP.

Just use Ordersendreliable with SL/TP specified, regardless whether or not the broker is known to use ECN bridge.

If the broker rejects the order for the bridge reason then that fact/event is captured, the order is then properly placed and the SL/TP are set accordingly, all automatically for your EA.

Reason: