Loading…

Max Lot Per Symbol Enforcer

Funded trading programmes typically cap how many lots can be open on a single symbol and how many lots can be open across the whole account at once. Both caps are trivial to breach by accident - a manual trade added on top of an EA's position, or two EAs on the same account unaware of each other - and a single oversized order can void an evaluation even when everything else about it was compliant. This EA scans open market orders (MQL4) or positions (MQL5) on a short interval, sums volume per symbol and in aggregate, and the moment either ceiling is exceeded it trims the newest order(s) on the affected symbol down to fit, closing an order outright rather than leaving an unclosable fraction below the broker's minimum lot size. Enforcement is deliberately volume based, never money based: a lot ceiling is a fixed number of lots regardless of what that volume is worth in the account currency, so no contract size or tick value conversion enters into the calculation anywhere. A magic number filter lets it enforce caps only against a specific EA's orders, or leave it at -1 to police the whole account including manual trades. A dry run mode logs exactly what would be trimmed without closing anything, useful for confirming the thresholds before trusting it on a live account. Notes and limitations This EA can only see and act on orders in this terminal's own account - it has no visibility into other terminals or accounts. Trimming always targets the newest order(s) first; it does not try to choose the "best" order to cut by any other measure such as which is most profitable. It enforces caps reactively on each scan interval, not by intercepting an OrderSend/trade request before it happens, so a very brief over-cap window can exist between the breach and the next scan.

Expert advisor · MT5 · v1.0 · Free

About Max Lot Per Symbol Enforcer

Max Lot Per Symbol Enforcer is an expert advisor (trading robot) for MetaTrader 5. It has 8 settings, such as Max lot per symbol, Max aggregate lot and Magic filter. MQL source code included.

Files in the download: MaxLotPerSymbolEnforcer.ex5, MaxLotPerSymbolEnforcer.mq5, MaxLotPerSymbolEnforcer.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Max lot per symbol1.0Maximum combined volume, in lots, open on any single symbol
Max aggregate lot3.0Maximum combined volume, in lots, open across the whole account
Magic filter-1Only enforce positions with this magic number (-1 = every position, including manual)
Check interval seconds2Minimum seconds between enforcement scans
Dry runfalseWhen true, only logs what would be trimmed - closes nothing
Slippage pips5Slippage tolerance for the trims this EA performs, in pips
Max retries5Attempts per close/trim before giving up
Retry wait ms500Pause between attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Volume · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria