Managing Correlated Trading Baskets with Aggregate P&L Stops
Summary
The document describes an MQL5 framework for managing related open positions as a single basket. Positions are grouped by an identifier in their comments, then scanned to calculate leg count, long and short volume, aggregate floating profit and loss, and volume-weighted pip performance. A stop registry tracks a basket-level equity threshold, while an executor handles opening and closing legs and a dashboard displays current state.
The approach separates position discovery, execution, risk monitoring, and presentation. A demo uses EURUSD and a configurable gold symbol, and the article lists a verification script with synthetic-data checks. The method can help coordinate basket decisions that MetaTrader otherwise treats position by position. Its reliability depends on broker comments retaining the basket identifier; comment changes can break grouping. Stops also require the expert advisor to run checks through tick or timer events, and the described design does not combine risk across multiple baskets. The article outlines extensions such as take-profit levels and portfolio-wide limits but does not provide evidence of trading performance.
Key ideas
- Basket membership is identified through a prefix and basket ID stored in each position comment.
- The scanner aggregates floating P&L, directional volume, and volume-weighted pip results across matching positions.
- A basket-level stop threshold can trigger coordinated closing of all associated legs.
- The design separates scanning, execution, stop monitoring, and display into distinct components.
- Broker changes to comments and the lack of portfolio-wide aggregation are important limitations.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.