Skip to content

MtApi5: implement SendNotification, SendMail, Comment, PlaySound#303

Open
biohazardxxx wants to merge 5 commits into
vdemydiuk:devfrom
biohazardxxx:feat/mql5-terminal-notifications
Open

MtApi5: implement SendNotification, SendMail, Comment, PlaySound#303
biohazardxxx wants to merge 5 commits into
vdemydiuk:devfrom
biohazardxxx:feat/mql5-terminal-notifications

Conversation

@biohazardxxx

Copy link
Copy Markdown

Summary

Implements four MQL5 terminal notification/output functions that were reserved in Mt5CommandType.cs but never wired up (//TODO). This makes chart comments, sound alerts, push notifications and terminal email reachable from the .NET client, end-to-end (C# client → EA handlers → recompiled .ex5).

New methods on MtApi5Client:

Command id Method
137 bool Comment(string comments)
142 bool PlaySound(string filename)
144 bool SendNotification(string text)
145 bool SendMail(string subject, string someText)

Implementation notes

  • Command ids — reuses the existing reserved ids (Comment = 137, PlaySound = 142, SendNotification = 144, SendMail = 145); only those four //TODO markers were removed. The remaining reserved ids (GetTickCount, GetMicrosecondCount, MessageBox, PeriodSeconds) are untouched.
  • C# client — methods live in the Common Functions region next to Print/Alert and follow the Print pattern: SendCommand<bool> with a parameters dictionary, string params null-coalesced to string.Empty. Payload keys: Comments, Filename, Text, Subject/SomeText.
  • MQL5 EA (mq5/MtApi5.mq5) — handlers follow the Execute_Alert/Execute_Print style (GET_JSON_PAYLOAD + GET_STRING_JSON_VALUE, direct built-in calls). SendNotification/SendMail/PlaySound pass the built-in's bool result through via JSONBool (PlaySound returns bool in MQL5, so its real result is passed through too). Comment() is void in MQL, so its handler returns JSONBool(true) to satisfy the "return true after execution" contract, matching the Execute_Print precedent. Executor registrations inserted in numeric order in preinit().
  • TestClient — kept minimal: two buttons (Comment, SendNotification) next to the existing Print/Alert buttons, reusing the existing MessageText textbox. PlaySound/SendMail have no test buttons.
  • The diff is purely additive — no changes to existing behavior. A post-implementation review traced all four commands end-to-end (id match between Mt5CommandType.cs and the ADD_EXECUTOR registrations, byte-identical JSON payload keys on both sides, response marshaling via the proven JSONBool{"ErrorCode":"0","Value":true}SendCommand<bool> path used by GlobalVariableCheck) and found no defects.

Testing

  • MtApi5 builds with 0 warnings / 0 errors (Release); MtApi5TestClient builds with 0 errors (its nullable warnings are pre-existing, none in the added code).
  • MtApi5.mq5 compiles via MetaEditor with "Result: 0 errors"; the recompiled mq5/MtApi5.ex5 is committed (a6ebc37).
  • Not runtime-tested against a live MT5 terminal — actual notification/mail/sound delivery requires a configured live terminal, so verification was build/compile-level only.

🤖 Generated with Claude Code

biohazardxxx and others added 5 commits July 3, 2026 23:58
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…hods

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <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.

1 participant