Skip to content
All library documents

Exporting MQL5 Trade History to a Structured Trading Journal

Article MQL5 articles

Summary

This beginner-focused tutorial extends an MQL5 trading journal by selecting account history over a chosen time interval and exporting trade details to a CSV-style file. It describes creating readable column headers for identifiers, symbols, order types, volume, entry and exit times and prices, stop and target levels, profit, and outcome. The workflow uses history selection and deal iteration, then stores entry and exit information in arrays before writing records in sequence.

The article presents code snippets and explanations for counting entry deals, distinguishing them from exit deals, and labeling outcomes as wins, losses, or break-even based on profit. This is a practical logging and record-keeping method that can support later reporting or strategy review, rather than a trading signal or performance analysis. The excerpt is instructional and provides no assessment of journal accuracy across edge cases, account types, or unusual trade histories.

Key ideas

  • Select account history by start and end times before iterating through deals.
  • Use a header row so exported trade fields can be interpreted consistently.
  • Distinguish entry deals from exit deals when collecting a trade’s lifecycle details.
  • Store corresponding entry and exit fields in aligned arrays before writing journal records.
  • Classify each completed trade’s result using its realized profit.

Tags

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