Advertisement IC Markets

Python + MT5: tick latency logger without buying fancy software

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Python + MT5: tick latency logger without buying fancy software

Post by PTScalper »

LondonScalper wrote: Thu Sep 10, 2026 6:59 pm
PTScalper wrote:Continuous is strictly better, provided you have a localized log rotation.... If you only log around the London or NY opens, you miss the baseline.
Agree on continuous with rotation. Open-only logging makes every spike look like a crisis because you never measured the quiet baseline.

Lean stack is the point — isolate broker lag from your own VPS/network without renting another SaaS toy. I want terminal truth, not a vendor dashboard that averages away the ugly minutes.

Practical note from years of this: annotate platform builds and VPS route changes in the same log. Otherwise you’ll “blame the broker” for a week that was actually your own infrastructure drift.
That note on infrastructure drift is pure gold. Nothing wastes more time than diagnosing "broker latency degradation" only to discover a silent route change or host migration added 12ms to your round-trip. Terminal truth over smoothed SaaS p99s every time.

Have a good trades.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Recommended broker for automated trading & scalping IC Markets
LondonScalper
Posts: 965
Joined: Sat Sep 05, 2026 7:54 am

Re: Python + MT5: tick latency logger without buying fancy software

Post by LondonScalper »

PTScalper wrote:Nothing wastes more time than diagnosing "broker latency degradation" only to discover a silent route change or host migration added 12ms to your round-trip. Terminal truth over smoothed SaaS p99s every time.
Been there — spent days blaming the venue for what was a quiet VPS move.

I keep a one-line infra diary next to the latency CSV: build number, route/host note, anything that changed. Twelve milliseconds won’t always show in a vendor’s smoothed p99, but it’ll show in your open-window deltas if you have a baseline. Terminal truth first; SaaS charts as optional colour.

Have a good session. If the logger stays boring for a month, that’s success — drama in the latency file usually means something drifted.
LondonNewsTrader
Posts: 421
Joined: Mon Sep 21, 2026 9:30 am

Re: Python + MT5: tick latency logger without buying fancy software

Post by LondonNewsTrader »

PTScalper wrote: For sub-millisecond truth, a native MQL5 script utilizing EventChartCustom or writing directly via FileWrite is the only way to eliminate observer effect.
It depends on which clock you want. If you pull ticks with copy_ticks_from or copy_ticks_range, every tick carries time_msc, stamped by the server, so Python jitter doesn't touch those timestamps at all. Inter-arrival gaps measured from time_msc show feed gaps. What they can't show is a VPS or terminal stall, because that needs local receipt time, and for that you are right that MQL5 with GetMicrosecondCount() is the better tool.

One caveat on the MQL5 side: an EA doesn't queue ticks. If OnTick is still running when a new tick arrives, that tick event is skipped. So a logger that does work inside OnTick can miss exactly the bursts you want to see, which come on releases. The cleanest setup I've used is a tiny OnTick that only records GetMicrosecondCount() and the tick time into an array, plus CopyTicks afterwards to fill in anything skipped.

Continuous logging is worth the disk space. The quiet Asian baseline is what makes the London and data spikes measurable.
FXS Prop Desk
Posts: 1689
Joined: Wed Oct 07, 2026 9:52 am

Re: Python + MT5: tick latency logger without buying fancy software

Post by FXS Prop Desk »

Logging inter-arrival gaps continuously is a good way to set a baseline. For the Python side, the MetaTrader5 package can call copy_ticks_from to retrieve historical ticks with millisecond timestamps, which lets you compare live gaps with the broker's recorded tick history. If the live logger shows long gaps but the history does not, the problem is local (VPS or connection) rather than the broker feed.
FXS Official Team | The Idea Lab & Strategy
Post Reply