How vdemydiuk/mtapi works
MtApi is a .NET bridge for executing MetaTrader MQL operations through an Expert Advisor attached to a terminal chart; it is not a direct connection to MetaTrader servers. The principal workflow is an application invoking the MT4 or MT5 client API, which sends commands over WebSocket through the shared RPC client and service to the connector and chart-linked expert, then returns responses and trading events. README capabilities include local or remote TCP access and MT4/MT5 APIs. The available tree and excerpts establish only part of the native/MQL flow, so unshown links are omitted.
Main entry points: MtApi5Client.cs MT5 API · MtApiClient.cs MT4 API · MtService.cpp Service runtime · MtExecutorManager.cs Command execution
Components 21
RPC and service
- Command model
MTApiService/MtCommand.cs - WebSocket RPC
MtClient/MtRpcClient.cs - Service client
MTApiService/MtClient.cs - Service runtime
MtService/MtService.cpp - Command execution
MTApiService/MtExecutorManager.cs - Response types
MTApiService/MtResponse.cs
Terminal bridge
- MT4 connector
MTConnector/MTConnector.cpp - MT5 connector
MT5Connector/MT5Connector.cpp - MT4 expert handler
MTConnector/MT4Handler.h - MT5 expert handler
MT5Connector/MT5Handler.h - MetaTrader terminal
- Chart-linked expert
Trading capabilities
- Trading operations
MtApi5/MtApi5Client.cs - Quotes and ticks
MtApi5/MtApi5Client.cs - History and series
MtApi5/MtApi5Client.cs - Charts and objects
MtApi/MtApiClient.cs - Trade monitors
MtApi/Monitors/TradeMonitor.cs
Other components
- Application developer
- Sample terminal model
TestClients/TestServer/MetaTrader.cs
Connections 23
- Application developer → MT4 API: calls API
- Application developer → MT5 API: calls API
- MT4 API → WebSocket RPC: sends commands
MtApi/MtApiClient.cs - MT5 API → WebSocket RPC: sends commands
MtApi5/MtApi5Client.cs - MT4 API → Trading operations: exposes operations
MtApi/MtApiClient.cs - MT5 API → Trading operations: exposes operations
MtApi5/MtApi5Client.cs - MT5 API → Quotes and ticks: exposes data
MtApi5/MtApi5Client.cs - MT5 API → History and series: exposes history
MtApi5/MtApi5Client.cs - MT4 API → Charts and objects: exposes chart API
MtApi/MtApiClient.cs - WebSocket RPC → Service client: exchanges RPC
MtClient/MtRpcClient.cs - Service client → Command execution: submits commands
MTApiService/MtClient.cs - Command execution → Command model: uses command
MTApiService/MtExecutorManager.cs - Command execution → Response types: returns result
- Service runtime → MT4 expert handler: manages experts
- Service runtime → MT5 expert handler: manages experts
- MT4 connector → Service runtime: bridges requests
- MT5 connector → Service runtime: bridges requests
- MT4 expert handler → Chart-linked expert: invokes expert
- MT5 expert handler → Chart-linked expert: invokes expert
- MetaTrader terminal → Chart-linked expert: hosts chart expert
- Chart-linked expert → MetaTrader terminal: executes MQL
- Application developer → Trade monitors: configures monitoring
- Sample terminal model → Trading operations: simulates commands
MtApi5/MtApi5Client.cs