Monte Carlo - Degrado casuale dell'esecuzione
Le imperfezioni nell'esecuzione, come lo slittamento dei prezzi o gli spread temporaneamente più ampi, sono eventi comuni nel trading live. Questi fattori possono far sì che il prezzo di chiusura effettivo di un'operazione sia meno favorevole del prezzo ideale osservato o mirato durante il backtest. Questa simulazione Monte Carlo modella l'impatto di questi problemi di esecuzione casuale.
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 Prezzo di chiusura of the selected trades. The amount by which the Prezzo di chiusura 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 Prezzo aperto to the original Prezzo di chiusura). A “worse” price means a inferiore 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:
-
Which trades are affected is random (based on Probability).
-
How much each affected trade is degraded is anche 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.
Come importare snippet/indicatori personalizzati in SQX:
- https://strategyquant.com/doc/programming-for-sq/import-export-custom-indicators-and-other-snippets/