How I test that an EA respects the maximum spread filter
Posted: Fri Oct 30, 2026 1:45 pm
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:
Has anyone found other common bugs in spread filters? I suspect many EAs have similar timing issues.
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.
Has anyone found other common bugs in spread filters? I suspect many EAs have similar timing issues.