Skip to content
All library documents

Bridging MQL4 and MQL5 Trading Events for Position and Order Opens

Article MQL5 articles

Summary

This installment in a MetaTrader library series addresses compatibility between MQL4 and MQL5 while tracking position openings and pending-order activations. It starts by compiling a test expert advisor under MQL4, then uses the resulting errors to identify dependencies on MQL5-only trading classes and functions. Conditional compilation separates platform-specific code, while MQL4 helper functions provide basic order submission and modification behavior for the test environment.

The article also explains an overload ambiguity involving chart-object enumeration in MQL4 and resolves it by explicitly supplying the subwindow argument. Its focus is library plumbing and event handling rather than a trading strategy. The example trading helpers deliberately omit many checks needed for live or demo trading, and the article says that MQL4 event tracking still has issues to address in a later installment; readers should treat this as an intermediate compatibility step, not a complete production implementation.

Key ideas

  • Conditional compilation lets shared expert-advisor code isolate MQL5-only trading classes from MQL4 builds.
  • Basic MQL4 helper functions can stand in for selected MQL5 trade operations during testing.
  • Explicit arguments can resolve ambiguous overloaded function calls in MQL4.
  • The test workflow uses compiler errors to guide compatibility changes.
  • The provided trading routines omit safeguards and the event-tracking work remains incomplete.

Tags

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