News Filter Engine
Most news filters hardcode one window - "block 30 minutes either side of any High-impact event" - as a pair of input parameters. That falls apart the moment a trader wants different treatment for Medium impact, or wants High and Medium both gated but with different widths. This header replaces the fixed pair with an array of SNewsGateRule entries, each naming an impact level string and its own minutesBefore/minutesAfter. Adding, removing or retuning a level is one line in the array, not a change to the gating logic itself - CheckAndPrint in the demo shows the same call shape working unchanged across five different check times. The calendar format is the same time_iso,currency,impact,title CSV already used by NewsAutoFlat.mq4 elsewhere in this catalogue, so one export script - from any calendar API, RSS feed or manual spreadsheet - can feed every calendar-driven project here without a per-project conversion step. Times are compared as literal wall-clock values against whatever datetime the caller passes in; there is no timezone conversion, so the calendar export and the caller's own clock (normally broker/server time) must already agree. IsTradeGated decomposes the traded symbol into its base and quote currency by splitting the first six characters, tolerant of a broker suffix afterward (EURUSD.m, EURUSDm, EURUSD#ecn all decompose the same way). An event gates the symbol if its currency matches either leg AND its impact level has a configured rule - an impact string with no rule (Low, or an unrecognised value from a feed) is deliberately never gated rather than silently blocking on an unconfigured level. A missing or empty calendar file is reported through outReason on every call rather than treated as "nothing scheduled" - IsTradeGated still returns false in that case (nothing CAN be gated with no data), but the reason string says plainly that no protection is active, so a caller displaying it on-chart never shows a false "all clear". Notes and limitations - No timezone conversion happens anywhere in this header. The calendar export and the caller's clock must already agree - normally both in broker/server time, the convention the rest of this catalogue uses. - A calendar row with a comma inside its title misaligns that row, the same constraint the plain four-column CSV format imposes everywhere else in this catalogue - it trades a full RFC4180 parser for staying self-contained. - An impact level string is matched case-insensitively but otherwise exactly ("High" matches "high" but not "HIGH-IMPACT" or "H"). Keep the calendar export's impact column consistent with the rule array's impact strings. - This header never trades and never modifies chart state - it only answers "is this gated, and why" for whatever symbol and time the caller passes in.
Script · MT5 · v1.0 · Free
About News Filter Engine
News Filter Engine is a script for MetaTrader 5. It has 1 setting, such as Calendar file name. MQL source code included.
Files in the download: NewsFilterEngine.mq5.mqh, NewsFilterEngine.txt, NewsFilterEngineDemo.ex5, NewsFilterEngineDemo.mq5.
Settings
| Setting | Default | What it does |
|---|---|---|
| Calendar file name | NewsFilterEngineDemoCalendar.csv | Sample calendar file, written into MQL5\Files\ |
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 → Scripts.
- 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 script onto a chart to run it once.
Tags: News Trading · MT5 Script · MQL5 Source Code