Breakout strategies can encounter widening bid-ask spreads precisely when liquidity deteriorates. A fixed spread limit alone does not describe the relative cost of trading in different volatility regimes. A cTrader cBot can combine a spread-to-ATR ratio with an absolute spread ceiling before submitting a new entry.

Rules and worked example

Suppose an existing long strategy signals when a completed bar closes above the highest high of the preceding 20 completed bars, with no strategy-owned position or pending entry. Use a 14-period exponentially smoothed ATR. Require the current spread to be no more than 15% of ATR and no more than two pips. With ATR at 10 pips, the effective ceiling is 1.5 pips. With ATR at 30 pips, the absolute two-pip ceiling still applies. These thresholds are illustrative, not optimized.

Filtering Breakout Entries with a SpreadATR Ratio
With ATR at 10 pips, the three quoted spreads produce ratios of 0.08, 0.15 and 0.24; the last is rejected.

Implementing the gate in a cBot

Initialize AverageTrueRange in OnStart and declare _atr as an AverageTrueRange field. In OnBarClosed the Bars collection excludes the currently forming bar, so LastValue refers to the completed bar's ATR. Require sufficient warm-up history, for example 50 bars. Exclude the signal bar from the breakout reference high. Symbol.Ask minus Symbol.Bid and ATR are both in price units; no pip conversion is necessary for their ratio.

// Inside an existing cBot; initialize in OnStart:
// _atr = Indicators.AverageTrueRange(14, MovingAverageType.Exponential);
// Call from OnBarClosed before submitting a new entry.
private bool SpreadAllowsEntry()
{
    double atr = _atr.Result.LastValue;
    double spread = Symbol.Ask - Symbol.Bid;
    if (double.IsNaN(atr) || atr <= 0 || spread < 0)
        return false;
    return spread <= 0.15 * atr
        && spread <= 2.0 * Symbol.PipSize;
}

This helper is an entry filter, not a complete robot. Submit an order only when the original breakout, position checks and filter all pass. This version discards a rejected signal instead of queuing it until spreads normalize. Keep protective stops and exits independent of the filter. Normalize order volume to the symbol's permitted minimum, maximum and step, check the trade result, and prevent duplicate submissions.

Testing and limitations

Test spreads of 0.8, 1.5 and 2.4 pips, zero ATR, insufficient history and invalid quotes. Compare an unfiltered baseline, a fixed two-pip ceiling and the combined filter using trade count, net results, drawdown and missed breakouts. Use historical data with realistic variable spreads where possible, and test news and rollover conditions in a demo account. Slippage between the quote check and execution remains possible; this gate does not guarantee transaction costs. ATR does not predict future volatility.

Official reference: AverageTrueRange. This educational example has not been compiled or backtested here. Trading involves risk of loss.

To adapt this free strategy idea to your own 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.