Skip to content
All library documents

Exporting Closed Trading Positions to a Journal CSV

Article MQL5 code base

Summary

The document describes a terminal script for exporting account history into a CSV trading journal. It selects deals from a user-chosen lookback period and groups them by position ID to reconstruct closed positions, including on netting and hedging accounts. For positions with partial fills, it calculates volume-weighted entry and exit prices, then records direction, size, timestamps, point result, commissions, swaps, net profit, holding duration, and the first deal comment.

Users can set the period, filename, separator, output folder, and whether to restrict export to the current chart symbol. The export skips positions that remain open and those whose entry falls outside the selected period. This is a record-keeping utility, not a trading strategy or performance analysis. The document provides no sample output or validation results, and the selected lookback and skip rules may leave some account activity out of a given export.

Key ideas

  • The exporter groups account deals by position ID to reconstruct closed positions.
  • It supports partial fills by calculating volume-weighted entry and exit prices.
  • The CSV includes trade outcomes, costs, timing, and a deal comment for filtering.
  • Open positions and positions entered before the selected period are excluded.
  • Output settings include the date range, delimiter, filename, folder, and symbol filter.

Tags

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