Download MetaTrader 5

Latency check on Ea running on vps

To add comments, please log in or register
Join MQL5 Cloud Network. Start earning money!
simoncs
321
simoncs 2014.04.09 23:22 
Hi
I am running an ea on a vps. The trace from vps to the broker reports about 70ms.

I included the below code into my EA to check latency and slippage. The first time the ea traded it reported 375ms, which is about what I was getting at home, about 15000 km away from the brokers server.

Could this code not be reflecting what I am trying to check, or could it be an issue with the vps? I have spoken to the vps provider and they can't see any issue.
int OpenSellOrder(double LotSize,double SL,double TP,string commt="Sell Order")
{
while(IsTradeContextBusy()) Sleep(10);
double requestedPrice = MarketInfo(Symbol(), MODE_BID);
int orderStartPointInTime = GetTickCount();
RefreshRates();
// Place Buy Order
SellTicket=OrderSend(Symbol(),OP_SELL,LotSize,requestedPrice,Slippage*pips2points,(SL()+pips2dbl+Spread()),(TP()-pips2dbl-Spread()),commt+MagicNumber,MagicNumber,0,Red);
OrderOpened=true;
int orderExecutionDurationInMs = GetTickCount() - orderStartPointInTime;
if (OrderSelect(BuyTicket, SELECT_BY_TICKET)) {
double slippageIncurred = requestedPrice - OrderOpenPrice();

Print(StringConcatenate("Execution duration = ", orderExecutionDurationInMs, "ms,Slippage = ", DoubleToStr(slippageIncurred * 10000, 1), "pips"));
} 
Alain Verleyen
Moderator
30743
Alain Verleyen 2014.04.10 00:01  

Hello,

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



simoncs
321
simoncs 2014.04.10 01:00  
angevoyageur:

Hello,

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

sorry - originally posted via my phone, which doesn't have this option
Alain Verleyen
Moderator
30743
Alain Verleyen 2014.04.10 08:15  
simoncs:
Hi
I am running an ea on a vps. The trace from vps to the broker reports about 70ms.

I included the below code into my EA to check latency and slippage. The first time the ea traded it reported 375ms, which is about what I was getting at home, about 15000 km away from the brokers server.

Could this code not be reflecting what I am trying to check, or could it be an issue with the vps? I have spoken to the vps provider and they can't see any issue.
Are you sure RefreshRates() is needed ? If yes, you have to execute it before your start counter. Not sure what can be the impact though.
simoncs
321
simoncs 2014.04.10 11:31  
angevoyageur:
Are you sure RefreshRates() is needed ? If yes, you have to execute it before your start counter. Not sure what can be the impact though.


Possibly not. it was here before i added the latency check code. I will comment it out and see if that makes a difference.
eric
99
eric 2014.04.11 14:24  

I use the code below, but I think the speed is the time for order to go, to be filled and to come back from broker

That's why I get between 300 and 3000ms results. My server is only at 1ms from broker server.

tick=GetTickCount();
ticket=OrderSend(Symbol(),OP_SELL,lotshort,BID,Slippage,stop,takeprofit,EANAME,MAGIC,0,Red);
speed=GetTickCount()-tick;
simoncs
321
simoncs 2014.04.11 21:23  
kissandfly:

I use the code below, but I think the speed is the time for order to go, to be filled and to come back from broker

That's why I get between 300 and 3000ms results. My server is only at 1ms from broker server.


interesting, thanks.

my concern was also that i was getting the same times from home. If what you say is correct, then it almost looks like it vps has less impact from a slippage point of view, and is more to do with the brokers processing time.

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.04.12 01:29  
Yes. It is brokers processing speed. If you don't notice, try doing trade 8 hours apart. You will see there are trades that opened real fast while there might be times when trades opened after quite some time.
To add comments, please log in or register