A spread filter is often treated as a minor safety feature. For an M1 Expert Advisor, it can decide whether the strategy has a usable edge. Ask how much execution cost a trade can absorb before its expected payoff disappears.
1. Measure the current bid-ask distance
Use the latest tick and calculate the spread in symbol points so the code does not assume every symbol has the same digits.
bool SpreadIsAcceptable(const int max_spread_points) { MqlTick tick; if(!SymbolInfoTick(_Symbol,tick)) return false; const double point=SymbolInfoDouble(_Symbol,SYMBOL_POINT); if(point<=0.0) return false; const int spread_points= (int)MathRound((tick.ask-tick.bid)/point); return spread_points<=max_spread_points; }
Call the check immediately before a new order because the quote can change between signal calculation and execution.
2. Treat the filter as an entry gate
If the spread is too wide, skip the entry. Existing positions should follow the strategy's exit rules unless it has an explicit emergency-liquidity exit.
Record every blocked signal. A filter that removes 2% of entries behaves very differently from one that removes 40%, but both can look like a quiet EA without a rejection counter.
3. Build a cost budget, not one perfect setting
Start with the strategy's average trade in points. Subtract the realized bid-ask cost, commission in point-equivalent terms and a slippage allowance. Use one consistent bid, ask or mid-price convention so spread is not counted twice. A short-horizon system needs a tighter budget than a swing system, so copying another EA's maximum spread is not a meaningful default.
4. Run a small stress matrix
For an M1 EA, use at least these five checks:
- Every tick based on real ticks with the intended spread gate.
- The same test with a tighter gate.
- The same test with a wider gate.
- Higher commission and a slippage allowance.
- A report covering signals, blocked entries, executed trades, average trade, profit factor and drawdown.
Look for understandable behavior across a reasonable area of settings, not the single threshold with the best historical profit. If only one exact value works, the filter may be fitting noise instead of controlling execution.
5. Recheck the broker environment
Digits, point size, spread, commission and execution quality differ across brokers and account types. Repeat the Strategy Tester and demo checks in the environment you plan to use. Real-tick mode is the appropriate final tester mode for a tick-sensitive M1 system, although no historical simulation guarantees future fills or performance.
Final checklist
- Read the latest tick before entry.
- Express the limit in symbol points.
- Block new entries, not routine exits.
- Count and log rejected signals.
- Stress more than one spread threshold.
- Include commission and slippage assumptions.
- Test with real ticks and then on demo.
A spread filter cannot create an edge. It can only stop a small edge from being spent on poor execution. If realistic costs remove the result, the strategy needs more work before the filter does.
References
- Testing Trading Strategies
- SymbolInfoInteger and spread calculation
- Testing trading strategies on real ticks


