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.