How joni0108/mql5-sdk works
Project Type & Purpose
• This is an open-source SDK/framework for developing Expert Advisors (EAs), indicators, and scripts in MQL5 (MetaTrader 5’s language).
• It provides a stable, modular API on top of native MQL5 features, grouping functionality into packages, modules, and classes to simplify EA development and extension.
File-Structure Analysis
• Top-Level:
• modules/ ← All public packages & modules (mql5, network, terminal, apis, concepts, utils)
• internal/ ← Core utilities (enums, error handling) used by multiple modules
• sdk.mqh ← Root “umbrella” include that pulls in everything
• docs/ ← Documentation for users and each module
• .github, README, CHANGELOG, LICENSE, CONTRIBUTING
• Patterns:
• Package-Module-Class hierarchy under modules/
• Single entry point: modules/mql5.mqh (the “mql” package) that auto-imports submodules
• internal/ as a shared library of common definitions
README Insights
• Emphasis on stable, backward-compatible API versions (semantic versioning)
• Installation target: copy .mqh headers into MetaTrader’s Include folder, .dll files into Libraries
• Modular imports: users can include entire SDK or cherry-pick modules
a. Main Components
• MQL5-SDK Core (sdk.mqh)
• Package Layers:
– MQL Package: account, terminal, market, trade, files modules
– Network Package: web-requests, sockets, JSON serialization
– Terminal Package: UI simulation (clicks, keymap, login)
– APIs Package: Discord, Telegram, Notion, etc.
– Concepts Package: trading patterns, zones, liquidity, trend detection
– Utils Package: logging, backtesting support, reporting, tools
• Internal Layer: enums, errors, shared macros
• Host Environment: Metatrader 5 (compiler, runtime), file system, network stack, external services
b. Relationships & Interactions
• sdk.mqh → imports Internal Layer + selected modules
• Modules → depend on Internal Layer (enums, error handling)
• MQL Package modules → call native MQL5 API under the hood
• Network & APIs → call Metatrader network functions / DLLs to reach external services
• Utils → used by other packages (e.g., logging by any module; backtest by trading modules)
• Host Environment ←→ SDK (compile-time includes, runtime interactions)
c. Architectural Patterns & Principles
• Layered Architecture:
– Core/Internal at the bottom
– Functional Packages in the middle
– SDK Entry Point at top
• Modular Design: each package is self-contained, can be included individually
• Semantic Versioning: clear boundary between stable vs breaking changes
• Separation of Concerns: trading logic, network, UI simulation, and utilities are distinct
d. Key Technologies & Libraries
• MQL5 Language & Native API
• .mqh include files (header-only modules)
• DLLs (for advanced features, copied into /libraries)
• JSON serialization, HTTP sockets (network module)