Gap and Crash: What Trading Robots Really Do
A weekend passes, and on Monday morning the price opens far from Friday's last quote. If you have an automated robot running, one question comes up right away: what happens to my order now? The same question shows up when a surprise news event shakes the market in seconds and the price skips several ticks instead of moving through them one by one. A trading robot facing a crash or gap doesn't behave like a person who panics and sells, or waits. It follows rules, and those rules decide what happens to a pending order when the price jumps instead of moving smoothly.
This article goes through the settings in StrategyQuant X that actually deal with these kinds of price jumps: what they test, what they're meant for, and where their effect stops. Along the way we keep a clear line between what a backtest simulates and what a live robot does in real time.
Gap and crash: what Realistic Gaps Handling in StrategyQuant X actually changes
StrategyQuant X has a trading option called Realistic Gaps Handling. It applies only to the MT4 engine, and only to entry stop orders and entry limit orders. The idea behind it: without this option, the backtester simply fills such an order at your requested price, as if the price had moved there smoothly. With the option turned on, the tester instead fills the order at the price that was actually first available after the jump between two candles.
For a backtest that spans a weekend or a volatile news period, that makes a real difference. Without the option, the simulation often looks noticeably more optimistic than a real execution would have been.

What this setting doesn't cover
The documentation describes Realistic Gaps Handling only for entry orders. Nothing in it suggests that it also changes how stop-loss or take-profit orders are simulated, or that the option even exists on engines other than MT4. That doesn't necessarily mean nothing happens to your stop-loss during a gap, but it does mean this particular setting isn't built for that. You shouldn't treat it as protection for open positions.
If you test your robot on MT4 and turn this option on, you're checking how realistically a new order would have been filled during a gap, not what happens to a position that's already open. That alone shows how large the gap can be between what a backtest simulates and what actually happens in live trading.
Futures: when the exchange rejects an order
Futures markets come with an extra hurdle that has nothing to do with ordinary gaps. Once prices hit a certain daily limit up or down, exchanges can simply stop accepting further orders. In volatile periods or around major news, this can mean your order gets rejected, and only the next session opens, with a large gap and matching slippage.
No software can prevent or get around a limit move like that, StrategyQuant X included. What actually helps is preparation and caution: knowing a futures contract's specifications and price limits ahead of time, pausing trading during periods you expect to be critical, and not placing stop-loss levels too close to the daily limit. These aren't automatic safeguards the software handles for you, they're precautions you put in place yourself before the market gets there.
The worst moment of a trade: Maximum Adverse Excursion
Once a trade has closed, you can look back and see how bad things really got in the middle of it. Maximum Adverse Excursion describes exactly that: the largest unfavorable price move a trade went through before it closed. A StrategyQuant plugin uses this worst intermediate value, not just the position's closing price, to check a trade against set limits.
For the crash and gap question, this is useful because a single trade might have closed in profit, while sitting well into the red at some point in between, for instance because a gap happened right during that holding period. Maximum Adverse Excursion reveals that moment, something a pure end-result view hides. But it only describes what happened to that one trade in the past, it says nothing about how bad a future trade will get. If you're wondering how individual bad trades add up into a drawdown, that's the next step.

Value at Risk estimates normal days, not the crash
Value at Risk is a method for estimating the expected maximum loss over a given period. It works with a confidence level, daily portfolio volatility and a time horizon, and it's calculated under normal market conditions. That's exactly where its limit lies: Value at Risk isn't built to describe extraordinary, non-normal moves like an actual market crash.
The figure can give you an idea of what might happen on an ordinary bad day. It isn't an upper limit for what happens on a truly extraordinary day. Keep that distinction in mind before you mistake a single number for a safety net.
Portfolio backtest: recreating execution problems with Max Degradation Percent
In the portfolio backtest of StrategyQuant X, there's a setting called Max Degradation Percent. It sets an upper limit on how much a trade's closing price can be randomly worsened during the simulation, expressed as a percentage of that trade's price range. It's part of a broader feature for modeling execution problems in the portfolio simulation, things like slippage or delayed fills.
This feature recreates general execution problems, not a specific crash scenario. It helps keep a backtest from looking more optimistic than real execution would be, since real execution rarely runs as smoothly as a theoretical fill at the exact price you wanted. A real crash with extreme volatility and dried-up liquidity isn't simulated one to one by this, but the setting does show how sensitive a portfolio is to execution variation in general.
What these settings show, and what stays open
The settings we went through here, Realistic Gaps Handling, Maximum Adverse Excursion, Value at Risk and Max Degradation Percent, each describe something different: how an order gets filled in a backtest, how bad a past trade looked at its worst point, how large an expected loss is under normal conditions, or how sensitive a portfolio is to execution problems. None of them is a switch that automatically stops a running robot during an actual crash, closes a position, or hedges it.
What your robot actually does in real time during such a moment depends on your platform, your broker, and the precautions you've put in place yourself, for instance what happens to open positions when the connection to the platform drops. A backtest with the gap setting turned on shows you how a strategy would have handled a gap in the past, not how it will behave in the next crash.
This article is for education only and is not investment advice. Past results, including backtests, do not guarantee future results. Trading financial instruments involves risk, and you can lose money.
This article is for education only and is not investment advice. Past results do not guarantee future results.
How do you do it? Share it in the community. Free, in your language.
Sign up free