Skip to content

MQL5: add timer-based command polling for live trading#295

Open
biohazardxxx wants to merge 12 commits intovdemydiuk:devfrom
biohazardxxx:fix/mql5-timer-based-command-polling
Open

MQL5: add timer-based command polling for live trading#295
biohazardxxx wants to merge 12 commits intovdemydiuk:devfrom
biohazardxxx:fix/mql5-timer-based-command-polling

Conversation

@biohazardxxx
Copy link

Summary

  • In live trading, OnTimer() (which drains the command queue) was only called from OnTick() during backtesting. Commands from the .NET client would queue up and never be processed until the next market tick, making the EA unresponsive on low-volume symbols or outside market hours.
  • Added EventSetMillisecondTimer(100) in init() for live trading mode so commands are polled every 100ms regardless of tick activity.
  • OnTimer() is now also called on every tick (supplements the timer for lowest latency when ticks are flowing).
  • Added EventKillTimer() in deinit() for proper cleanup.

Test plan

  • Compile MtApi5.mq5 with MetaEditor — verified 0 errors, 0 warnings
  • Attach EA to a low-volume symbol, connect .NET client, and verify commands are processed promptly even without ticks
  • Verify backtesting mode still works correctly (timer is not started, OnTick() still calls OnTimer())
  • Verify high-volume symbols still work with normal latency (no duplicate command execution)

🤖 Generated with Claude Code

vdemydiuk and others added 12 commits July 28, 2025 23:29
OnTimer() (which drains the command queue via executeCommand()) was only
called from OnTick() during backtesting. In live trading, commands from
the .NET client would queue up and never be processed until the next
market tick arrived, making the EA unresponsive on low-volume symbols
or outside market hours.

- Add EventSetMillisecondTimer(100) in init() for live trading mode
- Call OnTimer() on every tick regardless of mode (supplements the timer)
- Add EventKillTimer() in deinit() for cleanup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The .ex5 binary was stale and still referenced removed DLL imports
(getIntValue, getDoubleValue, etc.) that no longer exist in
MT5Connector.dll since the migration to the JSON payload-based
protocol (getPayload). This caused "unresolved import function call"
errors when loading the EA in MetaTrader.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants