Skip to content
All library documents

Retrieving the Nth Most Recently Closed MT4 Trade

Article MQL5 code base

Summary

This brief description explains an MT4 expert advisor that scans historical closed trades and retrieves one by recency. An index of zero refers to the latest closed trade; increasing the index moves backward through the close history, so an index of one identifies the trade immediately before the latest.

The lookup can also be filtered by symbol and magic number, which helps isolate trades associated with a particular instrument or EA instance. The document does not describe how ties, missing history, or invalid indices are handled, and it offers no code, testing evidence, or trading strategy. Its value is operational: it outlines a way to access prior executions for logic that depends on closed-trade history.

Key ideas

  • The EA searches the account's closed-trade history and orders results by closing recency.
  • An index of zero selects the most recently closed trade.
  • Larger indices refer to progressively earlier closed trades.
  • Symbol and magic-number filters can narrow the trades returned.
  • The description gives no implementation or evidence about edge-case behavior.

Tags

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