Separate trend signals from volatility permission
A moving-average crossover can occur during a sudden volatility shock. In ProRealTime ProOrder, a separate ATR gate can prevent new entries when recent price ranges exceed a chosen limit. This is a testable design rather than a prediction of profitability.
Rules and example
Use a 10-period and 30-period simple moving average and 14-period ATR. Enter long only on an upward crossover while flat and ATR is at most 2 price units. If ATR is 1.5, the gate passes; at 2.5 it fails. Passing the gate alone never triggers an order. A rejected crossover is not queued for later entry. Exit on a downward crossover or protective stop.

Illustrative ATR readings of 1, 1.5, 2.5, 3 and 1.5 price units. Green bars permit a crossover entry; red bars block it.
ProOrder implementation
DEFPARAM CumulateOrders = False
atrValue = AverageTrueRange[14](close)
fastMA = Average[10](close)
slowMA = Average[30](close)
IF NOT ONMARKET AND fastMA CROSSES OVER slowMA AND atrValue <= 2 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF LONGONMARKET AND fastMA CROSSES UNDER slowMA THEN
SELL AT MARKET
ENDIF
SET STOP pLOSS 40
CumulateOrders disables position accumulation. The example uses one contract and a 40-point protective stop; points and ATR price units must be interpreted using the instrument specification. The fixed threshold is intentionally illustrative and should not be copied across instruments. A market order generated at bar close normally executes at the next bar in backtesting; actual execution can differ. The ATR gate controls entries only, never protective exits.
Testing and risk
Compare the ungated crossover with thresholds of 1.5, 2 and 3 using identical data and costs. Record rejected crossovers, exposure, drawdown and net returns. Use chronological out-of-sample testing and check sensitivity across volatility regimes. A low ATR does not guarantee safety; a high ATR can accompany profitable trends. Gaps and slippage can exceed the stop distance. This illustrative code has not been compiled or backtested here. Leveraged trading can cause substantial losses.
For instrument-specific volatility filters and order management, see Custom ProRealTime strategy Development Services.