Skip to content
All library documents

Capping Gross Symbol Exposure Across Multiple Trading Systems

Article MQL5 code base

Summary

This document describes a shared pre-trade control for limiting total gross position volume in a symbol across multiple Expert Advisors. Each strategy checks all open positions on the symbol, including positions opened manually or by other EAs, and allows a proposed order only if its addition would remain within the configured cap. It also describes helper functions for reading current exposure and remaining capacity, plus a refusal log that records held, requested, and capped volume.

The motivation is a demo-account incident in which independent systems repeatedly entered the same symbol, accumulating 22 contracts against an intended one-contract exposure and prompting a watchdog to close 16. The proposed check belongs before order submission and should use the same cap across the fleet. Its limits are explicit: it measures gross rather than net exposure, offers no per-system allocation, and is not atomic, so simultaneous checks can both pass before either order is visible.

Key ideas

  • Independent systems can exceed intended symbol exposure when each checks only its own positions.
  • A pre-order check can sum all open volume for a symbol across strategies and manual trades.
  • The cap applies to gross volume and does not offset opposing long and short positions.
  • The check is not a lock, so simultaneous order decisions can still exceed the limit.

Tags

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