1

I am creating EA on MT4 and want to retrieve the latency value ( e.g. 123 ms ) by MQL4 code.

Is it do-able?

I can't find this feature in MQL4 reference.

user3666197
  • 1
  • 6
  • 50
  • 92
tensor5375
  • 126
  • 1
  • 9
  • Are you referring to ping latency? or Order execution latency? The value is not directly available in MQL4, but you can produce them depending on which latency you are referring to. It is important to note that a ping-latency of 60ms could still have an execution-latency of 3000ms... basically, the broker is slow (or delay) the execution of your order (causing slippage). – jlee88my Jun 04 '15 at 06:28
  • I mean ping latency. – tensor5375 Jun 05 '15 at 21:43
  • Can I ask how "critical" is this info is to you? It can be done, but is very difficult. Involving several off-MT4 processes. 1. Identify your MT4 Windows System ID, 2. Map it to the IP connection it is connecting to, 3. Issue an ICMP ping to it, and 4. Get the response time. ::: All of it is off-MT4 and rather complicated. If it is not absolutely critical, would rather not spend the time on it. But if it is very critical and no work around, I can give it a try. Let me know. – jlee88my Jun 06 '15 at 06:07

1 Answers1

0

Short version

Yes, it is do-able

Long version

MQL4/MQL5 does not give you a direct tool to get either an End-to-End socket-based communication/transport latency or an End-to-End eXecute-Trading-Operation client/server transaction latency.

Nevertheless, you may get both latency envelopes indirectly.

visualised latency envelopes

user3666197
  • 1
  • 6
  • 50
  • 92
  • what is this? will i know the answer by looking for PROFIT_ENGINE? – tensor5375 Apr 25 '15 at 00:00
  • @tensor5375 Speaking about latency, the graphs depict [msec] gathered data for transport and latency envelopes respective broker servers deliver towards MT4 Terminal programme. You may have noticed, that some events appear with less than tens of milliseconds, thus one's end-to-end transport latency may "**mask**" and hide events, that decide about a due trading ( responsive ) policy deployment and the MQL4 code remains "**blind**" and non-responding to the Market Event. **Collecting & evaluation of both transport & XTO-transaction latencies is very important** – user3666197 Apr 25 '15 at 09:09
  • More information on this would be great. – BioBier Feb 07 '23 at 12:14
  • @BioBier was not able to decode what information you try to seek. Feel free to clarify the focus of interest. – user3666197 May 16 '23 at 21:57
  • @user3666197 I meant info on how this "Collecting & evaluation of both transport & XTO-transaction latencies" can be done code wise. The posted indicator does not have any source file provide. – BioBier May 18 '23 at 05:45
  • @BioBier Well, XTO-transactions was recorded in an MQL4 code in a bit simpler manner, recording end-to-end latencies down to a [ms] resolution from `GetTickCount()` and more recently, after MQL4-language revision & extension, down to a [us] resolution from `GetMicrosecondCount()`. The transport latency envelope data code was harder to craft, and uses a minimum latency single end recording of the flow of events. Given one aims at going into using safe & professional trading infrastructure, these sets of live-telemetry data are a must-have intelligence before going into any real trading strategy – user3666197 May 18 '23 at 09:19