Advertisement IC Markets

Disk logging as a hidden latency source

Optimize MetaTrader 4, MetaTrader 5, cTrader, and TradingView for speed. Discuss Level II Market Depth (DOM), custom hotkeys, and volume indicators.
Post Reply
Amanhasnoname
Posts: 1506
Joined: Fri Oct 30, 2026 9:45 am

Disk logging as a hidden latency source

Post by Amanhasnoname »

Writing log files seems harmless. In a tight loop, however, synchronous disk writes can stall a program for milliseconds, especially on slow or busy storage. An EA that logs on every tick can introduce significant delay.

The effect increases when the disk is shared or when antivirus software scans each write. On a VPS with network-attached storage, writes may take longer than expected.

The pattern shows up as irregular delays in tick processing. The EA seems fine in quiet markets and falls behind when ticks arrive quickly, which is exactly the time it matters.

Mitigation involves reducing log volume, buffering messages in memory and flushing periodically, and writing to a fast local drive. Use log levels so that detailed logging is enabled only when needed.

In MQL, file operations are blocking. Consider batching writes in the timer event rather than on every tick.

Measure by timing the logging calls. If they take more than a fraction of a millisecond, they are worth optimizing.

How much time does logging consume per tick in the current EA?
Recommended broker for automated trading & scalping IC Markets
Post Reply