Advertisement IC Markets

Spread filters in EAs: current spread, average spread, or both?

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
Fairman
Posts: 3303
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Spread filters in EAs: current spread, average spread, or both?

Post by Fairman »

Spread filters in EAs: current spread, average spread, or both?

Almost every scalping EA needs a spread filter. If the spread is too wide, the trade's cost eats too much of the expected move. The question is which spread to check.

Checking the current spread right before entry is the most direct. If it's above your limit, skip. The problem is that spread can flicker. A momentary spike on one tick can block a valid entry, and a momentary dip can let a trade through right before the spread widens again.

Using an average spread over the last few minutes smooths that out and gives a better picture of conditions. But it reacts slowly. If spreads blow out suddenly around news, the average might still look fine for a while.

What I use is both. The EA checks that the current spread is under a hard limit, so it never enters during an obvious spike, and that the recent average is under a softer limit, so it doesn't trade in generally poor conditions. Setting those limits is easier if you've logged spread data from your broker at different times of day.

One more point: the spread limit should probably vary by session. A limit that suits London will block almost everything in Asia, and one that suits Asia is too loose for London. Per session limits fit how spreads actually behave.
It’s Fairman :geek:
Recommended broker for automated trading & scalping IC Markets
Fairman
Posts: 3303
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Spread filters in EAs: current spread, average spread, or both?

Post by Fairman »

If you're backtesting, check how the tester handles spread. MT4's tester often uses a fixed spread unless you use custom tick data, which means your spread filter never actually triggers in the backtest. The results then show trades that would have been blocked live, and the filter looks like it has no effect. MT5 can use real tick spreads with the right data. Make sure the spread filter actually fires in testing, otherwise you can't judge whether it's set at a sensible level. A quick check is to look at the decision log or a print statement and count how often the filter blocked a trade in the test. If the answer is zero, the filter isn't being tested.
It’s Fairman :geek:
Fairman
Posts: 3303
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Spread filters in EAs: current spread, average spread, or both?

Post by Fairman »

Another thing to think about is what the spread filter does with exits. Most EAs only filter entries, which makes sense. But if the EA closes positions at a fixed time or on a signal, closing during a spread spike can cost more than the trade made. Some EAs delay non-urgent exits until spread is back to normal, with a time limit so they don't hold too long. It's not right for every strategy, but worth considering if your exits are based on time rather than price. For time based exits, even a short delay of a minute or two can avoid the worst of a rollover spike.
It’s Fairman :geek:
Post Reply