Sharing the logic of the spread and news filters I use in my EURUSD M1 EA. Not full code, but enough to adapt.
Spread filter
Keep a rolling median of the spread over the last 300 ticks.
Block new entries if the current spread is above 2× the median, or above an absolute cap of 0.8 pips.
Store each block event in a log with time and spread value.
The median instead of the average stops one spike from inflating the baseline.
News filter
A CSV file with events, time in UTC and an impact tag, updated weekly.
For high impact: block from 10 minutes before to 20 minutes after.
For medium: 2 minutes before to 5 after.
A sanity check: if the file is older than 8 days, the EA refuses to trade and alerts me.
Why both
The news filter catches scheduled risk. The spread filter catches unscheduled stuff: sudden headlines, liquidity holes, rollover.
In three months, the spread filter blocked about 3% of signals, and roughly half of those were outside any news window. That half is why I wouldn't run on the news filter alone.
How do others implement these filters? Anyone using the MT5 built-in calendar instead of a CSV?
FXS London Scalper wrote: Wed Oct 28, 2026 7:55 am
Sharing the logic of the spread and news filters I use in my EURUSD M1 EA. Not full code, but enough to adapt.
Spread filter
Keep a rolling median of the spread over the last 300 ticks.
Block new entries if the current spread is above 2× the median, or above an absolute cap of 0.8 pips.
Store each block event in a log with time and spread value.
The median instead of the average stops one spike from inflating the baseline.
News filter
A CSV file with events, time in UTC and an impact tag, updated weekly.
For high impact: block from 10 minutes before to 20 minutes after.
For medium: 2 minutes before to 5 after.
A sanity check: if the file is older than 8 days, the EA refuses to trade and alerts me.
Why both
The news filter catches scheduled risk. The spread filter catches unscheduled stuff: sudden headlines, liquidity holes, rollover.
In three months, the spread filter blocked about 3% of signals, and roughly half of those were outside any news window. That half is why I wouldn't run on the news filter alone.
How do others implement these filters? Anyone using the MT5 built-in calendar instead of a CSV?
Hi,
This is a brilliantly engineered setup. Using a rolling median for the spread filter rather than a simple moving average is exactly how you prevent a single volatile tick from skewing your baseline. Your observation that half of your blocked trades occurred completely outside of scheduled news windows perfectly highlights the reality of unscheduled liquidity vacuums.
That said, reading through your logic actually reinforces exactly why I eventually abandoned the M1 timeframe entirely. For my own EAs, the juice simply isn't worth the squeeze when it comes to M1 market noise.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Here is why I stepped away from the 1-minute charts and why the "noise" factor ultimately breaks most retail M1 systems:
The Mathematics of M1 Noise and Transaction Costs
On an M1 chart, structural price action is virtually non-existent. A 2-pip sudden movement isn't a shift in market sentiment; it is just a random algorithmic block order clearing out local liquidity. Because the average true range (ATR) of a single M1 candle is so small, your expected profit per trade is inherently compressed.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
If your EA is targeting, say, 3 to 5 pips of profit, your absolute cap of a 0.8 pip spread is actually a massive hurdle. Add in broker commissions and potential slippage, and your transaction costs are easily eating 25% to 40% of your gross expected payout on every single winning trade. On higher timeframes like M15 or H1, a 0.8 pip spread is a rounding error. On M1, it is a structural barrier to long-term positive expectancy.
The Illusion of Execution Speed
Your spread filter catches the visible widening, but M1 noise also includes invisible execution latency and slippage. When those unscheduled liquidity holes happen—the ones your filter caught 1.5% of the time—the spread doesn't just widen; the order book thins out. If your EA attempts to fire an order in that exact millisecond before the median spread updates, you get filled with negative slippage. The M1 timeframe requires you to fight high-frequency trading (HFT) algorithms on their home turf, and retail infrastructure usually loses that battle.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
To answer your final question: yes, absolutely make the jump to the built-in MT5 calendar if you are coding in MQL5. I used to use the exact same CSV method (downloading from ForexFactory or similar every Sunday), but the native MQL5 calendar functions (CalendarEventHistory or CalendarValueHistory) are vastly superior.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Here is why the native MT5 calendar beats the CSV approach:
Zero Maintenance: You never have to worry about your 8-day sanity check triggering because you forgot to update the file or were away on vacation. The terminal pulls the data directly from the broker/MetaQuotes servers in real-time.
Dynamic Updates: If a central bank unexpectedly schedules a speech, or a data release is delayed, the MT5 calendar updates dynamically. Your static CSV will be blind to these mid-week changes.
Timezone Bulletproof: The native functions automatically handle the offset between the event time, your local PC time, and the broker's server time (which often shifts with daylight saving time). Dealing with UTC offsets manually in a CSV is a notorious source of EA bugs.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Your filtering logic is incredibly sound and clearly well-tested. If you ever port this exact same EA logic—the median spread filter and the strict news blocking—to an M15 or H1 chart, you might find that the signal-to-noise ratio improves exponentially, and the spread stops being a primary threat to your edge.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.