Skip to content
All library documents

Tracking Multiple Trading Orders with Current and Prior State Arrays

Article MQL5 articles

Summary

This article presents a program structure for tracking many open and pending orders in an MQL4 expert. A dedicated routine runs on each tick before strategy logic, collects order attributes into globally available arrays, and supports comparisons between current and prior states. The stored fields include prices, stop loss and take profit levels, ticket, lot size, order type, and magic number; a multi-symbol design adds a symbol dimension.

Comparing snapshots can identify order changes and events, including pending orders becoming active. The article also discusses limits on array capacity, handling manually placed orders or orders from multiple traders, and normalizing open prices to account for end-of-day swap effects. Its arrays use fixed capacities and an indexing convention that readers may need to adapt. The closing discussion cautions that open price alone may be a poor decision criterion and emphasizes choosing strategy criteria carefully; it does not evaluate trading performance.

Key ideas

  • A terminal inventory routine should collect order data before other strategy logic runs on each tick.
  • Separate current and prior order arrays allow the program to detect changes between snapshots.
  • Arrays can store order attributes and extend to track orders across multiple symbols.
  • Pending, manually placed, and externally managed orders may need to be included in program state.
  • Price normalization and choice of decision criteria matter when interpreting order data.

Tags

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