News Filter for MT5 EA — No Code

Why EAs need a news filter, how to code one with the MQL5 Economic Calendar, and what the builder's spread, session and time filters can and cannot cover.

📖 5 min read

📝 955 words

🏷️ MQL5 and Expert Advisors

Share this article:

News Filter for MT5 EA — No Code

Can you add a news filter to an MT5 EA without coding?

Not yet. The MT5 Strategy Builder has no news or economic-calendar filter; news and fundamental filters are not available yet. Its Step 4 filters are sessions, time ranges, spread, correlation and your own conditions (up to 8 filters). None of them reads the calendar.

A true news blackout ("no new trades while a high-impact USD event is near") needs MQL5 code that reads the Economic Calendar: write it by hand, or add it to the .mq5 you export from Code Generator. The builder's spread and time filters can soften news risk, but they are not a news filter (see below). For prop-firm rule context, see Prop Firm EA Rules.

Related guides: Advanced EA MTF & Filters · Convert Manual Strategy to EA · Prop Firm EA Rules (FTMO) · Scalping EA


Why News Filters Matter for EAs

Manual traders often stand aside before NFP, CPI, or central-bank decisions. An EA without that habit will:

  • Enter into spread spikes and slippage
  • Hit stop loss on wicks that do not repeat in backtest
  • Breach prop firm news rules even when the strategy behaves well in quiet hours

MetaQuotes documents calendar access in MQL5 via Calendar functions [1]. That is where a real news filter lives.


Economic Calendar in MQL5

A hand-written news blackout usually follows these steps before each new entry:

  1. Call CalendarValueHistory [2] for a window around now (for example 30 minutes before to 30 minutes after), filtered by the currencies of your symbol (EURUSD → USD and EUR).
  2. For each value, read the event with CalendarEventById and keep only high-importance events (CALENDAR_IMPORTANCE_HIGH).
  3. If any remain, skip the entry. Open positions keep their stop loss; the filter only gates new trades.
MqlCalendarValue values[];
datetime now = TimeTradeServer();
if (CalendarValueHistory(values, now - 30 * 60, now + 30 * 60, NULL, "USD") > 0)
  {
   for (int i = 0; i < ArraySize(values); i++)
     {
      MqlCalendarEvent ev;
      if (CalendarEventById(values[i].event_id, ev) && ev.importance == CALENDAR_IMPORTANCE_HIGH)
         return;   // high-impact USD event in the window: no new entry
     }
  }

Gold (XAUUSD) tip: USD events often move gold as much as FX — check USD even on XAUUSD charts. See Gold RSI EA.


What the Builder Can Filter Instead

These Step 4 filters exist in the MT5 form. They help around news, but none of them knows the calendar:

FilterWhat it doesLimit around news
SpreadSkips entries when the spread is above your limitReacts to the spread after it widens, not to the scheduled event
Time rangeAllows or blocks a fixed time window on the weekdays you pickApplies the same window every selected weekday, not only on event days
Market sessionTrades only the sessions you chooseMajor releases often fall inside London / New York
Your own ATR conditionSkips entries when volatility is outside your rangeReacts after volatility rises

Use them as a first layer; add the calendar check in MQL5 if your strategy or your prop firm requires a real blackout.


Combine Session, Spread, and News

FilterBlocksWhere
Market sessionQuiet Asian hours if you only trade London/NYBuilder, Step 4
SpreadWide spread around rollovers and releasesBuilder, Step 4
Economic Calendar checkScheduled high-impact releasesYour MQL5 code

Full filter patterns: Advanced EA MTF & Filters.

Prop / FTMO builds: The rules live in Prop Firm EA Rules (FTMO), not duplicated here.


Export, Compile, Backtest Limits

  1. Strategy Tester: Every tick, realistic spread, 6–12 months.
  2. Compare trade count with vs without the news check — entries should drop on event-heavy weeks.
  3. Forward test on Demo through at least one known release week.

Honest limit: Historical calendar data in the Tester may be missing, or may not match broker server time or later revisions. Treat backtest as logic validation, not proof of prop compliance.

Hand-coded calendar patterns: Prop Firm EA Rules — News Filter.


Next Steps

GoalLink
Automate full manual playbookConvert Manual Strategy to EA
Firm drawdown + news code (FTMO-style)Prop Firm EA Rules (FTMO)
Platform overviewBuild EA Without Coding

News hour test: Note the next high-impact USD event on your calendar. Run your EA on Demo through it and check the journal: if a new trade opened inside your blackout window, fix the calendar check before going live; a news guard that silently fails is worse than none.

Frequently Asked Questions

Not yet. The MT5 Strategy Builder has no news or economic-calendar filter; news and fundamental filters are not available yet. Its Step 4 filters are sessions, time ranges, spread, correlation and your own conditions. A true news blackout needs MQL5 code that reads the Economic Calendar, written by hand or added to the exported .mq5 in MetaEditor.

CalendarValueHistory returns the calendar values for a time range, country and currency; CalendarEventById gives each event's importance. Block new entries while a high-importance event for your symbol's currencies is within your window.

No. Historical calendar data in the Tester may be missing or differ from live, and broker spreads around releases differ too. Use Tester for logic checks, then Demo around real releases. Read Backtest an EA in the MT5 Strategy Tester.

Prop Firm EA Rules explains firm limits and MQL5 Calendar API code patterns. This article explains why news filters matter, the calendar logic, and what the builder's own filters can and cannot cover.

In MQL5, yes: check that the event's importance is CALENDAR_IMPORTANCE_HIGH before blocking. The AlfaTactix builder has no calendar or impact setting.

Only partly. A spread filter skips entries when the spread widens, which often happens around releases, but it reacts to the spread, not the calendar. A time-range filter blocks the same window on every selected weekday, not only on event days.

References

  1. MetaQuotes, MQL5 Reference. Economic calendar functions. https://www.mql5.com/en/docs/calendar
  2. MetaQuotes, MQL5 Reference. CalendarValueHistory. https://www.mql5.com/en/docs/calendar/calendarvaluehistory