Skip to content
All library documents

Queued Trading Requests and Magic Number Encoding in MQL

Article MQL5 articles

Summary

The article introduces pending trading requests as a way to retry failed trade operations without blocking an expert advisor with a timed pause. A trading class can store a request, resume its normal work, and retry when the wait period ends. The same mechanism can support conditional order placement, including a stop-limit workflow or entries triggered by a price level or time.

To associate requests with orders or positions, the article proposes encoding identifiers in the magic number. It allocates fields for the EA identifier, two group identifiers, and a pending-request identifier, while describing the storage constraints and compatibility tradeoffs between MQL4 and MQL5. This is an implementation design rather than evidence of trading performance. The installment covers an initial implementation focused on opening positions, with further development left to later articles.

Key ideas

  • Queued requests let an expert advisor retry a failed trade without pausing its main execution flow.
  • A pending request can represent conditional order placement, including a stop-limit activation sequence.
  • The design encodes request and grouping identifiers in the order or position magic number.
  • The encoding trades available magic-number range for fields that support grouping and request tracking.
  • This installment begins implementation for opening positions and does not report strategy performance.

Tags

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