#2821·freqtrade

Suggestion Robust Montecarlo backtesting

Author: Gambi97Created Jan 29, 2020Updated Apr 3, 2026
LabelsEnhancementBacktest

Robust Montecarlo backtesting

Hi, I noticed that a script to verify the robustness of a strategy through Montecarlo methods is not yet present in freqtrade. The idea of ​​stressing the trading system through a different market situation is a very useful tool to verify the effective efficiency of the strategy used.

What is Montecarlo simulation?

To get a little more into the technician and explain what Montecalro methods are, I'll give you a simple explanation. The MonteCarlo Method is part of the family of nonparametric statistical methods. It is useful to overcome the computational problems related to exact tests (for example methods based on binomial distribution or calculation, which for large samples generate an excessive number of permutations). The method is used to make estimates through simulations. It is based on an algorithm that generates a series of uncorrelated numbers, which follow the probability distribution that is supposed to have the phenomenon to be investigated. The correlation between numbers is ensured by a chi-square test. " In practice it is possible through the Montecarlo method to generate pseudo-causal values ​​that can be used as series of prices to test the trading system created (or take the prices already analyzed and recombine them in different order). The results of the trading system applied to the generated series will indicate the robustness of the system. Also in this case we are considering strong hypotheses, we are in fact considering that the average and the variance of future prices is the same as that observed in the past (we have in fact spoken of pseudo-causal values). It is therefore understood that even when a trading system has passed the various robustness tests, you will never be sure that in the future the equity line is in line with that recorded with the historical data in the backtest.

The IDEA

The idea is to create a script that can recombine the candles of a specific period (2 days, 1 month, 1 year; this depends on the timeframe of the strategy) to create create new patterns and verify the behavior of the strategy. If the strategy is good, the results should not vary as much, if instead the strategy has been hyper-optimized only for a particular market situation then the results will have a high variance. It is important to verify the variance of the profit, but even more important is to verify the maximum drawdown obtained in the various scenarios.

Conclusion

I hope I have been clear enough and that I have done everything right, I hardly ever use github, if there are questions or curiosities ask me as well. I should have some documents or links in reference to all this. I will try to find them in the next period. thank you :)