3. 5. 2025

5 0

Monte Carlo – Randomly Degrade Execution

Execution imperfections, such as price slippage or temporarily wider spreads, are common occurrences in live trading. These factors can cause the actual closing price of a trade to be less favorable than the ideal price observed or targeted during the backtest. This Monte Carlo simulation models the impact of such random execution issues.

If we apply this Monte Carlo test, a random percentage of trades (Probability) during the backtest will have their execution outcome degraded. This is achieved by worsening the ClosePrice of the selected trades. The amount by which the ClosePrice is worsened is also randomized for each affected trade, calculated as a random percentage (up to Max Degradation Percent) of the price range covered by that specific trade (from OpenPrice to the original ClosePrice). A “worse” price means a lower closing price for long trades and a higher closing price for short trades, thus reducing profits or increasing losses.

Simply said, by running 500 (or a different number) backtests, where each backtest applies this random price degradation to a different subset of trades and with varying severity, you can acquire a Monte Carlo analysis perspective on the strategy’s sensitivity to execution quality variations.

In this particular example, we might run 100 simulations with randomized execution degradation applied as described.

This test differs from applying a fixed slippage value to all trades. Here, the degradation effect is probabilistic:

  1. Which trades are affected is random (based on Probability).

  2. How much each affected trade is degraded is also random (up to Max Degradation Percent of its range).

Therefore, each simulation run represents a unique backtest scenario. One simulation might see trades #5, #23, and #58 degraded by small amounts, while another simulation might affect trades #12, #23, #45, and #70, with trade #23 potentially experiencing a larger price degradation than in the first simulation. If the number of Monte Carlo simulations is set to 500, there will be 500 unique backtest results, each reflecting a different plausible pattern of random execution imperfections. This helps assess the robustness of the strategy against unpredictable execution variations encountered in live markets.

 

How to import snippets / custom indicators to SQX:

 

Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments