A bar-close signal and the quote available when a cBot submits an order are different observations. A strategy that ignores this difference may enter after a gap has materially changed its intended setup. A quote-drift gate rejects entries when the executable-side quote is too far from the original signal close.
Define the reference and units
For a buy, compare the current Ask with the completed signal bar's close. Divide the difference by Symbol.PipSize, not TickSize. This example uses absolute drift, rejecting both favorable and unfavorable moves beyond three pips because either can invalidate the original setup. An adverse-only filter is a separate design worth testing.
Assume EUR/USD with a pip size of 0.0001 and signal close of 1.1000. An Ask of 1.1002 gives two pips and passes; 1.1005 gives five pips and fails. A quote of 1.0996 also fails the absolute rule because its drift is minus four pips.

| Ask | Signed drift | Decision |
|---|---|---|
| 1.1002 | +2 | Eligible |
| 1.1005 | +5 | Skip |
| 1.0996 | -4 | Skip |
Integrate into a cBot
In OnBarClosed, the Bars collection excludes the live bar, so Last(0) identifies the completed bar. The event occurs when a new tick opens the next bar; after a weekend this can be substantially later than the nominal close. Add a separate signal-age limit and session filter. The fragment assumes the existing strategy has already checked a fresh signal, valid quote, and flat exposure. It is not a complete cBot.
// Inside an existing cBot's OnBarClosed handler,
// after confirming a fresh long signal and flat exposure.
double signalClose = Bars.ClosePrices.Last(0);
double drift = (Symbol.Ask - signalClose) / Symbol.PipSize;
if (double.IsNaN(drift) || double.IsInfinity(drift)
|| Math.Abs(drift) > 3.0 + 1e-8)
return;
double units = Symbol.NormalizeVolumeInUnits(
1000, RoundingMode.Down);
if (units < Symbol.VolumeInUnitsMin ||
units > Symbol.VolumeInUnitsMax)
return;
var result = ExecuteMarketOrder(TradeType.Buy,
SymbolName, units, "DriftGate", 20, 40);
if (!result.IsSuccessful)
Print("Entry rejected: {0}", result.Error);
The example normalizes 1,000 volume units and requests a 20-pip stop and 40-pip target. These are illustrative distances from entry, not risk recommendations. Check symbol-specific minimum protection distances and account constraints. For a short entry use Bid instead of Ask. Use a unique strategy label and reconcile actual positions and outstanding requests before another entry.
Quote validation versus execution protection
The gate is not a guaranteed slippage limit: the market may move between validation and execution. A market-range order can be considered where supported, with its base price and permitted range explicitly defined. That is a different execution policy and may reject otherwise valid signals. Do not blindly retry a rejected order using the original reference; first decide whether the signal is still fresh.
Testing plan
Compare no filter with thresholds of one, three and five pips using identical signals, exits and costs. Record the signal close, observed Ask, requested volume, rejection reason and actual fill price. Test the exact three-pip boundary, different pip sizes, wide spreads, weekend gaps and rejected orders. Use tick-level data where available and compare with a demo account; historical spread assumptions may hide live quote drift. Report skipped trades as well as completed trades to avoid selection bias.
Market orders and protective stops can slip, and filtering entries can remove profitable trades. No threshold guarantees profitability or a maximum loss.
Official references: Bar events and Robot API. This educational fragment has not been compiled or backtested here.
To extend this free strategy idea, contact us about Custom cTrader strategy Development Services.