Event Exposure Rotator
A position held straight through a high-impact release is exposed to a spread spike and a slippage-heavy fill on both the entry that is already open and anything that reacts to it, and manually watching a calendar and flattening by hand does not scale past a couple of symbols. This EA reads a fixed target book from InpBookDefinition - a comma- separated list of SYMBOL:DIRECTION:LOTS entries - and, on each check interval, reloads an external calendar file and checks whether either of a symbol's two currencies has a qualifying event whose blackout window (configurable minutes before and after the event time) covers the current server time. A symbol currently in blackout is closed and marked as rotated away; once its blackout window passes, it is reopened at exactly the direction and lot size it was closed at, not a fresh guess. A symbol never re-enters blackout handling twice for the same still-active event, and a symbol with no qualifying event on either currency is left alone entirely. The calendar file itself is not fetched from anywhere - this EA has no news feed of its own. It reads a plain CSV that the user, a script, or another tool keeps updated; the exact format is documented below. Notes and limitations - The calendar file is reloaded from disk on every check interval, not cached - a change only takes effect from the next check onward. - Currency codes are matched against the symbol's first and last three characters and are skipped for symbols that do not follow that convention. - If a symbol cannot be restored after its blackout window (broker rejects the order, stops level, etc.), it stays flat and is retried on the next check interval rather than the EA halting. - No stop-loss or take-profit is managed by this EA - it only opens and closes at the configured target lot size; risk management on the position itself is the user's own responsibility elsewhere. - A malformed calendar row or book entry is skipped and logged rather than aborting the whole file.
Expert advisor · MT4 · v1.0 · Free
About Event Exposure Rotator
Event Exposure Rotator is an expert advisor (trading robot) for MetaTrader 4. It has 11 settings, such as Book definition, Calendar file and Min importance. MQL source code included.
Files in the download: EventExposureRotator.ex4, EventExposureRotator.mq4, EventExposureRotator.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 |
|---|---|---|
| Book definition | EURUSD:BUY:0.10,GBPUSD:SELL:0.10,USDJPY: | Symbol:Direction:Lots list, comma-separated |
| Calendar file | EventCalendar.csv | File under MQL4\Files\ - see .txt for the exact format |
| Min importance | HIGH | Minimum importance token that triggers a rotation (HIGH or MEDIUM) |
| Blackout minutes before | 30 | Minutes before the event time to flatten the symbol |
| Blackout minutes after | 30 | Minutes after the event time to keep the symbol flat |
| Check interval seconds | 60 | Seconds between calendar re-checks |
| Magic number | 20271001 | Magic number identifying this book's own positions |
| Slippage pips | 5 | Slippage allowance, in pips |
| Dry run | false | true = log intended actions only, never trades |
| Max retries | 5 | Attempts per order action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 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: MT4 Expert Advisor · MQL4 Source Code