Skip to content
All library documents

Selecting and Reading Closed Position History in MQL5

Article MQL5 code base

Summary

The document describes a MQL5 class for retrieving and inspecting closed positions. Its methods expose position details such as opening and closing times, direction, volume, prices, stop loss and take profit, commissions, swaps, profit, symbol, comments, and deal tickets. It also includes selection functions for retrieving historical positions by ticket or index over a chosen date range.

The example selects history from a specified start time through the current time, iterates over the returned positions, and reads their properties. It notes that the selected positions are ordered by closing time, which supports calculating a running balance in chronological order of closures. This is an interface and usage description, not a trading analysis; it does not discuss data-quality checks, accounting edge cases, or performance evaluation.

Key ideas

  • The class provides access to properties of closed positions in MQL5 history.
  • History can be selected by date range, ticket, or index.
  • The example iterates over selected positions and reads timing, pricing, cost, profit, and identifying fields.
  • Selected positions are ordered by closing time rather than opening time.
  • Closing-time order can support chronological running-balance calculations.

Tags

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