Skip to content
All library documents

MQL5 Order Placement with OrderSend and CTrade

Article MQL5 articles

Summary

This article explains the distinction between orders, deals, and positions in MetaTrader 5, then introduces two ways to manage trades from MQL5: direct requests with OrderSend and the higher-level CTrade class. It covers market and pending orders, stop-loss and take-profit settings, pending-order modification and removal, and position operations. The request structure carries fields such as symbol, volume, price, order type, filling policy, and position ticket; a result structure receives the server response.

Examples include a moving-average crossover system implemented using each method, illustrating how the APIs can perform similar trade operations. The article also notes that buy and sell execution prices differ between opening and closing actions. Its examples are instructional rather than evidence of profitability: the author advises testing suitability before live use. Some displayed code and sections are incomplete in the supplied text, so readers should consult the platform reference and validate details before relying on an implementation.

Key ideas

  • An order is a request, a deal records an execution, and a position represents the resulting net exposure.
  • OrderSend sends a request structure to the trade server and returns execution information through a result structure.
  • Trade requests can open market or pending orders, set protective levels, modify pending orders, and remove them.
  • CTrade offers a higher-level interface for operations that can also be handled through OrderSend.
  • The example crossover systems illustrate API usage and do not establish trading profitability.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.