MQL5 Trade Operations and Standard Library Classes for Trading Robots
Summary
This introductory article explains how an MQL5 expert advisor can submit and manage trades. It outlines market orders, pending stop and limit orders, order modification and deletion, and position changes, with OrderSend and its asynchronous counterpart as the underlying request mechanisms. The MqlTradeRequest structure carries operation details, so correct field selection and checking execution results are central to reliable order handling.
The examples introduce Standard Library classes for inspecting account permissions and balances, symbol prices and contract settings, and for simplifying trade requests with CTrade. The article also points toward account, symbol, terminal, and indicator classes as building blocks for a robot. Its focus is platform mechanics rather than a trading signal, strategy, or performance evaluation; it offers no evidence about profitability. The examples are educational and emphasize checking account and symbol constraints before sending orders, while leaving the choice of what to trade and when to trade to the strategy developer.
Key ideas
- MQL5 trade requests support market orders, pending orders, and changes to existing orders or positions.
- OrderSend waits for a response, while OrderSendAsync submits a request without waiting for completion.
- The request structure must contain fields appropriate to the selected operation, and its result needs handling.
- Account and symbol information classes expose permissions, prices, contract properties, and trading limits.
- CTrade and related library classes can reduce the amount of low-level request handling in an expert advisor.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.