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.
Spread filters in EAs: current spread, average spread, or both?
Re: Spread filters in EAs: current spread, average spread, or both?
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 
Re: Spread filters in EAs: current spread, average spread, or both?
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 
Re: Spread filters in EAs: current spread, average spread, or both?
Another option is a filter based on the spread relative to the expected move. If the strategy targets ten pips, a spread of two pips is twenty percent of the target. If it targets fifty pips, the same spread is only four percent. A filter like 'spread less than fifteen percent of the target' adjusts automatically for different pairs and different target sizes. It's a bit more logic, but it makes the filter more meaningful than a fixed pip number. It also stops the filter from being too strict on pairs with naturally wider spreads but bigger moves.
It’s Fairman 
-
FXS Prop Desk
- Posts: 1689
- Joined: Wed Oct 07, 2026 9:52 am
Re: Spread filters in EAs: current spread, average spread, or both?
Using both is usually the best approach. The current spread prevents entries at a bad moment, and the average spread gives a sense of normal conditions for the time of day. A trade is skipped if the current spread is above a multiple of the average.
The average should be calculated for the same time of day, not the last few minutes. Otherwise, a wide spread that lasts for a while becomes the new average and the filter stops working.
The average should be calculated for the same time of day, not the last few minutes. Otherwise, a wide spread that lasts for a while becomes the new average and the filter stops working.
FXS Official Team | The Idea Lab & Strategy
-
Shadow Trader
- Posts: 5594
- Joined: Wed Sep 09, 2026 5:19 pm
Re: Spread filters in EAs: current spread, average spread, or both?
Writing a spread logger takes about twenty lines in most languages. Connect to the platform, ask for the current bid and ask once a second for a list of pairs, and append the time, the pair and the spread to a file.
After two weeks, a heatmap of spread by pair and time of day appears, and it answers questions that no review site can:
- Exactly when does the spread start widening before rollover?
- Which pairs are worth trading in Asia, and from what time?
- How much does the spread jump around news, and for how long?
- Is the advertised average spread the same as the average at the hours actually traded?
- Does the broker widen the spread at specific times, such as the top of the hour?
Run the same logger on two brokers at once and the comparison is direct and fair.
The file is also useful later. Any trade can be matched with the spread at that moment, and the cost of each entry becomes visible.
It needs to run on a stable machine, ideally the same VPS used for trading, so gaps in the log are not caused by a sleeping laptop.
Has a spread log ever shown something unexpected about a broker?
After two weeks, a heatmap of spread by pair and time of day appears, and it answers questions that no review site can:
- Exactly when does the spread start widening before rollover?
- Which pairs are worth trading in Asia, and from what time?
- How much does the spread jump around news, and for how long?
- Is the advertised average spread the same as the average at the hours actually traded?
- Does the broker widen the spread at specific times, such as the top of the hour?
Run the same logger on two brokers at once and the comparison is direct and fair.
The file is also useful later. Any trade can be matched with the spread at that moment, and the cost of each entry becomes visible.
It needs to run on a stable machine, ideally the same VPS used for trading, so gaps in the log are not caused by a sleeping laptop.
Has a spread log ever shown something unexpected about a broker?
Re: Spread filters in EAs: current spread, average spread, or both?
How long the spread has been wide matters too. A spread that widens for a second and comes back is different from one that stays wide for several minutes. Some EAs use a spread filter that requires the spread to be normal for a certain number of seconds before entering. That avoids entering just as the spread narrows briefly in the middle of a volatile period. It's easy to add with a timer that resets whenever the spread goes over the limit. A few seconds is usually enough to avoid the worst of it, and it barely changes the number of trades.
It’s Fairman 