An MT5 news filter pauses new entries, and optionally closes open positions, for a set window around high-impact economic releases. The fastest reliable route is either the built-in economic calendar through CalendarValueHistory, wrapped in a lightweight cache, or a standalone guardian EA that flips a global flag. The rest of this guide covers the architecture choices, timezone traps, testing patterns, and prop-firm compliance details that decide whether your filter actually holds up in production.
TL;DR:
- Using a cached calendar API call and filtering results locally minimizes latency and ensures reliable detection during live trading or backtesting.
- Dynamically calculating broker server time and adjusting for daylight saving prevents timing discrepancies around high-impact economic releases.
- Industry-standard blackout windows range from 15 to 60 minutes, depending on event impact and strategy, and should be configurable through input parameters.
- Exporting calendar data to CSV files for backtesting ensures reproducibility and accuracy when the built-in MT5 calendar isn't accessible in the Strategy Tester.
- Funded account simulations support news trading and weekend holding, providing a practical environment to validate your filter's timing before risking real money.
Table of Contents
- What a news filter does and three ways to build one
- MT5 economic calendar API and how to query it efficiently
- Getting broker time zones and daylight saving right
- Setting blackout windows, impact levels, and currency filters
- Testing and backtesting your filter without guesswork
- Prop-firm rules for news trading and how to stay compliant
- Integration checklist and defensive coding patterns
- When to use a built-in calendar module versus a standalone guardian
- Practice news-aware EAs on a simulated funded account
- Primary sources and developer references
- Sources
- FAQ
What a news filter does and three ways to build one
A news filter has two jobs, and they're not the same thing. Blocking new entries during a blackout window is the baseline: your EA simply refuses to open trades while a flag is set. Closing existing positions before an event is a separate, more aggressive decision that depends on your strategy's tolerance for gap risk and spread widening.
There are three common architectures for this, and each one shows up repeatedly across libraries and market products:
- Integrated module: a header file like
NewsFilter.mqhincluded directly in your EA, querying the MT5 calendar and exposing a simpleIsNewsTime()function. - Standalone guardian EA: a separate EA that monitors the calendar and either disables
AlgoTradingat the terminal level or writes aGlobalVariablethat your trading EAs check before every order. - CSV or hardcoded schedule: a fixed list of event times loaded from a file, used mainly for backtesting or for brokers where the built-in calendar is unreliable.
The tradeoffs come down to backtestability, simplicity, and overhead. An integrated module is easiest to reason about and ship as one file, but it duplicates logic if you run several EAs. A guardian EA coordinates multiple robots from one place, which matters if you're running a portfolio across several charts, though it adds a moving part that has to stay alive. CSV schedules are the only option that gives you deterministic results in the Strategy Tester, since MT5's built-in calendar isn't fully synchronized with historical quotes during backtests. Most production setups end up combining two of these: a cached calendar module for live trading and a CSV fallback for testing.
MT5 economic calendar API and how to query it efficiently
The CalendarValueHistory function returns economic events over a date range as an array of MqlCalendarValue structures, and it supports filtering by country or currency. Each value carries an event_id, time, actual_value, forecast_value, and impact_type, along with a link back to the parent MqlCalendarEvent for the event's importance level.
The catch is that several of these numeric fields use a sentinel value, LONG_MIN, when data hasn't been released yet or isn't available. Skip that check and you risk dividing an uninitialized integer by 1,000,000, since calendar values are stored as scaled long integers rather than plain doubles.
The efficient pattern looks like this:
- On
OnInit, or on a timer that fires every few minutes, callCalendarValueHistoryonce for a window covering the next 24-48 hours and store the results in an array or struct. - Filter that array down to events matching your configured currencies and minimum importance, and compute a blackout start and end time for each one.
- On every tick, or before every order send, run a simple loop or lookup against that cached list, comparing the current server time against the pre-computed windows. No calendar call happens here.
- Refresh the cache on a timer (every 15-30 minutes is common) rather than on every tick, since the calendar rarely changes mid-session.
- Log every state transition (blackout entered, blackout cleared, cache refreshed, cache empty) to the Experts log so you have a record if a trade gets blocked unexpectedly.
This turns an expensive API call into a cheap array lookup at the moment it matters most, right before you'd otherwise send an order. Market libraries such as GWNewsFilterLib follow this same shape, offering Auto, API, and CSV source modes, per-currency file support, configurable seconds before and after an event, separate entry and exit flags, and diagnostic logging levels from 0 to 4, which is a reasonable template if you'd rather not write the caching layer from scratch.
Fallbacks matter too. If the calendar returns an empty array, perhaps because the broker doesn't provide calendar data or the terminal hasn't downloaded it yet, your EA should default to a safe state rather than silently trading through a news window it can't see.
Pro Tip: Log the raw event count and the filtered count separately on every cache refresh; if the filtered count is always zero, your currency or importance filter is wrong, not the calendar feed.
Getting broker time zones and daylight saving right
A hardcoded GMT offset breaks the first time your broker shifts its server clock for daylight saving, and it breaks again if your broker's DST schedule doesn't match your own country's. This is one of the most common reasons a news filter fires at the wrong time or misses the window entirely.
The fix is to compute the offset dynamically rather than assume it:
- Use
TimeTradeServer()alongsideTimeCurrent()to read the broker's actual server time rather than a fixed value. - Compare the calendar's event timestamps against known reference points, such as a symbol's tick history around a previous well-known release, to empirically confirm the offset is correct.
- Recheck that offset periodically, not just once at startup, since some brokers adjust their server clock on different dates than your local jurisdiction.
- If the calendar timestamp and server time diverge in a way that doesn't match any expected DST shift, treat the cache as untrusted and fall back to a conservative wider blackout window.
One of the most reliable fixes is syncing to the broker's own server time and empirically correcting the cache against symbol history, since DST and server-time mismatches are one of the most common failure modes in calendar-based filters. Checking your offset against a liquid pair like EURUSD or a volatile one like XAUUSD around a past NFP release is a quick sanity test that catches most timezone bugs before they cost you a trade.
Setting blackout windows, impact levels, and currency filters
Industry-standard blackout windows for high-impact events commonly range from 15 to 60 minutes, with medium-impact events usually treated more loosely, often 15 to 30 minutes. The right number depends on the event: a Non-Farm Payrolls or FOMC release can move price sharply for several minutes, while a medium-impact regional data print might only need a short pause.
Rather than baking these numbers into your code, expose them as EA inputs so a trader can adjust behavior without recompiling:
PreNewsMinutesandPostNewsMinutes, the minutes before and after an event during which entries are blocked.MinImportance, set to Low, Medium, or High, to control which tier of events triggers the filter.CurrencyList, a comma-separated list so a EUR/USD strategy doesn't get paused by a JPY release.CloseBeforeEvent, a boolean that decides whether the EA also flattens open positions ahead of the blackout, not just blocks new ones.
Whether these settings apply per symbol or account-wide depends on your setup. A single-pair scalper generally wants a tight, symbol-specific filter tied to that pair's currencies. A portfolio EA running several symbols from one chart often needs an account-wide flag instead, since a USD release affects every USD pair at once regardless of which chart triggered the check.
Closing positions outright is the safer choice against slippage, but it also means exiting trades that might have run through the news cleanly. Pausing entries only is less disruptive but leaves open risk exposed to the spread widening that often accompanies a release.
Testing and backtesting your filter without guesswork
The built-in MT5 calendar frequently isn't available inside the Strategy Tester, which means a filter that relies purely on live CalendarValueHistory calls will behave differently in backtests than it does live. This is the single most common reason a news filter passes a demo run but never gets properly validated.
The fix is a hybrid approach:
- Export your live calendar data to a CSV file using a calendar cache tool, capturing event time, currency, and importance for the period you want to test.
- Place that CSV in your terminal's
Common\FilesorMQL5\Filesfolder so both the live terminal and the Strategy Tester can read it. - In
OnInit, detect whether you're running in the tester (MQLInfoInteger(MQL_TESTER)) and, if so, load events from the CSV instead of calling the live calendar. - Apply the same timezone correction to the CSV timestamps that you apply to live data, since a mismatched offset in a cached file produces the same false triggers as a live DST bug.
- Keep the CSV file alongside your test results and document which calendar export and timezone version you used, so the run can be reproduced later.
That last step matters more than it sounds. If a funded account review ever questions why a trade was or wasn't blocked around a news event, having the exact cache file and its timestamp corrections on record turns a dispute into a two-minute lookup.
Prop-firm rules for news trading and how to stay compliant
High-impact releases widen spreads and produce slippage, which is exactly the kind of volatility that trips rule violations on funded accounts, from stop-outs on wider spreads to fills far from the intended price. Prop firms that restrict news trading generally define blackout windows somewhere in the same 15 to 60 minute range seen across market news-filter products, though the exact rule (and whether news trading is even restricted) varies by firm and by account type.
A few practices keep an EA adaptable across firms with different rules:
- Default to a conservative window, such as 30 minutes before and after high-impact events, when a firm's exact rule isn't published or is ambiguous.
- Expose the blackout minutes as inputs rather than constants, so the same compiled EA can run under a stricter firm's rules without a rebuild.
- Treat
MinImportanceas a per-account setting too, since a firm that only restricts high-impact events shouldn't be blocked by a medium-impact filter tuned for a stricter one. - Keep an append-only log of every blackout entered, cleared, or overridden, including the server timestamp, so a compliance review has a clear record of the EA's behavior.
Pro Tip: Write your filter's log entries to a dedicated file rather than mixing them into general EA logs; a reviewer looking for news-related activity shouldn't have to scroll past every routine trade entry to find it.
Integration checklist and defensive coding patterns
Getting from a working prototype to something you'd trust on a funded account comes down to a short sequence of decisions, each one closing a gap the last one left open.
Start with the checklist:
- Pick your data source first: live calendar, CSV cache, or both, depending on whether you need tester determinism.
- Build the cache-refresh routine before anything else touches the calendar, so every downstream check reads from the same array.
- Expose your inputs (
PreNewsMinutes,PostNewsMinutes,MinImportance,CurrencyList,CloseBeforeEvent) before you hardcode a single value. - Implement the O(1) runtime check that every order-sending function calls before it fires.
- Write the closure routine separately from the entry-block routine, since they're triggered by different conditions and shouldn't share logic just because they both react to news.
- Add diagnostic logging at every state change, not just when something fails.
Performance-wise, the biggest mistake is calling anything expensive on every tick. Cache updates should run on a timer, not per tick, and a WebRequest call to an external calendar source per tick will choke a terminal running multiple charts. A GlobalVariable flag or the terminal's AlgoTrading toggle is a far lighter way for multiple EAs to check filter state than each one independently querying the calendar. Treating news filtering as a form of market regime control, something checked cheaply and often rather than computed expensively and rarely, keeps a scalper's execution speed intact.
On the defensive side, always check for LONG_MIN before scaling a numeric calendar field, validate that a loaded CSV actually has the expected column count before parsing it row by row, and make sure OnDeinit re-enables AlgoTrading if your guardian EA disabled it, since a guardian that disables trading and never restores it is worse than having no filter at all. For reproducibility, ship the cache file used in any backtest alongside your test report, with its timezone-correction version noted, so someone else running the same test gets the same result.
When to use a built-in calendar module versus a standalone guardian

The right architecture depends less on preference than on how your EAs are actually deployed. Scalpers and high-frequency setups benefit most from an integrated, in-EA cache module, since it's deterministic, avoids inter-process coordination, and keeps latency low with no separate EA to babysit.
Traders running several EAs across many charts are usually better off with a standalone guardian that writes a single GlobalVariable flag. It's simpler to reason about than syncing calendar logic across a dozen chart windows, and it fails in one predictable place instead of several.
For anyone backtesting seriously, or documenting results for a funded-account review, the CSV cache approach isn't optional. It's the only path that gives a reproducible run.
If you only take one recommendation from this: build the cache module first regardless of architecture, then decide whether it lives inside your EA or inside a guardian based on how many robots you're actually running.
— Jean
Practice news-aware EAs on a simulated funded account
Once your filter logs clean transitions on a demo, the next test is running it against real broker time on an account that doesn't penalize you for news exposure while you're still debugging. Simulated MT5 funded accounts that explicitly allow EAs, algorithmic trading, news trading, and weekend holding can be a practical place to validate a news filter's real-world timing without the position-size limits of a plain demo.

Two entry points fit this particular use case well:
- The Free1K simulated trial gives you a $1,000 account with no card and no deposit, enough to confirm your filter's blackout windows trigger correctly against live broker time.
- Pay After Pass starts an evaluation for $9.99, with the remaining base fee of $515.01 due only if you pass, a lower-commitment way to run a fuller test if you want a larger simulated account than the free trial offers.
Attach your EA with the filter enabled, let it run through a scheduled high-impact release, and check the logs: did the blackout trigger on time, did AlgoTrading toggle correctly, did the cache refresh as expected. That's the same evidence a funded-account review would want to see, and it's worth having before you're running for real money on the line. See the full range of account packages and sizes if you'd rather start with a specific evaluation type from the outset.
Primary sources and developer references
For anyone building or auditing a filter, these are worth bookmarking directly:
- CalendarValueHistory in the official MQL5 reference, the core API for querying calendar events by country or currency.
- CalendarValueHistoryByEvent documentation, covering scaled numeric fields and the
LONG_MINsentinel. - GWNewsFilterLib on the MQL5 Market, a library implementing CSV, API, and Auto source modes with diagnostic logging.
- Watchman News Filter and Drawdown Guard, an example of configurable blackout windows tied to prop-firm-style rules.
- For execution-quality context around news volatility, this breakdown of common causes of bad fills is a useful companion read.
Sources
- CalendarValueHistory - Economic Calendar - MQL5 Reference
- GW News Filter — trading library (market)
- Watchman News Filter and Drawdown Guard (market)
- Economic Calendar Monitor and Cache for Backtesting on History
FAQ
What does an EA news filter actually do in MT5?
An EA news filter checks upcoming high-impact economic events and blocks new trade entries, and sometimes closes open positions, during a configured window around each event. It typically reads the MT5 economic calendar or a cached CSV export rather than querying live data on every tick.
How do I handle timezone differences between the calendar and my broker?
Compute your broker's actual offset using TimeTradeServer() rather than hardcoding a GMT value, since DST changes are a common source of mismatched trigger times. Cross-checking that offset against a symbol's historical ticks around a past release is a reliable way to confirm it's correct.
Why doesn't the news filter work correctly in the Strategy Tester?
The built-in MT5 calendar often isn't fully available inside the Strategy Tester, so filters relying only on live calendar calls behave inconsistently in backtests. The standard fix is exporting calendar events to a CSV cache and loading that file during OnInit when a tester run is detected.
How wide should my pre-news and post-news blackout windows be?
Industry-standard windows for high-impact events commonly range from 15 to 60 minutes before and after the release, with medium-impact events often using a shorter 15 to 30 minute window. Exposing these as EA inputs rather than fixed values lets you tune them per prop firm or strategy without recompiling.
Can I trade news with an EA on a FundedAxe simulated account?
Yes, FundedAxe simulated accounts allow news trading, weekend holding, and algorithmic EAs, which makes them suitable for testing a news filter's real-time behavior. You can start with the free $1,000 simulated trial or the $9.99 Pay After Pass evaluation before committing to a larger account size.
