Skip to content
All library documents

Portfolio-Wide Profit, Loss, and Time-Based Position Closure

Article MQL5 code base

Summary

This Expert Advisor monitors open positions as a group and can close them when combined profit reaches a configured take-profit level or combined loss reaches a stop-loss threshold. The thresholds can be measured as percentages or in the account’s deposit currency. The tool therefore applies portfolio-level exit limits instead of treating each position independently.

It also supports time-based operation, with configurable start and end times for the trading session. The description says the defaults allow operation from midnight and close all positions near the end of the day; when the start time is later than the end time, closure occurs the following day at the specified time. Triggered loss stops and position closures are recorded in a log. The document does not specify how profit or loss is aggregated, execution behavior, or handling of market gaps, so those details and the suitability of its limits require separate review.

Key ideas

  • The advisor can close all open positions when aggregate profit or loss reaches a configured threshold.
  • Thresholds can be defined in percentage terms or in deposit-currency units.
  • A configurable time window can govern when the advisor operates and when positions are closed.
  • The description mentions logging of stop-loss triggers and closures but gives no performance or execution analysis.

Tags

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