Delayed Execution Times above 450 msecs

 

Hello,

I have been suffering from very confusing and late execution times with my EA created with MT4. 

I have a top notch gaming pc with i7, 8GB ram, 128GB SSD etc with fiber cable internet (connected to internet not with wifi in order not to suffer from surrounding routers' signals), there is only MT4 running my single EA 24/5.

And finally, I calculate execution times like:

timerStart=GetTickCount();

OrderSend(...)  or OrderClose(...)

timerFinish=GetTickCount();

That is nothing in between to cause delayed execution times.

This is a dedicated PC running just a single program.

However, I see execution times from 280 msec as min, up to 2130 msec as max and with and average of 670 msec. Even More than 2 seconds! I have usually 80msec connection speed as MT4 reports.

When I need to close, say 10 positions simultaneously, it takes ages to complete!!!

I have tested my EA and seen the subject results with RoboForex Standard Demo-Pro  Account on EURUSD instrument.

This is true with RoboForex only! Before, I had been using another broker and I had execution speeds of 150 msec as min, 280 msec as max and 210 msec as average.

I believe, it should no matter where I am located all over the world but cannot figure out what it might be causing this. Any idea?

Note: Roboforex says, it is either on my hardware, virus software, or poor internet connection or their server being very busy. But whose job is to keep servers not busy and upgrade if their capacity not enough for the traffic load? Also, as I said, I have seen pretty reasonable execution speed times with another broker. Am I wrong to suggest that RoboForex has been exploiting the delayed execution times, even perhaps caused intentionally by themselves.? 

Many thanks in advance to all.

 
egeden1:

Hello,

I have been suffering from very confusing and late execution times with my EA created with MT4. 

I have a top notch gaming pc with i7, 8GB ram, 128GB SSD etc with fiber cable internet (connected to internet not with wifi in order not to suffer from surrounding routers' signals), there is only MT4 running my single EA 24/5.

And finally, I calculate execution times like:

timerStart=GetTickCount();

OrderSend(...)  or OrderClose(...)

timerFinish=GetTickCount();

That is nothing in between to cause delayed execution times.

This is a dedicated PC running just a single program.

However, I see execution times from 280 msec as min, up to 2130 msec as max and with and average of 670 msec. Even More than 2 seconds! I have usually 80msec connection speed as MT4 reports.

When I need to close, say 10 positions simultaneously, it takes ages to complete!!!

I have tested my EA and seen the subject results with [???] Standard Demo-Pro  Account on EURUSD instrument.

This is true with [???] only! Before, I had been using another broker and I had execution speeds of 150 msec as min, 280 msec as max and 210 msec as average.

I believe, it should no matter where I am located all over the world but cannot figure out what it might be causing this. Any idea?

Note: [???] says, it is either on my hardware, virus software, or poor internet connection or their server being very busy. But whose job is to keep servers not busy and upgrade if their capacity not enough for the traffic load? Also, as I said, I have seen pretty reasonable execution speed times with another broker. Am I wrong to suggest that [???] has been exploiting the delayed execution times, even perhaps caused intentionally by themselves.? 

Many thanks in advance to all.

It is against the forum rules to discuss specific brokers! However, that been said, I use that broker also and can say the following that might help you analyse the problem.

I run my EAs on 3rd party VPS setups (not on MQL5 VPS) with much fewer resources than your Super PC and have never had any such problems. I have had the VPSs located in London and in Frankfurt and at both locations the response time was very similar.

I have worked with various strategies including very fast scalpers on real live accounts (not Demo accounts), and cannot complain at all about the speed of Order execution.

However, I don't use "hedging", Grids or Martingales, so I have never used any strategy that requires so many positions be closed simultaneously, so can't comment on any delays in respect to that.

But if you really want to go that path, then you might want to consider using the "CloseBy" method of closing multiples orders because that will remove the dependency of having to close them off very quickly, and allows you to almost instantly freeze the position and then you close each order off at your leisure without worrying about the response time.

PS! This is in regards to both MT4 and MT5 setups (all on real live accounts, not demo). I use both, but most of them are on MT4.

 
Fernando Carreiro:

It is against the forum rules to discuss specific brokers! However, that been said, I use that broker also and can say the following that might help you analyse the problem.

I run my EAs on 3rd party VPS setups (not on MQL5 VPS) with much fewer resources than your Super PC and have never had any such problems. I have had the VPSs located in London and in Frankfurt and at both locations the response time was very similar.

I have worked with various strategies including very fast scalpers on real live accounts (not Demo accounts), and cannot complain at all about the speed of Order execution.

However, I don't use "hedging", Grids or Martingales, so I have never used any strategy that requires so many positions be closed simultaneously, so can't comment on any delays in respect to that.

But if you really want to go that path, then you might want to consider using the "CloseBy" method of closing multiples orders because that will remove the dependency of having to close them off very quickly, and allows you to almost instantly freeze the position and then you close each order off at your leisure without worrying about the response time.

PS! This is in regards to both MT4 and MT5 setups (all on real live accounts, not demo). I use both, but most of them are on MT4.

Thank you Fernando for your prompt and kind reply. 

I am sorry if I have omitted a forum rule by typing the broker name; I just wanted to see if anyone else has the same issues with the subject broker... I got the point on that. 

You are right thinking that I occasionally have more than 10 positions to handle at once. But:

1) I cannot eliminate this strategy at this point and have to use the same algorithm to see where we end up with eventually.

2) I know CloseBy and used it earlier; but, at the moment, it is not suitable for my algo either.

3) I had very same strategy where I recorded very reasonable execution times with my previous broker. I have good reasons and a positive intention to work with the subject broker, kind of, I favor them, (and this was a good thing to say about them, so I have never thought that it would be interpreted in a negative way, hoping that obviously I have been doing something wrong, and the fault is with me, not with them. I am sure they are good brokers, except the issue I have been suffering from) as I want to have several services and bonuses they currently offer.

So, I am happy with the previous one but not with the one I plan to switch to. And I got stuck.

The broker says, it is 150-450 msec, if I remember correctly. Even they don't expect more than 2000 msec execs for just one position closing or opening. 

Am I wrong to think that if someone sends adjacent orders, it is delayed intentionally by the broker not to support that kind of algos? If it is true, this sounds very sad and unfair. 

Thank you again for your guidance.

 
egeden1:

Thank you Fernando for your prompt and kind reply. 

I am sorry if I have omitted a forum rule by typing the broker name; I just wanted to see if anyone else has the same issues with the subject broker... I got the point on that. 

You are right thinking that I occasionally have more than 10 positions to handle at once. But:

1) I cannot eliminate this strategy at this point and have to use the same algorithm to see where we end up with eventually.

2) I know CloseBy and used it earlier; but, at the moment, it is not suitable for my algo either.

3) I had very same strategy where I recorded very reasonable execution times with my previous broker. I have good reasons and a positive intention to work with the subject broker, kind of, I favor them, (and this was a good thing to say about them, so I have never thought that it would be interpreted in a negative way, hoping that obviously I have been doing something wrong, and the fault is with me, not with them. I am sure they are good brokers, except the issue I have been suffering from) as I want to have several services and bonuses they currently offer.

So, I am happy with the previous one but not with the one I plan to switch to. And I got stuck.

The broker says, it is 150-450 msec, if I remember correctly. Even they don't expect more than 2000 msec execs for just one position closing or opening. 

Am I wrong to think that if someone sends adjacent orders, it is delayed intentionally by the broker not to support that kind of algos? If it is true, this sounds very sad and unfair. 

Thank you again for your guidance.

Personally, I don't think that is the case with this broker, as I have never had anything of the sort happen to me, and I am profitable with them.

 

Try getting rid the event handlers especially anything that has priority and you can't control like the ontick/onstart.   i don't know the exact close logic you are using but the problem is very likely mostly mt4 not the internet/brokers. I'd strongly recommend using a while loop not a for loop for critical paths since they are much easier  to control.   



int OnInit()
{
              EventSetMillisecondTimer(1)    // define this so you can finish initialising which is important.
               }
void OnTimer()    
{
EventKillTimer();  
while(1)  // no event handlers 
{


///  put your code here
/// e.g.  outline for while loop

i=0;    

while(i<OrdersTotal()) 
{
 OrderSelect(i,SELECT_BY_POS);
          { 
  if (close conditions)
{   
OrderClose(,,,,,,);
}
                      
            }
      }        
i+=1;        
}  


Add GetMicroSecondCount() at the start to see how you are doing and it will get the local time from the computer but you  should be able to handle 100's orders/heavy array calculations in low double digit micro-seconds with an off the shelf laptop (12-15million calculations per millionth of a second no problem). 

Delete all your logs/stop it from writing them/go to options set max history data all to the minimum. 

This will max all your cpus assuming you are not running it on specialised hardware but it will manage fine - its worth assigning at least first 2 specifically to the job. The fibre optic retail ethernet is good for upload latency in tiny sizes and these have negligible peak throughputs compared to gaming graphics so really shouldn't be an issue. Check the timings to the brokers colocation server its probably  inside a millisecond total round trip, my guess is a lot of  the problem is the mt4 event handling. Good Luck
Reason: