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 · MT5 · v1.0 · Free
About News Restriction Compliance Guard
News Restriction Compliance Guard is an expert advisor (trading robot) for MetaTrader 5. It has a news filter. 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.ex5, NewsRestrictionCompliance.mq5, NewsRestrictionCompliance.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Calendar file name | NewsRestrictionCompliance_Calendar.csv | Calendar file, MQL5\Files\ sandbox (see header for format) |
| Audit log file name | NewsRestrictionCompliance_AuditLog.csv | Audit trail of every ban entered/exited and every violation closed |
| Min impact | 3 | Only events at or above this impact (1-3) create a ban window |
| Server to gmt offset hours | 0 | Broker/server time minus GMT, hours (0 if the server already reports GMT) |
| Magic filter | 0 | 0 = watch every position on the account, otherwise only this magic number |
| Close violations | true | Actually close a watched position sitting inside an active ban (false = log/alert only) |
| Dry run | false | true = alert and log only, never actually closes anything |
| Timer interval sec | 30 | How often the calendar and open positions are checked |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: News Trading · MT5 Expert Advisor · MQL5 Source Code