Skip to content
All library documents

Reconstructing Position Profit and Entry-Time Distributions in MQL5

Article MQL5 articles

Summary

This article explains how to build HTML charts that show trading results by the time positions were opened, grouped across an account and by symbol. Its central step is reconstructing positions from the order and deal history: records sharing a position identifier belong together, and a position’s opening time comes from its first order. Profit is calculated by summing the profit of its buy and sell deals.

A reversal example shows that the deal which causes a position to reverse remains associated with the old position identifier; later deals belong to the new position. The article then describes using Google Charts to display distributions by hour, day, and month, with reports launched from a terminal account or strategy tester. It also describes analysis in money, points, or both. These charts are intended to help inspect time-related patterns before parameter optimization. They are descriptive analytics, however, and do not establish that any observed pattern will persist or improve future performance.

Key ideas

  • Group trade deals by their position identifier to reconstruct positions from MQL5 history.
  • Calculate position profit by summing the profit of its buy and sell deals.
  • Treat a reversal-causing deal as part of the prior position; subsequent deals use the new identifier.
  • Plot position profitability by opening hour, day, and month to inspect possible timing patterns.
  • Use the report as exploratory analysis before optimization, not as evidence of predictive performance.

Tags

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