MtApi5: expose MT5 economic calendar (Calendar* functions)#301
Open
biohazardxxx wants to merge 9 commits into
Open
MtApi5: expose MT5 economic calendar (Calendar* functions)#301biohazardxxx wants to merge 9 commits into
biohazardxxx wants to merge 9 commits into
Conversation
Values verified against the official MQL5 mqlcalendar reference (member order 0-based for all 8 enums). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Native CalendarCountryById/EventById/ValueById set a nonzero LastError even for a simple not-found, which made the handlers emit an error response. Native contract is a plain bool, so map any false to a null Value (client bool=false). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Compiled on the upstream/dev base (0 errors, 0 warnings). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 3, 2026
hosseinkhojany
pushed a commit
to hosseinkhojany/mtapi
that referenced
this pull request
Jul 22, 2026
…ar* functions # Conflicts: # mq5/MtApi5.ex5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Surfaces the MT5 terminal's built-in economic calendar through the MtApi5 connector. MQL5 exposes the calendar natively (
CalendarValueHistory,CalendarEventById,CalendarValueLast, …) but none of it was reachable from the .NET client. This adds all 10 nativeCalendar*functions end-to-end.What's included
C# client (
MtApi5) — 10 methods onMtApi5Client:CalendarCountries()CalendarCountryById(long, out MqlCalendarCountry)CalendarEventById(long, out MqlCalendarEvent)CalendarEventByCountry(string)CalendarEventByCurrency(string)CalendarValueById(long, out MqlCalendarValue)CalendarValueHistoryByEvent(long, DateTime, DateTime)CalendarValueHistory(DateTime, DateTime, string, string)CalendarValueLastByEvent(long, ref long)CalendarValueLast(ref long, string, string)MqlCalendarCountry,MqlCalendarEvent,MqlCalendarValueand 8ENUM_CALENDAR_*enums (values verified against the official MQL5 reference).MqlCalendarValuekeeps the raw wire fields (long, ×1e6,LONG_MIN= "no value") and adds conveniencedouble?accessors (ActualValue/ForecastValue/PrevValue/RevisedPrevValue,nullwhen empty) plusDateTime time/period.bool+outidiom;CalendarValueLast*round-trip the in/outchange_idviaref long.MQL5 EA (
mq5/MtApi5.mq5) — 10Execute_Calendar*handlers + executor registrations + 3 JSON serializers. 64-bit ids / datetimes / scaled values use the existingGET_ULONG/GET_LONGmacros andJSONNumber((long)).mq5/MtApi5.ex5recompiled (0 errors, 0 warnings).TestClient — a
CalendarHistorybutton for manual exercising.Testing
Verified against a live MT5 terminal:
CalendarCountries(23),CalendarEventByCurrency("USD")/CalendarEventByCountry("US")(248),CalendarEventById(correct event, 64-bit id intact),CalendarValueHistory(decodes correctly;LONG_MIN→null; enums decode to HIGH/PRICES/PERCENT etc.),CalendarValueById(sentinel handling),CalendarValueLastByEvent(change_idround-trips), andCalendarEventById(0)→falsewithout throwing.Branch is based on
devand contains calendar changes only.