Loading…

News Restriction Compliance Guard

Many prop-firm rulebooks ban trading a currency for a window either side of its high-impact news releases. MQL4 has no calendar feed of its own and no hook that runs before another program's OrderSend, so this EA cannot reach into a strategy and refuse a trade before it opens - nothing on either platform can. What it does instead, for real rather than only in a log line, is close any watched position whose symbol currently sits inside an active ban window, the moment it notices - and it notices every InpTimerIntervalSec seconds, not once a day. The calendar is a plain CSV file the trader (or an external export tool) maintains in the MQL4\Files\ (or MQL5\Files\ on the native MQL5 build) sandbox: one line per event, giving the currency, event name, GMT event time, minutes before/after that form the ban window, and an impact rating. The file is re-read on every check, so editing it takes effect without restarting the EA. Every ban window entering or leaving effect, and every violation closed, is written to a separate audit log CSV with a timestamp - the record a compliance review would ask for. Whether a violation that opened and closed entirely between two polling cycles gets caught at all depends on InpTimerIntervalSec. That gap is a genuine limitation of a polling-based reactive design, documented here rather than glossed over - this is a compliance NET, not a pre-trade block. Notes and limitations - Cannot block a new order before it opens. Detects and closes violations already open, on a polling cycle - see InpTimerIntervalSec above. - Currency-pair matching assumes a plain 6-letter symbol (base + quote); symbols that do not fit that shape are skipped, not guessed at. - Malformed calendar lines are skipped and counted in the Print/log output rather than aborting the whole load. - The audit log and calendar both live in the per-terminal MQL4\Files\ (or MQL5\Files\ on the native MQL5 build) sandbox, not the shared Common\Files folder - each terminal maintains its own calendar and its own audit trail.

Expert advisor · MT4 · v1.0 · Free

About News Restriction Compliance Guard

News Restriction Compliance Guard 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 Calendar file name, Audit log file name and Min impact. MQL source code included.

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

Settings

SettingDefaultWhat it does
Calendar file nameNewsRestrictionCompliance_Calendar.csvCalendar file, MQL4\Files\ sandbox (see header for format)
Audit log file nameNewsRestrictionCompliance_AuditLog.csvAudit trail of every ban entered/exited and every violation closed
Min impact3Only events at or above this impact (1-3) create a ban window
Server to gmt offset hours0Broker/server time minus GMT, hours (0 if the server already reports GMT)
Magic filter00 = watch every order on the account, otherwise only this magic number
Close violationstrueActually close a watched order sitting inside an active ban (false = log/alert only)
Dry runfalsetrue = alert and log only, never actually closes anything
Timer interval sec30How often the calendar and open orders are checked

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: News Trading · Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria