High-impact news events are responsible for a disproportionate share of prop firm breaches. Spreads spike, slippage multiplies, and stop levels become unreliable in the seconds around NFP, CPI, or central bank decisions. A strategy that performed cleanly in backtests can blow a challenge in a single candle.

Some firms ban news trading outright. FTMO prohibits opening or closing positions within two minutes of a high-impact event. Others restrict it on certain account types or pairs. Even firms with no explicit rule benefit from a news filter because the underlying volatility risk is real regardless of the policy. This guide covers two practical methods for adding a news filter to your MQL5 EA: the built-in economic calendar approach and the simpler time-based approach.

Why Your EA Needs a News Filter

An EA running without a news filter is exposed to conditions it was never backtested on. Historical tick data does not accurately reproduce the spread widening and liquidity gaps that occur during major releases. A 1.5-pip average spread on EURUSD can jump to 15 pips during NFP. Any pending order, stop loss, or take profit placed at a "normal" distance will execute at a completely different level.

The practical impact on a prop firm challenge is severe. A single news-related spike can consume several percent of your drawdown limit in seconds, not because the strategy failed but because the execution environment was temporarily broken. Adding a filter that halts trading for a window around high-impact events is one of the most reliable risk improvements you can make to any EA running on a prop account.

The Two Main Approaches

MQL5 Economic Calendar

  • Built into MT5, no external dependencies
  • Automatically fetches upcoming events
  • Filter by impact level and currency
  • Works in live trading and forward testing
  • Cannot be used in standard backtesting
  • Requires internet access on the terminal

Time-Based Blocking

  • No external data needed
  • Works in backtesting and live trading
  • You define fixed weekly schedule of blocked windows
  • Simple to implement and audit
  • Requires manual updates when schedules change
  • Better for firms requiring demonstrable compliance

For most prop firm contexts the time-based approach is the more practical choice. It works in the Strategy Tester, it is easy to verify, and the major recurring events (NFP on first Friday, FOMC on fixed schedule, CPI on monthly cycle) are predictable enough that a maintained schedule covers the bulk of the risk. The calendar method is more powerful but adds complexity and does not backtest.

Method 1: MQL5 Economic Calendar

MT5 includes a built-in economic calendar API through the CalendarValueHistory() and CalendarValueRange() functions. You query upcoming events filtered by currency and impact level, then block trading during a window around any matches.

MQL5: Calendar-based news filter function
// Input parameters (set these in the EA inputs section)
input int  NewsMinutesBefore = 30;   // Minutes to pause before event
input int  NewsMinutesAfter  = 30;   // Minutes to pause after event
input bool FilterHigh        = true; // Block high-impact events
input bool FilterMedium      = false;// Block medium-impact events

// Returns true if current time is inside a news window
bool IsNewsTime()
{
   MqlCalendarValue values[];
   datetime from = TimeCurrent() - NewsMinutesBefore * 60;
   datetime to   = TimeCurrent() + NewsMinutesAfter  * 60;

   // Get currency code from the chart symbol
   string base  = SymbolInfoString(_Symbol, SYMBOL_CURRENCY_BASE);
   string quote = SymbolInfoString(_Symbol, SYMBOL_CURRENCY_PROFIT);

   int count = CalendarValueRange(values, from, to);

   for(int i = 0; i < count; i++)
   {
      MqlCalendarEvent event;
      if(!CalendarEventById(values[i].event_id, event))
         continue;

      // Skip if not related to our symbol's currencies
      MqlCalendarCountry country;
      CalendarCountryById(event.country_id, country);
      if(country.currency != base && country.currency != quote)
         continue;

      // Check impact level
      bool isHigh   = (event.importance == CALENDAR_IMPORTANCE_HIGH);
      bool isMedium = (event.importance == CALENDAR_IMPORTANCE_MODERATE);

      if((FilterHigh && isHigh) || (FilterMedium && isMedium))
         return(true);
   }
   return(false);
}

Call IsNewsTime() at the top of your OnTick() function and return early if it returns true. This prevents new trade entries during any matched window. To also block closing positions during news, apply the same check before any trade management code.

MQL5: Usage in OnTick()
void OnTick()
{
   // Block new entries during news windows
   if(IsNewsTime())
      return;

   // ... rest of your EA logic here
}

One important limitation: CalendarValueRange() requires the terminal to have a live connection and the calendar data to be downloaded. In the Strategy Tester this function returns zero results, so the filter will have no effect during backtests. If you need the filter to work in testing you need the time-based approach below.

Method 2: Time-Based Blocking

The time-based approach encodes a weekly schedule of blocked windows directly in the EA. You specify day-of-week and time windows that the EA will always skip, regardless of what the live calendar says. This works in the Strategy Tester and is easier for a prop firm compliance review because the logic is deterministic and auditable.

MQL5: Time-based news filter
// Input parameters
input bool UseNewsFilter = true;

// Structure for a blocked time window (server time)
struct NewsWindow
{
   int dayOfWeek;  // 0=Sun, 1=Mon, ..., 5=Fri
   int startHour;
   int startMin;
   int endHour;
   int endMin;
};

// Define your blocked windows (server time, adjust to match your broker's timezone)
NewsWindow BlockedWindows[] =
{
   // US Non-Farm Payrolls: first Friday of each month, 13:25-14:00 UTC
   {5, 13, 25, 14, 0},
   // US CPI: variable Tuesday, 13:25-14:00 UTC
   {2, 13, 25, 14, 0},
   // FOMC decision: every 6 weeks Wednesday, 18:55-19:30 UTC
   {3, 18, 55, 19, 30},
   // ECB rate decision: every 6 weeks Thursday, 13:10-14:00 UTC
   {4, 13, 10, 14, 0}
};

bool IsBlockedTime()
{
   if(!UseNewsFilter) return(false);

   MqlDateTime dt;
   TimeToStruct(TimeCurrent(), dt);

   int totalWindows = ArraySize(BlockedWindows);
   for(int i = 0; i < totalWindows; i++)
   {
      if(dt.day_of_week != BlockedWindows[i].dayOfWeek)
         continue;

      int nowMins   = dt.hour * 60 + dt.min;
      int startMins = BlockedWindows[i].startHour * 60 + BlockedWindows[i].startMin;
      int endMins   = BlockedWindows[i].endHour   * 60 + BlockedWindows[i].endMin;

      if(nowMins >= startMins && nowMins <= endMins)
         return(true);
   }
   return(false);
}

The main weakness of this approach is that high-impact events do not always fall on the same day of week each month. NFP is always the first Friday, but CPI and FOMC rotate. You either block that time window every week on that day (accepting some false positives on off-weeks) or maintain a separate dated list. For most traders the conservative option is to block that window every week. The cost is a few missed trades per month on non-event days.

Making the Filter Configurable

Hard-coding window sizes makes the filter inflexible. The right buffer depends on the prop firm's rule. FTMO requires 2 minutes either side, while other firms use 5 or 10-minute windows. Expose the buffer as an input parameter so you can set it per-account without recompiling the EA.

MQL5: Configurable buffer inputs
input int  NewsBufferMinutes = 5;   // Minutes to block before and after event
input bool CloseOnNewsEntry = false; // Close open trades when news window starts
input bool UseNewsFilter    = true;  // Master switch, disable for firms with no restriction

The CloseOnNewsEntry parameter is worth considering carefully. Most firms with news rules prohibit opening and closing within the window, not holding through it. Closing existing trades before the window starts adds unnecessary slippage and commission. Leave this false unless your firm's rules specifically require it, and verify the exact wording on their official website before deciding.

Testing Before Live Trading

1

Print filter state to the log

Add a Print("NEWS FILTER ACTIVE") statement inside the blocked condition and run the EA on a demo account through a known news event. Verify the log shows the filter activating at the right time and clearing afterwards.

2

Visual confirmation with a panel

Display the filter state on the chart using ObjectCreate() with a text label. A simple "NEWS BLOCK" label in red that appears and disappears is far easier to monitor than reading terminal logs during live trading.

3

Forward test through a news event

Run on a demo account for at least two weeks before using the filter on a challenge. Confirm it blocks entries during the targeted events and does not interfere with normal trading hours. Check that the window clears correctly after the event ends.

4

Verify timezone alignment

MT5 uses server time, not local time. Your broker's server timezone may differ from UTC by several hours. Print TimeCurrent() and compare it to a world clock during a known event to confirm your window times are correct. A one-hour offset here will render the filter useless.

Timezone is the most common failure point

A news filter set to 13:30 UTC will fire at the wrong time if your broker's server runs on UTC+2. Always print server time and verify it against a reference clock before relying on any time-based filter in live conditions.

Which Firms Require a News Filter

Prop firm news rules vary significantly. FTMO has the most explicit restriction: no opening or closing within two minutes of a high-impact event on standard accounts. The Swing account is exempt from this rule, which makes it a popular choice for EAs that trade around news.

FundedNext restricts news trading on the Stellar model to within 2 minutes of high-impact events on the same currency pair. The Express model has no news restriction. Blue Guardian, Blueberry Funded, and Bright Funded currently have no published news trading prohibition, but rules change. Verify on the official website before you start a challenge.

Even on firms with no news restriction, running a filter is good practice. The volatility exposure is real regardless of the policy, and a single bad execution during NFP can set back a challenge by days of careful trading.

For a full breakdown of which firms allow news trading and which restrict it, see the MT5 prop firms with no news restrictions guide.

See which prop firms have the most EA-friendly news rules

Compare All Prop Firms →

Related: How to pass a prop firm challenge with an EA. Covers risk sizing, drawdown management, and what to monitor during the challenge.