Loading…

Symbol Permission Enforcer

A strategy built and tested for a handful of symbols can still end up trading somewhere it was never meant to - a fat-fingered manual click on the wrong Market Watch row, a copy-trading feed sending an unfamiliar symbol, or an EA with a bug in its symbol selection. This EA maintains an explicit comma-separated allow list and scans every market position and, optionally, every pending order in the whole terminal - not just the attached chart - for anything outside it, matching an optional magic number filter. An empty allow list is treated as a configuration mistake, never as "allow everything". Falling back to permitting every symbol the moment the input is blank would be the one failure mode capable of doing real damage silently; instead the EA falls back to allowing only the chart's own symbol and says so loudly in the log, so a blank input is impossible to miss rather than impossible to notice. Enforcement, like every guard in this catalogue, is after the fact: nothing running alongside another EA in the same terminal can refuse another program's OrderSend call before the ticket exists, so a disallowed order is allowed to appear and is then closed (market positions) or deleted (pending orders) immediately, with the reason logged and alerted. Notes and limitations Symbol names must match exactly, including any broker-specific suffix (such as EURUSDm or EURUSD.raw) - the allow list does no fuzzy matching. It only sees orders visible in this terminal's account and cannot prevent another terminal or a mobile app from placing an order in the moment before this EA's next check interval. Deleting a pending order or closing a position outside the allow list is permanent; test InpAction as ACTION_ALERT_ONLY first on an unfamiliar account before switching to ACTION_CLOSE.

Expert advisor · MT5 · v1.0 · Free

About Symbol Permission Enforcer

Symbol Permission Enforcer is an expert advisor (trading robot) for MetaTrader 5. It has 8 settings, such as Allowed symbols csv, Action and Magic filter. MQL source code included.

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

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

Settings

SettingDefaultWhat it does
Allowed symbols csvEURUSD,GBPUSD,USDJPYComma-separated allow list, e.g. "EURUSD,GBPUSD"
ActionACTION_CLOSEWhat happens to a disallowed order
Magic filter-1Magic number filter, -1 = every magic number
Include pendingtrueAlso delete pending orders on disallowed symbols
Check interval seconds5Minimum seconds between enforcement passes
Alert repeat seconds300Minimum seconds between repeat alerts for the same ticket
Max retries5Attempts per action 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: Alerts · Trade Copier · Pending Orders · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria