Loading…

Two Man Rule Guardian

A genuine two-man rule - where a second person must approve a trade BEFORE it reaches the broker - is not something any MQL4 program can implement. There is no hook that runs ahead of another program's OrderSend call, on the same terminal or a different one, so nothing can truly block an oversized order from opening in the first place. This EA is built around that limitation honestly rather than pretending around it: it is REACTIVE. It notices an oversized order once it already exists, starts a confirmation clock, and closes the order if that clock runs out with no second confirmation on record. The second confirmation is a bare ticket number appended to a shared file in the Common\Files folder (visible to every terminal on the machine), written from outside this EA entirely - a colleague's script, a phone shortcut, a second MetaTrader instance, anything capable of writing a line of text. Any ticket found in that file is treated as confirmed and left alone; anything still unconfirmed once its window elapses is closed. This trades true prevention for a real, working safety net: an oversized order left unattended for longer than the confirmation window never survives unnoticed, even though it did briefly exist. Anyone submitting this to CodeBase should keep the "reactive, not preventive" framing front and centre in the listing - it is the single most important thing a downloader needs to understand before relying on it. Notes and limitations - This EA cannot prevent an oversized order from opening. It can only notice one exists and close it if unconfirmed in time. Do not present or rely on this as a pre-trade block. - The confirmation channel checks only ticket presence in the shared file - it is not a cryptographic token or signature scheme, so anyone able to write to the shared Common\Files folder can confirm any ticket. - A confirmed ticket is removed from the watch list and not re-checked; re-opening the same ticket number never happens in MQL4 (tickets are unique for the account's lifetime), so this is not a re-use risk. - If AutoTrading is off when a window elapses, the EA alerts loudly but cannot close the order, and keeps watching until AutoTrading is back on or the order is confirmed.

Expert advisor · MT4 · v1.0 · Free

About Two Man Rule Guardian

Two Man Rule Guardian is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 8 settings, such as Size threshold lots, Magic filter and Confirm window seconds. MQL source code included.

Files in the download: TwoManRuleGuardian.ex4, TwoManRuleGuardian.mq4, TwoManRuleGuardian.txt.

Settings

SettingDefaultWhat it does
Size threshold lots1.0Orders at or above this size require a second confirmation
Magic filter00 = watch every order on the account, otherwise only this magic number
Confirm window seconds300Seconds allowed for a second confirmation to arrive
Confirm file nameTwoManRuleGuardian_Confirmations.csvShared (Common\Files) file the second device writes to
Dry runfalsetrue = alert only when the window elapses unconfirmed, never actually closes
Timer interval sec5How often new orders and the confirmation file are checked
Max retries5Attempts per close 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 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria