Skip to content
All library documents

MQL4-Compatible Position Closure Events in an MQL5 Trading Library

Article MQL5 articles

Summary

This installment describes changes to a MetaTrader library that supports MQL4 compatibility. It removes duplicate time properties, standardizes time-based selection, adds a custom comment field for orders and positions, and updates the associated property counts and sorting options. The main implementation topic is detecting position closure events, including partial closures, pending-order removals, and close-by actions, alongside changes to stop levels or pending-order prices.

The article walks through updates to the library’s data structures and event handling, then describes testing with an Expert Advisor in the strategy tester. The examples report that partial closure and pending-order removal are detected as distinct events, and that button-triggered checks identify relevant trade changes. This is a software implementation guide rather than a trading strategy: its value is in event tracking and cross-version compatibility. Results are demonstrated in the MetaTrader environment, and the text does not provide broader performance or reliability measurements.

Key ideas

  • The library removes redundant time fields and uses one time-selection option for each open or close time.
  • A custom comment property lets users label orders and positions for later display or filtering.
  • Position closure handling distinguishes partial closures, pending-order removals, and close-by events.
  • The article demonstrates event detection with a test Expert Advisor in the strategy tester.
  • The material covers MQL library implementation rather than trading performance.

Tags

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