Skip to content
All library documents

Designing a Cross-Platform MQL4 and MQL5 Order Manager

Article MQL5 articles

Summary

This article presents a class-based order manager for expert advisors that need to execute and maintain trades in both MetaTrader 4 and MetaTrader 5. It separates shared calculations and trade-management responsibilities from platform-specific operations, using helper classes to bridge differences in request formats and execution functions.

The manager delegates position sizing and stop-loss or take-profit calculations to dedicated components, while handling order parameters, entry preconditions, active-trade limits, and trade history. The article explains important compatibility constraints: MT5 records trade actions differently, closes positions through different operations, and supports filling policies that are not available in MT4. It recommends using the common fill-or-kill behavior and checking broker volume limits before sending requests. This is an implementation design discussion rather than a trading strategy or performance study; its focus is software structure and reliable execution across platforms.

Key ideas

  • A shared base class can hold calculations while platform-specific descendants handle differing trade operations.
  • Position sizing and stop-level calculations are delegated to separate components.
  • The order manager checks entry conditions and trade-count limits before submitting an order.
  • MT4 and MT5 differ in how they submit, close, and record trades.
  • Cross-platform code should account for fill-policy and maximum-volume differences before sending requests.

Tags

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