Skip to content
All library documents

Managing Daily Volume Limits Across Market and Pending Orders

Article MQL5 articles

Summary

This article explains why a daily trading-volume cap can fail when an automated expert advisor (EA) mixes market orders with pending orders. The manager checks current and requested volume before allowing another order, but a pending order can remain unfilled while later market orders consume the remaining allowance. If that pending order then activates, total volume can exceed the cap. The examples show how this can happen near a limit, including a case where a pending order would add volume after the manager has already approved other trades.

The proposed design direction is to track activity already entered while also accounting for volume that may be added later, without restricting the EA to one order type. The article emphasizes anticipating low-probability failures, testing automated systems, and maintaining supervision. It does not provide a full implementation of the planned fix in the supplied text, and its examples explain volume limits rather than demonstrate trading performance. It also notes that a separate configuration value may need to be increased when the intended operating volume is higher.

Key ideas

  • A volume check based on current exposure can miss pending orders that may later increase exposure.
  • Mixing pending and market orders can cause an EA to exceed its daily volume limit after an order activates.
  • A robust automation design should account for potential future fills as well as current positions.
  • The article recommends testing and supervising automated EAs because runtime failures and overlooked assumptions remain possible.

Tags

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