Porting MT5 Trade Classes and Position Management to MT4
Summary
This document describes adapting several MT5 standard trading classes for use in MT4, with the goal of sharing an Expert Advisor codebase across both platforms. It sets two constraints: the program must avoid MT5-only classes unless they are also ported, and trading and market-information operations must go through the specified trade, position, order, and symbol classes.
The examples show how to submit pending limit orders, total profit across positions filtered by symbol and magic number, and delete matching pending orders and close matching open positions. The document says a sample Expert Advisor can compile and run on both platforms, but also notes that some methods may need correction because they were not found during testing. It supplies implementation patterns rather than performance evidence, and does not assess trading outcomes or platform-specific execution differences.
Key ideas
- The port aims to let one trading program compile for both MT5 and MT4.
- MT5-only dependencies must be removed or separately ported for MT4 compatibility.
- The examples filter positions and orders by symbol and magic number before calculating profit or closing them.
- The author cautions that some class methods may still require correction.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.