Robust Metaheuristic Optimization for Algorithmic Trading: A Comparative Study of Optimization Techniques
Abstract
1. Introduction
- Providing a comparative analysis of four single-objective Metaheuristics applied to an optimization problem.
- Proposing a rolling-window validation [23] framework that mimics realistic deployment scenarios.
- Presenting a replicable and statistically grounded methodology that can guide the development and evaluation of rule-based trading strategies, particularly for practitioners in financial engineering and algorithmic trading.
- Incorporating a Diversity metric for discrete solution space.
2. Related Work
3. Background
3.1. Optimization Problems
3.2. Metaheuristic Optimization Algorithms
3.3. Rolling Windows Validation
3.4. Technical Indicators
3.5. Trading Strategies
- Open position if .
- Close position if .
4. Proposed Approach
4.1. Problem Model
4.2. Proposed Methodology
Proposed Strategy
| Algorithm 1 Four-SMA Crossover |
|
4.3. Performance Metrics and Backtest Assumptions
- Transaction Costs and Slippage: Each executed trade incurs a commission of 0.05% (0.0005) per transaction.
- Leverage and Position Sizing: The strategy uses 1× leverage and allocates 100% of the available capital to each new position. The backtesting engine operates with exclusive_orders = True, which ensures that only one order is active or executed at any time, and that no overlapping positions (long or short) can coexist.
- Stop-Loss and Take-Profit Mechanics: Stop-loss and take-profit levels follow a trailing logic. After each price update, the stop thresholds are recalculated based on the current volatility-adjusted factors. A position is immediately closed when its corresponding stop level is breached.
4.4. Diversity
5. Experimental Results
5.1. Data Employed
5.2. Experimental Setup
5.3. Statistical Comparison
5.4. Diversity Analysis of the Search Process
On the Persistent Diversity of Differential Evolution
6. Conclusions
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
Abbreviations
| GA | Genetic Algorithm |
| DE | Differential Evolution |
| GWO | Grey Wolf Optimization |
| WOA | Whale Optimization Algorithm |
| PSO | Particle Swarm Optimization |
| BTC | Bitcoin |
| Div | Diversity |
| XPT | Exploitation |
| XPL | Exploration |
| SMA | Simple Moving Average |
| STD | Standard Deviation |
References
- Buz, T.; de Melo, G. Democratisation of retail trading: A data-driven comparison of Reddit’s WallStreetBets to investment bank analysts. J. Bus. Anal. 2024, 7, 256–272. [Google Scholar] [CrossRef]
- Simonn, F.C. Past, Present, and Future Research Trajectories on Retail Investor Behaviour: A Composite Bibliometric Analysis and Literature Review. Int. J. Financ. Stud. 2025, 13, 105. [Google Scholar] [CrossRef]
- Ren, W. Retail investors’ accessibility to the internet and firm-specific information flows: Evidence from Google’s withdrawal. Int. Rev. Econ. Financ. 2023, 86, 402–424. [Google Scholar] [CrossRef]
- Mienye, E.; Jere, N.; Obaido, G.; Mienye, I.D.; Aruleba, K. Deep Learning in Finance: A Survey of Applications and Techniques. AI 2024, 5, 2066–2091. [Google Scholar] [CrossRef]
- Bhuiyan, M.S.; Rafi, M.A.; Rodrigues, G.N.; Mir, M.N.; Ishraq, A.; Mridha, M.; Shin, J. Deep Learning for Algorithmic Trading: A systematic review of predictive models and Optimization Strategies. Array 2025, 26, 100390. [Google Scholar] [CrossRef]
- Smith, D.M.; Wang, N.; Wang, Y.; Zychowicz, E.J. Sentiment and the Effectiveness of Technical Analysis: Evidence from the Hedge Fund Industry. J. Financ. Quant. Anal. 2016, 51, 1991–2013. [Google Scholar] [CrossRef]
- Brock, W.; Lakonishok, J.; Lebaron, B. Simple Technical Trading Rules and the Stochastic Properties of Stock Returns. J. Financ. 1992, 47, 1731–1764. [Google Scholar] [CrossRef]
- Rink, K. The predictive ability of technical trading rules: An empirical analysis of developed and emerging equity markets. Financ. Mark. Portf. Manag. 2023, 37, 403–456. [Google Scholar] [CrossRef]
- Chen, C.H.; Lai, W.H.; Hung, S.T.; Hong, T.P. An Advanced Optimization Approach for Long-Short Pairs Trading Strategy Based on Correlation Coefficients and Bollinger Bands. Appl. Sci. 2022, 12, 1052. [Google Scholar] [CrossRef]
- Chen, S.; Zhang, B.; Zhou, G.; Qin, Q. Bollinger Bands Trading Strategy Based on Wavelet Analysis. Appl. Econ. Financ. 2018, 5, 49. [Google Scholar] [CrossRef][Green Version]
- Peng, Y.; de Moraes Souza, J.G. Chaos, overfitting and equilibrium: To what extent can machine learning beat the financial market? Int. Rev. Financ. Anal. 2024, 95, 103474. [Google Scholar] [CrossRef]
- Suhonen, A.; Lennkh, M.; Perez, F. Quantifying Backtest Overfitting in Alternative Beta Strategies. J. Portf. Manag. 2017, 43, 90–104. [Google Scholar] [CrossRef]
- Avramelou, L.; Nousi, P.; Passalis, N.; Doropoulos, S.; Tefas, A. Cryptosentiment: A Dataset and Baseline for Sentiment-Aware Deep Reinforcement Learning for Financial Trading. In Proceedings of the 2023 IEEE International Conference on Acoustics, Speech, and Signal Processing Workshops (ICASSPW), Rhodes Island, 4–10 June 2023; pp. 1–5. [Google Scholar] [CrossRef]
- Crespo-Martínez, E.; Tonon-Ordóñez, L.; Orellana, M.; Lima, J.F. Applied Metaheuristics in International Trading: A Systematic Review. In Information and Communication Technologies; Maldonado-Mahauad, J., Herrera-Tapia, J., Zambrano-Martínez, J.L., Berrezueta, S., Eds.; Springer: Cham, Switzerland, 2023; pp. 95–112. [Google Scholar]
- Li, G.; Zhang, T.; Tsai, C.Y.; Yao, L.; Lu, Y.; Tang, J. Review of the metaheuristic algorithms in applications: Visual analysis based on bibliometrics. Expert Syst. Appl. 2024, 255, 124857. [Google Scholar] [CrossRef]
- Dolvin, S. The Efficacy of Trading Based on Moving Average Indicators: An Extension. J. Wealth Manag. 2014, 17, 140410000314006. [Google Scholar] [CrossRef]
- Storn, R.; Price, K. Differential Evolution—A Simple and Efficient Heuristic for Global Optimization over Continuous Spaces. J. Glob. Optim. 1997, 11, 341–359. [Google Scholar] [CrossRef]
- Kennedy, J.; Eberhart, R. Particle swarm optimization. In Proceedings of the ICNN’95-International Conference on Neural Networks, Perth, WA, Australia, 27 November–1 December 1995; Volume 4, pp. 1942–1948. [Google Scholar] [CrossRef]
- Mirjalili, S.; Lewis, A. The Whale Optimization Algorithm. Adv. Eng. Softw. 2016, 95, 51–67. [Google Scholar] [CrossRef]
- Mirjalili, S.; Mirjalili, S.M.; Lewis, A. Grey Wolf Optimizer. Adv. Eng. Softw. 2014, 69, 46–61. [Google Scholar] [CrossRef]
- Romo, A.; Soto, R.; Vega, E.; Crawford, B.; Salinas, A.; Becerra-Rozas, M. Adaptive Optimization of a Dual Moving Average Strategy for Automated Cryptocurrency Trading. Mathematics 2025, 13, 2629. [Google Scholar] [CrossRef]
- Zhou, C.; Huang, Y.; Cui, K.; Lu, X. R-DDQN: Optimizing Algorithmic Trading Strategies Using a Reward Network in a Double DQN. Mathematics 2024, 12, 1621. [Google Scholar] [CrossRef]
- Kuo, S.Y.; Chou, Y.H. Building Intelligent Moving Average-Based Stock Trading System Using Metaheuristic Algorithms. IEEE Access 2021, 9, 140383–140396. [Google Scholar] [CrossRef]
- Morales-Castañeda, B.; Zaldívar, D.; Cuevas, E.; Fausto, F.; Rodríguez, A. A better balance in metaheuristic algorithms: Does it exist? Swarm Evol. Comput. 2020, 54, 100671. [Google Scholar] [CrossRef]
- Crawford, B.; Soto, R.; Lemus-Romani, J.; Becerra-Rozas, M.; Lanza-Gutiérrez, J.M.; Caballé, N.; Castillo, M.; Tapia, D.; Cisternas-Caneo, F.; García, J.; et al. Q-Learnheuristics: Towards Data-Driven Balanced Metaheuristics. Mathematics 2021, 9, 1839. [Google Scholar] [CrossRef]
- Lemus-Romani, J.; Becerra-Rozas, M.; Crawford, B.; Soto, R.; Cisternas-Caneo, F.; Vega, E.; Castillo, M.; Tapia, D.; Astorga, G.; Palma, W.; et al. A Novel Learning-Based Binarization Scheme Selector for Swarm Algorithms Solving Combinatorial Problems. Mathematics 2021, 9, 2887. [Google Scholar] [CrossRef]
- Becerra-Rozas, M.; Lemus-Romani, J.; Cisternas-Caneo, F.; Crawford, B.; Soto, R.; García, J. Swarm-Inspired Computing to Solve Binary Optimization Problems: A Backward Q-Learning Binarization Scheme Selector. Mathematics 2022, 10, 4776. [Google Scholar] [CrossRef]
- Alsulmi, M. Reducing Manual Effort to Label Stock Market Data by Applying a Metaheuristic Search: A Case Study from the Saudi Stock Market. IEEE Access 2021, 9, 110493–110504. [Google Scholar] [CrossRef]
- Bousbaa, Z.; Bencharef, O. Metaheuristics for Financial Investment Strategies: Applications Survey. In Proceedings of the 2023 3rd International Conference on Electrical, Computer, Communications and Mechatronics Engineering (ICECCME), Tenerife, Canary Islands, Spain, 19–21 July 2023; pp. 1–6. [Google Scholar] [CrossRef]
- Soler-Dominguez, A.; Juan, A.A.; Kizys, R. A Survey on Financial Applications of Metaheuristics. ACM Comput. Surv. 2017, 50, 15. [Google Scholar] [CrossRef]
- Corazza, M.; Pizzi, C.; Marchioni, A. A financial trading system with optimized indicator setting, trading rule definition, and signal aggregation through Particle Swarm Optimization. Comput. Manag. Sci. 2024, 21, 26. [Google Scholar] [CrossRef]
- Trimarchi, S.; Casamatta, F.; Grimaccia, F. Strategy Optimization by Means of Evolutionary Algorithms with Multiple Closing Criteria for Energy Trading. IEEE Open J. Ind. Appl. 2024, 5, 469–478. [Google Scholar] [CrossRef]
- Trimarchi, S.; Casamatta, F.; Grimaccia, F.; Lorenzo, M.; Niccolai, A. Robust Optimized Trading Strategies for Energy Commodity Markets. In Proceedings of the 2024 IEEE International Conference on Artificial Intelligence & Green Energy (ICAIGE), Yasmine Hammamet, Tunisia, 10–12 October 2024. [Google Scholar]
- Trimarchi, S.; Casamatta, F.; Grimaccia, F. A Review of Agent-Based Models for Energy Commodity Markets. Energies 2024, 18, 3171. [Google Scholar]
- Lahyani, R. Exploring the Deployment of Business Analytics Tools, Including Metaheuristics, Across Saudi Enterprises. In Sustainable Data Management; Studies in Big Data; Springer Nature: Cham, Switzerland, 2025; Volume 171, pp. 111–115. [Google Scholar] [CrossRef]
- Omran, S.M.; El-Behaidy, W.H.; Youssif, A.A. Optimization of Cryptocurrency Algorithmic Trading Strategies Using the Decomposition Approach. Big Data Cogn. Comput. 2023, 7, 174. [Google Scholar] [CrossRef]
- Nayak, G.H.; Alam, M.W.; Naik, B.S.; Varshini, B.; Avinash, G.; Kumar, R.R.; Ray, M.; Singh, K. Meta-transformer: Leveraging metaheuristic algorithms for agricultural commodity price forecasting. J. Big Data 2025, 12, 138. [Google Scholar] [CrossRef]
- Dokeroglu, T.; Canturk, D.; Kucukyilmaz, T. A survey on pioneering metaheuristic algorithms between 2019 and 2024. arXiv 2024, arXiv:2501.14769. [Google Scholar]
- Huang, Y.; Zhou, C.; Zhang, L.; Lu, X. A Self-Rewarding Mechanism in Deep Reinforcement Learning for Trading Strategy Optimization. Mathematics 2024, 12, 4020. [Google Scholar] [CrossRef]
- Majidi, N.; Shamsi, M.; Marvasti, F. Algorithmic trading using continuous action space deep reinforcement learning. Expert Syst. Appl. 2024, 235, 121245. [Google Scholar] [CrossRef]
- Shahi, T.B.; Shrestha, A.; Neupane, A.; Guo, W. Stock price forecasting with deep learning: A comparative study. Mathematics 2020, 8, 1441. [Google Scholar] [CrossRef]
- Dutta, A.; Kumar, S.; Basu, M. A gated recurrent unit approach to bitcoin price prediction. J. Risk Financ. Manag. 2020, 13, 23. [Google Scholar] [CrossRef]
- Sörensen, K.; Glover, F. Metaheuristics. In Encyclopedia of Operations Research and Management; Science Springer Nature: Boston, MA, USA, 2013; pp. 960–970. [Google Scholar] [CrossRef]
- Sampson, J.R. Adaptation in Natural and Artificial Systems (John H. Holland). SIAM Rev. 1976, 18, 529–530. [Google Scholar] [CrossRef]
- Banks, A.; Vincent, J.; Anyakoha, C. A review of particle swarm optimization. Part I: Background and development. Nat. Comput. 2007, 6, 467–484. [Google Scholar] [CrossRef]
- Pennanen, T.; Perkkiö, A.P.; Rásonyi, M. Existence of solutions in non-convex dynamic programming and optimal investment. Math. Financ. Econ. 2017, 11, 173–188. [Google Scholar] [CrossRef]
- Cerqueira, V.; Torgo, L.; Mozetič, I. Evaluating time series forecasting models: An empirical study on performance estimation methods. Mach. Learn. 2020, 109, 1997–2028. [Google Scholar] [CrossRef]
- Chugh, T.; Sindhya, K.; Hakanen, J.; Miettinen, K. A survey on handling computationally expensive multiobjective optimization problems with evolutionary algorithms. Soft Comput. 2019, 23, 3137–3166. [Google Scholar] [CrossRef]
- Bazgan, C.; Herzel, A.; Ruzika, S.; Thielen, C.; Vanderpooten, D. Approximating multiobjective optimization problems: How exact can you be? Math. Methods Oper. Res. 2024, 100, 5–25. [Google Scholar] [CrossRef]
- Pardo, R.E. The Evaluation and Optimization of Trading Strategies, 2nd ed.; John Wiley & Sons: Hoboken, NJ, USA, 2008. [Google Scholar]
- Kernc, E.A.; Backtesting. py Contributors. Backtesting.py: Backtest Trading Strategies in Python. 2024. Available online: https://kernc.github.io/backtesting.py/ (accessed on 25 May 2025).
- Malhotra, D.; Mooney, T.; Poteau, R.; Russel, P. Assessing the Performance and Risk-Adjusted Returns of Financial Mutual Funds. Int. J. Financ. Stud. 2023, 11, 136. [Google Scholar] [CrossRef]
- Hussain, K.; Zhu, W.; Mohd Salleh, M.N. Long-Term Memory Harris’ Hawk Optimization for High Dimensional and Optimal Power Flow Problems. IEEE Access 2019, 7, 147596–147616. [Google Scholar] [CrossRef]
- Bodie, Z.; Kane, A.; Marcus, A.J. Investments, 10th ed.; McGraw-Hill Education: Columbus, OH, USA, 2014. [Google Scholar]
- Hull, J.C. Options, Futures, and Other Derivatives, 10th ed.; Pearson: London, UK, 2018. [Google Scholar]
- Singh, B.; Batth, J.S.; Goel, P. Review of Meta-Heuristic Algorithms: Interplay between Exploration and Exploitation. In Proceedings of the 2024 First International Conference on Technological Innovations and Advance Computing (TIACOMP), Bali, Indonesia, 29–30 June 2024; pp. 47–52. [Google Scholar] [CrossRef]
- Teghem, J. Metaheuristics. From Design to Implementation, El-Ghazali Talbi. John Wiley & Sons Inc. (2009). XXI + 593 pp., Publication 978-0-470-27858-1. Eur. J. Oper. Res. 2010, 205, 486–487. [Google Scholar] [CrossRef]
- Fama, E.F.; Blume, M.E. Filter Rules and Stock-Market Trading. J. Bus. 1966, 39, 226–241. [Google Scholar] [CrossRef]
- Katsiampa, P. Volatility estimation for Bitcoin: A comparison of GARCH models. Econ. Lett. 2017, 158, 3–6. [Google Scholar] [CrossRef]
- Tomar, V.; Bansal, M.; Singh, P. Metaheuristic Algorithms for Optimization: A Brief Review. Eng. Proc. 2023, 59, 238. [Google Scholar] [CrossRef]






| Indicator | Formula |
|---|---|
| Simple Moving Average (SMA) | |
| Standard Deviation (STD) |
| Parameter | Description | Range |
|---|---|---|
| Period of the simple moving average i | ||
| Take-profit factor for long positions | ||
| Stop-loss factor for long positions | ||
| Take-profit factor for short positions | ||
| Stop-loss factor for short positions |
| Metric | Description |
|---|---|
| Return [%] | Total return of the strategy. |
| Buy and Hold Return [%] | Return from a buy-and-hold strategy. |
| Return (Ann.) [%] | Annualized return. |
| Volatility (Ann.) [%] | Annualized standard deviation of returns. |
| Sharpe Ratio | Risk-adjusted return per unit of volatility. |
| Sortino Ratio | Like Sharpe Ratio, but penalizes only downside risk. |
| Max. Drawdown [%] | Largest equity drop from peak to trough. |
| Win Rate [%] | Percentage of winning trades. |
| Profit Factor | Gross profits divided by gross losses. |
| Algorithm | Parameter | Range or Value Selected |
|---|---|---|
| DE | F | 0.4–0.8 |
| 0.5–0.9 | ||
| PSO | w | 0.4–0.9 |
| 1.5–2.0 | ||
| 1.5–2.0 | ||
| GWO | a | 0–2.0 |
| WOA | a | 0–2.0 |
| b | 1 | |
| l | −1.0–1.0 |
| Metaheuristic | Avg. Return (ann.) [%] | Avg. Volatility (ann.) [%] | Best Return (ann.) [%] | Volatility of Best (ann.) [%] |
|---|---|---|---|---|
| PSO | 73.47 | 90.09 | 121.48 | 119.83 |
| WOA | 92.05 | 98.64 | 118.15 | 115.35 |
| GWO | 61.80 | 84.21 | 116.79 | 114.85 |
| DE | 107.36 | 108.85 | 119.62 | 117.64 |
| Metric | DE | GWO | WOA | PSO | |
|---|---|---|---|---|---|
| Mean Return | DE | - | >0.05 | >0.001 | >0.05 |
| GWO | >0.05 | - | >0.05 | >0.05 | |
| WOA | >0.001 | >0.05 | - | >0.05 | |
| PSO | >0.05 | >0.05 | >0.05 | - | |
| Std. Dev. Return | DE | - | >0.001 | >0.001 | >0.001 |
| GWO | >0.001 | - | >0.05 | >0.05 | |
| WOA | >0.001 | >0.05 | - | >0.05 | |
| PSO | >0.001 | >0.05 | >0.05 | - | |
| Best Validation | DE | - | 0.021 | >0.05 | >0.05 |
| GWO | 0.021 | - | >0.05 | >0.05 | |
| WOA | >0.05 | >0.05 | - | >0.05 | |
| PSO | >0.05 | >0.05 | >0.05 | - |
| Metric | WOA | GWO | PSO | DE |
|---|---|---|---|---|
| Retorno (Anual.) [%] | 120.28 | 116.79 | 110.84 | 108.86 |
| Volatilidad (Anual.) [%] | 116.73 | 114.86 | 102.04 | 111.42 |
| Sharpe Ratio | 1.03 | 1.02 | 1.086 | 0.977 |
| Sortino Ratio | 3.95 | 3.81 | 3.78 | 3.49 |
| Max. Drawdown [%] | −28.66 | −29.34 | −37.13 | −29.77 |
| Win Rate [%] | 69.39 | 82.50 | 94.12 | 60.00 |
| Number of Trades | 49 | 40 | 51 | 20 |
| Profit Factor | 5.06 | 2.74 | 3.71 | 4.11 |
| Metaheuristic | Recommended Use | Pros | Cons |
|---|---|---|---|
| DE | Suitable when stability across runs is prioritized | High consistency across runs, strong exploration-exploitation balance and robust validation performance | High variability in the best found solutions does not necessarily maximize extreme single-run returns |
| WOA | Suitable when maximizing single-run performance is desired | Best individual execution with highest profit factor and Sortino, contained maximum drawdown | Less consistent than DE: more volatile performance across runs |
| PSO | Suitable for capturing short-term opportunities and high-frequency strategies | Highest Sharpe with exceptional hit rate. Effective for fast-changing market dynamics | Largest drawdowns and higher sensitivity to sharp declines tends to produce more aggressive strategies |
| GWO | Suitable for balanced return-frequency profiles | Second best return with high hit rate and generally stable behavior | Moderate profit factor, gains frequently offset by losses of relatively larger magnitude |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Hernández-Romo, K.; Lemus-Romani, J.; Vega, E.; Becerra-Rozas, M.; Romo, A. Robust Metaheuristic Optimization for Algorithmic Trading: A Comparative Study of Optimization Techniques. Mathematics 2026, 14, 69. https://doi.org/10.3390/math14010069
Hernández-Romo K, Lemus-Romani J, Vega E, Becerra-Rozas M, Romo A. Robust Metaheuristic Optimization for Algorithmic Trading: A Comparative Study of Optimization Techniques. Mathematics. 2026; 14(1):69. https://doi.org/10.3390/math14010069
Chicago/Turabian StyleHernández-Romo, Kaled, José Lemus-Romani, Emanuel Vega, Marcelo Becerra-Rozas, and Andrés Romo. 2026. "Robust Metaheuristic Optimization for Algorithmic Trading: A Comparative Study of Optimization Techniques" Mathematics 14, no. 1: 69. https://doi.org/10.3390/math14010069
APA StyleHernández-Romo, K., Lemus-Romani, J., Vega, E., Becerra-Rozas, M., & Romo, A. (2026). Robust Metaheuristic Optimization for Algorithmic Trading: A Comparative Study of Optimization Techniques. Mathematics, 14(1), 69. https://doi.org/10.3390/math14010069

