Keep Alive Command Connection

 

Hi,

I'm developing a scalper and low execution latency is very important for me when trade is executed.

The problem is that MT4 has a one TCP/IP connection for price feed, that is always connected.

However the connection to the server for executing BUY/SELL commands is connected on first use bases and disconnects after 30 seconds inactivity.

So If I send BUY command, it takes about 700ms just to establish the TCP/IP connection to the server. This time takes to exchange the SYN TCP/IP packets and establish the SSL protocol.

My solution is to send bogus BUY/SELL commands every 25 seconds, so that the MT4 command connection is not disconnected, but that's not optimal.

So my question is: is there a secret setting to keep alive the connection for more than 30 seconds?

Thanks!

 
robertvo:

[...] My solution is to send bogus BUY/SELL commands every 25 seconds, so that the MT4 command connection is not disconnected, but that's not optimal. [...]

That would probably make your broker block automatic trading on your account (yes, they can do that).

[...] and disconnects after 30 seconds inactivity.

I have never noticed that. You sure u got your facts right?

 
gordon:

That would probably make your broker block automatic trading on your account (yes, they can do that).

I would just try it. If they block the account you can say it was some misconfigured or faulty get-rich-quick-EA that you downloaded from some forum and promise to not use it again. They might give you a second chance if your excuse sounds credible and naive enough.
 
robertvo:

[...]My solution is to send bogus BUY/SELL commands every 25 seconds, so that the MT4 command connection is not disconnected, but that's not optimal.

[...]


i think the damage is more than the benefit u gonna pay every 25 sec. spread for nothing
 
qjol:
i think the damage is more than the benefit u gonna pay every 25 sec. spread for nothing
No. His orders won't get filled because they have invalid stops or an unrealistic price and no slippage. Or he would move a pending buy limit from 0.0001 EURUSD to 0.0002 EURUSD and back.
 

then i think he don't have to worry for blocking the account (& maybe he can just send another code to keep alive the connection like some MarketInfo())

 
qjol:

then i think he don't have to worry for blocking the account (& maybe he can just send another code to keep alive the connection like some MarketInfo())

MaketInfo() does not send or modify orders. It needs no connection to the sever.
 

u know what changing the history, for example from last week to monthly does need the servers connection & no need to worry for account blocking (but involving WIN API)

 
qjol:

u know what changing the history, for example from last week to monthly does need the servers connection

Did you even read the OP's question? If in doubt then just read it again.
 
robertvo:

Hi,

I'm developing a scalper and low execution latency is very important for me when trade is executed.

The problem is that MT4 has a one TCP/IP connection for price feed, that is always connected.

However the connection to the server for executing BUY/SELL commands is connected on first use bases and disconnects after 30 seconds inactivity.

So If I send BUY command, it takes about 700ms just to establish the TCP/IP connection to the server. This time takes to exchange the SYN TCP/IP packets and establish the SSL protocol.

My solution is to send bogus BUY/SELL commands every 25 seconds, so that the MT4 command connection is not disconnected, but that's not optimal.

So my question is: is there a secret setting to keep alive the connection for more than 30 seconds?

Thanks!

May i ask what is your latency to the broker? 700ms for the connection establishment seems to much from my point of view. But i have to admit i have not investigated this.
 

If you dont want to open a bogus order maybe you could send an orderclose every 30 seconds for an order with a ticket number that doesnt exist.

Reason: