Order Latency Measurement
"How fast does this broker actually execute" is usually answered by impression rather than measurement - a bad fill during a news spike gets remembered, a hundred ordinary fills do not. This script answers it with a real batch of real orders, timed end to end, on the smallest size the symbol allows. Two timings are kept separately rather than combined into one number, because they measure different things. The open leg is timed from the instant the buy request is sent to the instant it returns - the terminal's round trip to the server and back for a new order. The close leg times the same round trip for closing it. A broker can be fast opening and slow closing, or the reverse, and averaging the two together would hide whichever one is worse. This places and closes real orders, and that is exactly what "measuring execution" requires - a script that only simulated a send would be measuring nothing. Two safeguards keep that from being reckless. First, the script checks the account's trade mode before it does anything else and refuses outright on a live account; a benchmarking tool is the wrong place to accept "I meant to switch accounts first" as an excuse. Second, it shows a confirmation dialog stating plainly what is about to happen, including the exact lot size, before sending the first order. Every order the script opens is closed again before the next one is sent, so the batch never accumulates a net position while it runs, and a close that fails is retried on its own with backoff rather than left open when the script moves on. The batch also totals the spread actually paid across every successful round trip, converted to money using the symbol's real tick value and tick size and scaled by the exact lot size traded - never a hardcoded contract size, which is wrong on gold, indices and anything that is not a standard 100,000-unit forex lot. Notes and limitations - Refuses to run on a live account. There is no override input for this by design. - The lot size used is always the symbol's minimum, normalised to its volume step - this measures execution speed, not risk, and the smallest possible size keeps the measurement's own footprint on the account minimal. - Latency figures include the terminal's own round trip to the broker's server and back, not just server-side processing time - that full round trip is what a trader actually experiences, so it is the number reported. - A rejected open still counts towards InpNumberOfTrades; the batch does not send extra trades to make up for a rejection. - Running this repeatedly in a short window can itself trigger a broker's frequency limits, which will show up as a rising rejection rate that has nothing to do with genuine execution quality. - The MQL5 version refuses to start on a netting account if the test symbol already carries an open position, to protect the accuracy of its own measurement. The MQL4 version has no equivalent check because MQL4 has no netting model.
Script · MT5 · v1.0 · Free
About Order Latency Measurement
Order Latency Measurement is an expert advisor (trading robot) for MetaTrader 5. It looks for price differences (arbitrage). It has 7 settings, such as Symbol, Number of trades and Delay between ms. MQL source code included.
Files in the download: OrderLatencyMeasurement.ex5, OrderLatencyMeasurement.mq5, OrderLatencyMeasurement.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Symbol | Symbol to test ("" = this chart's symbol) | |
| Number of trades | 10 | Trades to send in the batch |
| Delay between ms | 1000 | Pause between trades, milliseconds |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 3 | Attempts per trade before it counts as rejected |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Confirm first | true | Ask for confirmation before sending anything |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: News Trading · Arbitrage · MT5 Script · MQL5 Source Code