Advertisement IC Markets

A spread filter in an EA: fixed threshold or relative to normal?

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
FXS London Scalper
Posts: 976
Joined: Sun Oct 18, 2026 12:25 pm

A spread filter in an EA: fixed threshold or relative to normal?

Post by FXS London Scalper »

Most EAs use a fixed maximum spread, for example 1.0 pip. A relative filter, compared with the normal spread at that hour, can be more useful.

Fixed filter:
  • Simple to understand and test.
  • May block too much in Asia, when spreads are normally wider, and too little at the London open.
Relative filter:
  • Compares the current spread with a typical value for the hour, for example the median of the last few weeks.
  • Blocks entries when the spread is more than a multiple, for example 1.5 times normal.
  • Needs data to build the typical values, and updating.
A combined version: block if above a hard cap, or above 1.5 times normal for the hour, whichever is lower.

How to test: log what the filter would have blocked, with what the trade would have done. If blocked trades were noticeably worse, the filter is earning its place.

Whichever version is used, log every block, so you can later see what the filter cost or saved.

Which approach do you use?
FXS Official Team | London Session Desk
Recommended broker for automated trading & scalping IC Markets
Shadow Trader
Posts: 5594
Joined: Wed Sep 09, 2026 5:19 pm

Re: A spread filter in an EA: fixed threshold or relative to normal?

Post by Shadow Trader »

The combined version at the end is the one that makes the most sense to me, because each approach on its own has an obvious failure case. A fixed cap alone is either too loose during the London open or too strict in Asia, and a relative filter alone can happily let you trade when the spread is 1.5 times a "normal" level that is already expensive for your strategy.

One detail that's easy to miss with the relative version is how the typical value gets built. If the median for each hour comes from the last few weeks, a run of unusually wide spreads, such as around a holiday or a period of heavy news, will slowly raise the baseline, and the filter becomes more permissive exactly when conditions are worse. Using a longer window, or capping how far the baseline can move from a fixed reference, helps with that.

It's also worth thinking about when the filter is checked. Checking the spread only at the moment the signal fires can let an entry through on a single good tick in the middle of a period that's otherwise wide. Some people require the spread to have been under the threshold for a few seconds, or for a set number of ticks, before allowing the entry. That costs a few signals but tends to remove the worst fills.

And the suggestion to log what the filter would have blocked is probably the most valuable part. Without that, there's no way to tell whether the filter is saving money or just removing good trades along with the bad.
Amanhasnoname
Posts: 2060
Joined: Fri Oct 30, 2026 9:45 am

Re: A spread filter in an EA: fixed threshold or relative to normal?

Post by Amanhasnoname »

A relative filter makes sense for scalping because the cost of a trade depends on the spread compared with what your edge was built on, and that edge was measured at normal conditions for that hour. The combined version is a good default, but I would also tie the hard cap to the strategy itself, for example a fraction of the average target, so a system aiming for three pips and one aiming for ten do not share the same limit.

When building the hourly baseline, use the median rather than the mean, and sample the spread at regular intervals instead of per tick, since busy minutes produce far more ticks and would otherwise dominate the figure. Keep separate baselines for Mondays and for days with scheduled news if you trade near releases, because those hours are structurally wider and would distort an ordinary day.

The pitfall to watch is the moment just after a block lifts. Spreads often snap back to normal briefly while liquidity is still thin, so an entry that passes the filter can still fill poorly. Comparing the expected entry with the actual fill on trades taken within a minute of a block is a simple way to see whether a short cooldown would help.
Post Reply