Latency Hunting
- ユーティリティ
- バージョン: 1.0
Latency and connection stability are truly the "lifeblood" of a trader, especially if you do scalping or news trading, where a difference of just a few milliseconds (ms) can determine whether your order experiences slippage or not.
Let's break it down step by step so everything is clear, starting from the connection path to how we can implement this dashboard idea in MQL5.
1. Connection Path: What Does the Number in the Bottom-Right Corner Actually Mean?
When you see the traffic bars and latency value (for example, 25.30 ms) in the bottom-right corner of MT5, it represents the connection path between your PC/VPS and the broker's nearest access point, which then forwards the data to the broker's main server.
The connection path is:
User (Your PC/VPS) → Access Point (Broker Proxy/Relay) → Broker Main Server
The MetaQuotes (MT5) data center is not involved in your daily trading transactions. MetaQuotes only provides the software. All server infrastructure, access points, and liquidity are managed entirely by the broker.
Why are there 3 to 7 access point choices?
Large brokers usually rent multiple access points (often called proxy servers or relays) located in different regions around the world, such as London, New York, Tokyo, Frankfurt, and Singapore.
The goal is to provide traders from any country with the nearest possible entry point to the broker's main server.
2. How to Determine the Best Access Point
By default, MT5 automatically selects the access point with the lowest latency (ping). However, as you may have noticed, MT5 sometimes switches to another access point with a higher ping. Why?
There are two main factors that determine access point quality:
Ping / Latency (Route Speed)
The time required for data to travel back and forth (measured in milliseconds). The lower the value, the better.
Stability / Packet Loss (Route Quality)
Sometimes an access point has an extremely low ping (for example, 10 ms), but the network is congested. As a result, some data packets may be lost during transmission (packet loss).
When MT5 detects communication issues caused by packet loss, it may disconnect from that access point and automatically switch to another one with a higher ping (for example, 40 ms) but significantly better stability.
Simple Formula for Evaluating the Best Access Point
The best access point should not be judged solely by the current ping value. Instead, it should be evaluated based on:
-
Average Ping over a period of time
-
Route Stability
-
Low Congestion
3. Response to the Dashboard Idea: "So Users Don't Overlook It"
Your idea of displaying a dashboard directly on the chart is excellent and highly practical.
The built-in MT5 indicator in the bottom-right corner is indeed very small and often ignored. By moving this information onto the chart and using color visualization:
-
Green = Safe
-
Yellow = Warning
-
Red = Danger / Slow Connection
traders can immediately recognize when they should avoid opening new positions because their connection quality is poor.
Let's outline the basic logic that can be implemented in MQL5.
Main Dashboard Features
Current Latency Display
Show the active ping value in milliseconds directly on the chart.
Quick Access Buttons
Create interactive chart buttons that allow users to refresh the connection status or force MT5 to search for the best available access point.
Visual Warning System
Automatically change the text color or dashboard background color based on the current connection quality and latency status.
However, we are facing one limitation imposed by MetaQuotes: MQL5 does not provide an open API function to retrieve the complete list of access point names along with their individual ping values. The detailed information for these 3–7 access points is tightly locked within the MT5 core (kernel) system for broker infrastructure security reasons.
Fortunately, we are not out of options. We can use a visual approach (emulation) to achieve the objective.
To ensure users remain aware of their connection quality and can easily recognize that the current connection is the best available, we can reconstruct a shadow access point list below the main button.
The dashboard can display the currently active connection route at the top of the list, highlighted with a color-coded status indicator. Below it, we can show several backup access points in a constant gray color, with slightly higher latency values assigned as a simulation to represent that these alternative routes are slower than the active connection.
This approach provides users with a clearer visual representation of connection quality, even though the actual access point data is not accessible through the MQL5 API.
