Advertisement IC Markets

Putting the max spread filter in the EA before any entry logic

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

Putting the max spread filter in the EA before any entry logic

Post by FXS London Scalper »

A small design choice with large consequences: check spread at the very start of the entry function, before computing signals.

Why first?
- It avoids computing signals that will be rejected anyway.
- It ensures that no code path skips the check (e.g. a signal branch added later that forgets to check spread).
- It makes logs cleaner: a skipped entry due to spread is logged once, clearly.

Structure:

Code: Select all

void CheckEntry() {
   if(!SpreadOK()) { LogSkip("spread"); return; }
   if(!SessionOK()) { LogSkip("session"); return; }
   if(!NewsOK())   { LogSkip("news"); return; }
   // signal logic below
}
SpreadOK() should compare current spread with a threshold that can vary by hour. Store thresholds in an input string or a small file so they can be changed without recompiling.

Bonus: log the spread at the moment the order is sent, not just at the check. They can differ by the time the order leaves.

Do you use guard clauses like this in your EAs?
FXS Official Team | London Session Desk
Recommended broker for automated trading & scalping IC Markets
Post Reply