Skip to content
All library documents

Global Take-Profit Across Open Trading Positions

Article MQL5 code base

Summary

This Expert Advisor applies a portfolio-wide take-profit rule. It monitors the combined profit of all open positions and initiates closure of every position once that profit exceeds a user-set maximum level. The method therefore manages exits at the account or basket level rather than setting a separate profit target for each trade.

The description highlights a reliability issue: closing several positions can take time and may be interrupted. To handle that, the advisor records that the profit threshold was breached in a terminal-wide variable before it begins closing positions. It can then continue the exit process based on that saved state, and removes the variable after all positions are closed. The document explains this execution safeguard but provides no trading results, details about loss controls, or guidance on how to choose the profit threshold.

Key ideas

  • The advisor closes all open positions when their combined profit exceeds a configured maximum.
  • It records the threshold breach before attempting to close positions.
  • The saved state supports continued closure if the multi-position process is interrupted.
  • The state marker is deleted after all positions have been closed.
  • The description does not specify a loss limit or report performance evidence.

Tags

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