Stop-Limit Order Execution via Martingale Theory
Ziyi Zhu / March 14, 2024
8 min read • ––– views
In financial markets, traders routinely face the challenge of optimizing entry and exit points in an environment characterized by uncertainty. This article examines the mathematical foundations of stop-limit orders—a powerful trading mechanism that combines protective stops with opportunistic limits—through the lens of stochastic calculus. By modeling asset price movements as a geometric Brownian motion, we derive an elegant formula for the probability that a limit order will execute before a stop order is triggered.
Stops vs Limits: The Fundamentals
A stop order is an instruction to trade when the price of a market hits a specific level that is less favourable than the current price. On the other hand, a limit order is an instruction to trade if the market price reaches a specified level more favourable than the current price.
There is no reason to only use one or the other type of order – both are extremely useful tools for a trader. In fact, some platforms go so far as to combine both orders into a single ‘stop-limit order’. This would enable traders to predefine their conditions for trading, entering a trend at a certain price level and exiting the trade once they’ve taken a certain amount of profit. Therefore, if we can understand the probability of a stop order getting triggered as opposed to a limit order, we can then estimate the expected return of a single stop-limit order.
Modeling Price Movements with Geometric Brownian Motion
To analyze these probabilities mathematically, we'll model stock price movements using a geometric Brownian motion (GBM). This is a continuous-time stochastic process where the logarithm of the randomly varying quantity follows a Brownian motion with drift.
A stock price follows a GBM if it satisfies the following stochastic differential equation:
where:
- represents a Wiener process (standard Brownian motion)
- is the expected return (drift coefficient)
- is the volatility (standard deviation of returns)
For any initial value , this SDE has the analytical solution:
This equation gives us the stock price at any future time based on the initial price and the parameters of the process.
The Two-Boundary Problem
In the context of stop-limit orders, we're interested in the first passage time problem with two absorbing boundaries. Let's define:
- as the upper boundary (limit price)
- as the lower boundary (stop price)
- as the current stock price, with
We want to determine the probability that the stock price will hit the upper boundary at time without ever hitting the lower boundary . This would represent the probability of a limit order executing before a stop order.
Applying the Optional Stopping Theorem
The optional stopping theorem from probability theory states that a martingale stopped at a stopping time remains a martingale. This means the expected value of a martingale at a stopping time equals its initial expected value.
We'll use the exponential martingale, which has the form:
This is a martingale for any value of , which we'll use to our advantage.
Transformation of Variables
To simplify our analysis, let's transform the stock price process into a more manageable form. We define a new variable as:
Substituting the expression for , we get:
where we've defined for convenience.
Creating a Time-Independent Martingale
Now we can express in terms of :
Substituting this into our exponential martingale:
To eliminate the time-dependent term, we need:
Solving for :
We choose (the non-trivial solution), which gives us:
This is now a time-independent martingale.
Finding the Probability
Let be the probability that the process hits the upper boundary before hitting the lower boundary .
At the stopping time , the process will be at either boundary:
- With probability , it hits first, and
- With probability , it hits first, and
By the optional stopping theorem, we know that .
Therefore:
Solving for gives us our final result:
This formula gives us the probability that a limit order at price will be executed before a stop order at price , assuming the stock price follows a geometric Brownian motion with drift and volatility .
Monte Carlo Simulations
We can simulate financial asset price movements using Geometric Brownian Motion (GBM) with absorbing boundaries, calculating both theoretical probabilities and empirical results from Monte Carlo simulations. The methodology tests how drift parameters, volatility values, and boundary configurations affect the probability of hitting upper boundaries before lower ones, validating theoretical formulas with empirical tests across 10,000 simulation paths per parameter combination. The code is available at my GitHub repository.

Results Summary
| Parameter Type | Parameter Values | Theoretical Probability | Empirical Probability | Absolute Error | Relative Error (%) |
|---|---|---|---|---|---|
| Drift (μ) | μ = -0.10, σ = 0.2 | 0.3778 | 0.3688 | 0.0090 | 2.39 |
| μ = -0.05, σ = 0.2 | 0.4378 | 0.4332 | 0.0046 | 1.06 | |
| μ = 0.00, σ = 0.2 | 0.5000 | 0.4944 | 0.0056 | 1.12 | |
| μ = 0.05, σ = 0.2 | 0.5624 | 0.5626 | 0.0002 | 0.03 | |
| μ = 0.10, σ = 0.2 | 0.6231 | 0.6261 | 0.0030 | 0.47 | |
| Volatility (σ) | μ = 0.05, σ = 0.1 | 0.7330 | 0.7306 | 0.0024 | 0.33 |
| μ = 0.05, σ = 0.2 | 0.5624 | 0.5587 | 0.0037 | 0.66 | |
| μ = 0.05, σ = 0.3 | 0.5278 | 0.5291 | 0.0013 | 0.24 | |
| μ = 0.05, σ = 0.4 | 0.5157 | 0.5045 | 0.0112 | 2.16 | |
| Boundaries | S₀ = 100, α = 105, β = 95 | 0.5312 | 0.5314 | 0.0002 | 0.03 |
| S₀ = 100, α = 110, β = 90 | 0.5624 | 0.5619 | 0.0005 | 0.09 | |
| S₀ = 100, α = 120, β = 80 | 0.6243 | 0.6212 | 0.0031 | 0.49 | |
| S₀ = 100, α = 120, β = 90 | 0.4171 | 0.4209 | 0.0038 | 0.91 | |
| S₀ = 100, α = 110, β = 80 | 0.7490 | 0.7428 | 0.0062 | 0.83 |
Key Insights
The simulations validate the theoretical framework with excellent accuracy, achieving relative errors typically below 1%. Three fundamental patterns emerge from the analysis:
Drift acts as a directional bias: positive drift increases the probability of hitting upper boundaries, with the effect being roughly linear—each increment in drift shifts probabilities by several percentage points in the expected direction.
Volatility diminishes drift effects: higher volatility causes the process to behave more randomly, reducing the influence of drift and pushing probabilities toward 50/50 regardless of directional bias. This explains why low-volatility assets exhibit more predictable directional behavior.
Boundary asymmetry matters significantly: the relative distances of boundaries from the starting price are critical. Moving one boundary farther away substantially increases the probability of hitting the opposite boundary first, demonstrating that stop-limit order placement requires careful consideration of both absolute and relative positioning.