Skip to content
All library documents

Analyzing Trade Duration and Profit with Regression and Buckets

Article MQL5 articles

Summary

This article presents an account-history dashboard that plots each closed trade's holding time against its net profit. It recovers opening times by matching deals on position ID, keeps closing and reversal deals, and combines profit, swap, and commission. A least-squares line summarizes the relationship between duration and profit; its slope indicates the direction and size of the average association, while R² measures how much profit variation the line explains. A logarithmic duration axis accommodates trades held for widely differing lengths, and a bucket analysis identifies which duration range had the highest historical average result.

The article includes a synthetic-data check of the regression calculations and the bucket selection, including an empty-bucket case. Its conclusions are limited: a linear association in one account's past does not establish causation or predict an individual future trade. The tool does not model more complex relationships, account for costs beyond swap and commission, or derive bucket boundaries from data, so its findings should be treated as descriptive diagnostics.

Key ideas

  • Closed-trade profit should include swap and commission as well as deal profit.
  • The regression slope summarizes the historical association between holding time and net profit, while R² measures fit.
  • Logarithmic scaling helps display holding times that span a wide range.
  • Duration buckets offer a second view by comparing average historical results across hold-time ranges.
  • Historical correlation is account-specific and does not establish causation or predict future trades.

Tags

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