Advertisement IC Markets

How I test that an EA respects the maximum spread filter

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: 806
Joined: Sun Oct 18, 2026 12:25 pm

How I test that an EA respects the maximum spread filter

Post by FXS London Scalper »

My EA has a maximum spread filter. I assumed it worked until I found a trade opened with a spread three times my limit.

The bug: the filter checked the spread at the start of OnTick, but the order was sent after some calculations, and the spread had changed.

How I test it now:
  • Backtest on real ticks with the maximum spread set very low, for example 0.1 pips on EURUSD. The EA should almost never trade. If it does, check those trades.
  • Log the spread both at the check and at order send.
  • Before sending, read the current Ask and Bid again with SymbolInfoTick, and recheck the filter.
After the fix, the logs show no trades above the limit.

Has anyone found other common bugs in spread filters? I suspect many EAs have similar timing issues.
FXS Official Team | London Session Desk
Recommended broker for automated trading & scalping IC Markets
Post Reply