How to Add a Spread Filter to Your EA
Spread is the only trading cost you can measure before committing. Slippage arrives afterwards and swap accumulates later, but spread is visible at the decision.
How to add a spread filter to your EA is one of the cheapest improvements available to an automated strategy, provided the threshold is set on the right basis.
Why It Matters More to an EA
A human notices a wide spread and hesitates. An EA notices nothing it was not told to check, so it sends the order at four times the normal cost without registering the change.
Backtests worsen this. Most testing applies a fixed or modelled spread that live conditions do not supply, so a strategy can look profitable in testing and lose live purely on entry costs.
A filter closes that gap by refusing to trade when the cost exceeds what the strategy was validated on.
Set the Threshold Against Your Target
Here is the design decision most implementations get wrong.
Traders typically pick a threshold in pips, chosen by feel and applied to everything.
The meaningful quantity is spread as a share of what you are capturing. One pip against a fifteen pip target consumes almost seven percent of the move. The same pip against a hundred pip target consumes one percent.
So express the filter as a percentage of your target rather than an absolute figure. A strategy with varying targets then gets a threshold that adapts, and the same filter works across instruments with different typical spreads.
Decide what proportion of a target you will surrender at entry and derive the pip value from it.
Filter Entries, Never Exits
This matters and it is a safety point rather than a performance one.
A filter applied indiscriminately prevents you closing a position in exactly the conditions where you most want out.
Apply it to entries only. An exit should execute whatever the spread is doing, because the alternative is holding through a widening you cannot escape.
Check your code for this. A single condition wrapped around all order sending is the easy mistake.
It Doubles as a News Filter
A useful side effect worth naming.
Spread widens ahead of releases as liquidity providers reduce risk, so a spread filter blocks entries around major events without knowing anything about the calendar.
That is condition based rather than event based. No feed to maintain, no list to update, and it responds to unscheduled volatility too.
For many strategies it provides most of what a dedicated news filter would, at a fraction of the complexity.
Log Every Rejection
A filter that silently blocks trades is invisible in your results.
Record each rejection with the timestamp, the spread observed, the threshold applied and the signal that would have been taken. Without it you cannot tell a quiet session from one where the filter rejected everything.
With it you can answer the question that matters. Were the blocked trades disproportionately losers, or did the filter remove winners too? If the rejected set would have been profitable, the threshold is too tight.
Check It Against Your Own Feed
Spread differs between brokers because each aggregates different liquidity. A threshold tuned on one platform may be wrong on another, and a filter imported with a strategy from elsewhere carries assumptions from a feed you are not using.
Measure your own typical spread by session before setting the number.
Conclusion – How to Add a Spread Filter to Your EA
How to add a spread filter to your EA comes down to expressing the threshold as a share of your target, applying it to entries only, logging every rejection so the filter is measurable, and tuning it against the spread your own broker actually delivers.
FAQ – How to Add a Spread Filter to Your EA
1. What spread threshold should I use?
Derive it from your target rather than picking a pip figure. Decide what share of the move you will surrender at entry.
2. Should the filter apply to closing trades?
No. Blocking exits during wide spread traps you in positions exactly when conditions are worst.
3. Does a spread filter replace a news filter?
For many strategies it covers most of the same ground, since spread widens around releases without needing a calendar.
We have helped thousands of traders reach funding at TTT Markets from account sizes of $5k upwards to $500k. Check out our programs.
Additional resources:
MT5 Scalping EA Guide: Settings, Spread Filters, and MQL5 Example | AlfaTactix
support@tttmarkets.com
WhatsApp Support →