A profitable-looking candle signal can become an expensive live entry when the bid-ask spread widens. Separate signal generation from execution eligibility rather than modifying the indicator to hide expensive trades. A spread gate is a pre-trade control, not an exit rule or a guarantee of execution quality.

Worked example: convert the quote into pips

For a hypothetical EURUSD quote, PipSize is 0.0001. Bid 1.10000 and ask 1.10008 give a spread of 0.8 pip. At ask 1.10015 with the same bid, the spread is 1.5 pips, which passes a maximum of 1.5. At ask 1.10032 the spread is 3.2 pips, so the entry is skipped. A five-digit quote's last decimal is not necessarily one pip.

How to Build a Spread-Aware Entry Gate for cTrader cBots
A 1.5-pip maximum entry spread permits 0.8 and 1.5 pips, but blocks 3.2 pips.

Put the gate immediately before the entry

Use OnBarClosed() for a completed-bar signal, but read current bid and ask when preparing the order. The callback runs when a new tick opens the next bar, which can be delayed after a session break. The following excerpt belongs inside the existing entry branch; it is not a complete cBot.

// Inside the entry path of OnBarClosed()
// after signal and position checks
double spreadPips = (Symbol.Ask - Symbol.Bid) / Symbol.PipSize;
if (spreadPips > 1.5)
{
    Print("Entry skipped: spread {0:F2} pips", spreadPips);
    return;
}
// Submit the planned entry and check TradeResult.

Use a configurable positive threshold in production; consider a small numerical tolerance or integer tick comparisons at the boundary. Do not let the early return skip position protection or exit management. Check the returned TradeResult and reconcile actual fills. A rejected signal should expire unless a separately designed retry rule explicitly permits re-entry later.

Validation and failure cases

  • Test spread below, exactly at, and above the threshold; verify accepted and rejected signals in logs.
  • Repeat with JPY pairs and non-FX instruments. Read each symbol's own PipSize rather than assuming 0.0001.
  • Compare fixed-spread and realistic historical bid/ask models; test live quotes in a demo account during illiquid periods.
  • Record signal timestamp, bid, ask, spread, actual fill and slippage. A spread check can become stale before execution.

For a strategy with a 5-pip gross target, a 3.2-pip spread is large relative to the target. This comparison is a cost diagnostic, not an exact net-P&L calculation; commissions, execution price and exit spread also matter.

Official reference: Symbol API.

This hypothetical teaching excerpt has not been compiled or backtested here. Trading involves risk of loss; simulated results do not guarantee future performance.

To adapt this free strategy idea to your trading rules, contact us about Custom cTrader strategy Development Services.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.