Next Article in Journal
Intrinsic and Extrinsic Geometry of Kählerian Slant Submanifolds in Complex Space Forms
Next Article in Special Issue
Quality–Diversity and Illumination Algorithms in Discrete Combinatorial Domains: Diversity Metrics and Implications for Resilient Mining Operations
Previous Article in Journal
Closed-Form Design Quantiles Under Skewness and Kurtosis: A Hermite Approach to Structural Reliability
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Robust Metaheuristic Optimization for Algorithmic Trading: A Comparative Study of Optimization Techniques

by
Kaled Hernández-Romo
1,
José Lemus-Romani
2,
Emanuel Vega
3,*,
Marcelo Becerra-Rozas
3 and
Andrés Romo
4
1
Departamento de Electrotecnia e Informática, Universidad Técnica Federico Santa María, Viña del Mar 2520000, Chile
2
Escuela de Construcción Civil, Pontificia Universidad Católica de Chile, Avenida Vicuña Mackenna 4860, Macul, Santiago 7820436, Chile
3
Escuela de Ingeniería Informática, Pontificia Universidad Católica de Valparaíso, Avenida Brasil 2241, Valparaíso 2362807, Chile
4
Centro de Electrónica Industrial, Universidad Politécnica de Madrid, C. de José Gutiérrez Abascal, 2, 28006 Madrid, Spain
*
Author to whom correspondence should be addressed.
Mathematics 2026, 14(1), 69; https://doi.org/10.3390/math14010069
Submission received: 5 November 2025 / Revised: 1 December 2025 / Accepted: 12 December 2025 / Published: 24 December 2025
(This article belongs to the Special Issue Diversity Metrics in Combinatorial Problems)

Abstract

Algorithmic trading heavily relies on the optimization of rule-based strategies to maximize profitability and ensure robustness under volatile market conditions. Traditional optimization methods often face limitations when dealing with the nonlinear, high-dimensional, and dynamic nature of financial search spaces. This study introduces a Metaheuristic-based framework for financial strategy optimization that focuses on the modeling and resolution of the problem through population-based search algorithms. The framework evaluates four Metaheuristic optimization techniques within a unified design, enabling a consistent and fair comparison of their performance in optimizing trading rules. To ensure realistic and time-consistent evaluation, the experimental setup incorporates a Rolling Windows Validation approach, allowing the assessment of model performance across successive market periods. Beyond improving convergence behavior, Diversity is employed as a metric to assess the quality and exploration capability of the search process, providing deeper insight into algorithmic performance. Experimental results, obtained from real market data, demonstrate substantial improvements in profitability consistency and risk-adjusted performance compared to conventional optimization approaches. The findings confirm that Metaheuristic optimization offers a robust and flexible alternative for the design and refinement of algorithmic trading systems in complex and dynamic financial environments. Interestingly, Differential Evolution exhibited persistently high Diversity, suggesting the presence of multiple distant yet competitive optima in the financial search space, where functional convergence coexists with geometric dispersion.

1. Introduction

In recent years, financial trading has experienced remarkable growth [1,2], attracting not only seasoned traders but also individuals with no prior exposure to financial markets. This surge in interest is largely attributed to the increasing accessibility of online exchanges and the proliferation of user-friendly trading platforms, which have significantly lowered the entry barrier for retail investors [3]. As the market evolves, algorithmic trading has become an increasingly popular approach for both institutional and retail participants [4]. These systems enable the automation of decision-making processes based on predefined rules or models, allowing for faster execution and more systematic strategies [5]. A central component of any algorithmic trading system is the set of indicators or rules used to generate trading signals [6]; therefore, a trading strategy can be broadly defined as a combination of heuristic rules that guide decisions on when to open or close positions, with the goal of maximizing returns. Such strategies are typically constructed using historical market data and technical indicators—statistical tools that provide insight into market trends, momentum, and volatility [7]. Among the most commonly employed algorithmic approaches are rule-based strategies, which rely on predefined decision rules derived from technical analysis [8]. Examples may include moving average crossovers, Bollinger Bands, and volatility filters [9]. These strategies remain popular due to their simplicity, interpretability, and ease of implementation [10]. Nonetheless, their effectiveness is highly sensitive to the choice of hyperparameters such as window lengths, thresholds, and stop-loss/take-profit levels [11]. If not properly optimized, such strategies are prone to overfitting or underperformance when deployed in volatile and non-stationary environments [12]. Thus, building effective algorithmic strategies requires more than just selecting appropriate indicators. A critical challenge lies in the optimization of these strategies, particularly in fine-tuning their parameters to ensure robust performance across diverse market conditions. The success of an algorithmic trading system is therefore closely tied to the quality of the optimization process, which must balance profitability, risk control, and generalization to unseen data.
While recent advancements in machine learning, particularly deep learning, have introduced new paradigms for predictive modeling and intelligent decision-making applied to financial contexts [13], relatively little attention has been devoted to the systematic optimization of rule-based trading strategies [14]. Despite the growing interest in the development of sophisticated forecasting models and autonomous trading agents, challenges such as hyperparameter tuning, performance generalization, and computational efficiency remain open problems in the literature. Metaheuristic optimization offers an effective and flexible framework for optimizing rule-based trading strategies. These algorithms, inspired by natural processes such as evolution or swarm intelligence, explore the solution space without relying on gradient information or convexity assumptions [15]. To address this challenge, we formulate the problem as a single-objective optimization task. Our methodology is applied to a simple but expressive strategy based on the Simple Moving Average (SMA), augmented with volatility-based stop-loss and take-profit mechanisms [16]. We evaluate the effectiveness of four Metaheuristics: Differential Evolution (DE) [17], Particle Swarm Optimization (PSO) [18], Whale Optimization Algorithm (WOA) [19], and Grey Wolf Optimizer (GWO) [20] in tuning the strategy’s parameters. For this evaluation, we employ historical data from the BTC/USDC pair, performing 31 independent seeds for each algorithm to ensure the statistical robustness of our findings.
Although numerous studies on the optimization of trading strategies claim to have outperformed the passive Buy and Hold approach (as shown in the works of Romo et al. [21] and Zhou et al. [22]), this success criterion is incomplete in practice. The limitation lies in the fact that simple absolute return ignores intrinsic volatility and, crucially, the strategy’s downside risk (drawdown). The lack of a robust evaluation that includes the Sharpe Ratio and, especially, the Sortino Ratio prevents determining whether the superior performance is achieved at an unacceptably high risk cost or whether the strategy is truly more efficient than the market. This methodological gap in the literature is what our study addresses, prioritizing the optimization of risk-adjusted metrics to provide results with real applicability.
This work closes the gap in the current knowledge and contributes as follows:
  • 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.
The experimental results demonstrate that DE achieved the most consistent and robust performance among the evaluated algorithms, reaching an average annualized return of 107.36%, and exhibited the lowest dispersion across runs, indicating greater stability against the stochastic nature of Metaheuristic optimization. However, the behavior of the Diversity metric is not consistent with what is presented in the literature [24,25,26], which could be answered with the great variability of the search space, and the large number of local optima that are common in problems in discrete domains [27].
The structure of this work is as follows: In Section 2, we present the main studies that deal with a topic similar to the one addressed in this work. In Section 3 we discuss the main concepts to be taken into account in the development of the methodology, focusing on the formulation of optimization problems and the optimization strategy proposed. Section 4 presents the methodology. Finally, in Section 5 we show the results of applying our methodology to a particular problem, and in Section 6 we discuss our conclusions.

2. Related Work

The application of Metaheuristics to the optimization of financial strategies has gained prominence in recent years, proving effective for addressing the highly nonlinear, noisy, and high-dimensional objective landscapes that characterize financial markets [28]. In this context, classical approaches such as GA and PSO have shown strong performance both in calibrating trading rules and in tuning hyperparameters of predictive models [5]. The versatility of these techniques extends to portfolio management, predictive modeling, and algorithmic trading; indeed, Bousbaa and Bencharef provide a comprehensive review of Metaheuristics in finance, highlighting their capacity to handle the stochastic and volatile nature of financial time series and organizing use cases into (i) hyperparameter tuning, (ii) pattern discovery in historical data, and (iii) optimization of trading-rule parameters [29]. Along the same lines, Soler Domínguez et al. emphasize the advance of hybrid approaches to improve robustness and profitability [30].
Within indicator-based strategies, Kuo and Chou (2021) extended moving-average systems through a dynamic scheme optimized with a quantum-inspired Metaheuristic (best-Guided Quantum Tabu Search), yielding rules that are more adaptive to heterogeneous market regimes [23]. More recently, Corazza et al. (2024) proposed a system that simultaneously optimizes indicator settings, rule definitions, and signal aggregation via PSO, achieving results superior to traditional technical-analysis strategies and exhibiting greater adaptability [31]. In related domains, evolutionary algorithms have also proven effective for optimizing exit criteria and multiple strategy parameters under high volatility [32,33]. Likewise, the energy-market literature using agent-based models has shown that evolutionary and Metaheuristic optimization supports decision-making in decentralized and volatile systems [34], and its integration into analytics platforms for strategic decision-making in corporate environments is increasingly reported [23,35].
In cryptocurrency markets, multi-objective optimization is gaining traction: Omran et al. optimize rules in Litecoin with a decomposition-based variant of MOPSO, simultaneously balancing return, Sortino ratio, and number of trades, and showing that explicitly accounting for multiple goals improves stability and the risk–return profile relative to standard parameters (e.g., fixed configurations) [36]. In parallel, a line of simple yet adaptive strategies has emerged: Romo et al. combine 2-SMA with a Learning-Based Linear Balancer ( L B 2 ) that dynamically adjusts parameters to maximize performance on BTCUSDT with realistic costs, outperforming Buy and Hold and the non-optimized 2-SMA while preserving interpretability [21]. These results suggest that (near) real-time adaptation via Metaheuristics can yield consistent gains without sacrificing the transparency of rules.
The hybridization of Metaheuristics and deep learning also appears in time-series prediction: Nayak et al. propose a meta-transformer that uses PSO, GWO and WOA to tune Transformer hyperparameters, outperforming GARCH in RMSE/MAE and evidencing the synergy between deep models and evolutionary optimization [37]. Complementarily, Dökeroğlu et al. review Metaheuristics from 2019 to 2024, cautioning about the proliferation of variants and recommending scrutiny of search mechanisms (to avoid premature convergence) and the prioritization of reproducible configurations—both of which are crucial when selecting algorithms for financial domains [38].
Another salient line is deep reinforcement learning (DRL) applied to trading. Zhou et al. introduce R-DDQN, integrating a reward network trained with human feedback, and report substantial improvements over baselines on indices and equities [22]. Huang et al. propose a self-rewarding mechanism (SRDRL) that combines reward prediction with expert labels, achieving greater stability and high cumulative returns on stock indices [39]. For continuous control, Majidi et al. employ TD3 to enable continuous actions (size/position) and observe improvements in Sharpe and profitability relative to discrete-rule baselines [40]. On the purely predictive side, comparisons between LSTM and GRU show that incorporating sentiment enhances accuracy, and that a strengthened GRU can outperform alternatives on Bitcoin; however, these models act as black boxes, and their direct translation into operable rules is not always straightforward [41,42].
Taken together, the literature converges toward (i) hybrid Metaheuristics, (ii) multi-objective optimization, (iii) DRL with adaptive rewards, and (iv) deep models to optimize strategies and forecasts. However, many proposals sacrifice interpretability and rely on static validations that fail to reflect real-world operation. Moreover, few studies systematically compare multiple Metaheuristics on interpretable, rule-based strategies under realistic protocols (e.g., rolling-window evaluation with non-parametric tests and overfitting control). This work addresses that gap by comparing four Metaheuristics (DE, PSO, WOA, GWO) in a single-objective framework with rolling-window validation, preserving interpretable rules and a statistically grounded protocol to connect search efficiency with operational clarity.

3. Background

In this section, we will review the topics needed to fully understand the methodology proposed in this work.

3.1. Optimization Problems

An optimization problem involves finding the optimal value for every decision variable x R n that either minimizes or maximizes an objective function. This process may be subject to certain constraints. Formally, an optimization problem can be described as
minimize or maximize f ( x )
subject to x D R n
g i ( x ) 0 , i = 1 , , m
In this case: f ( x ) is the objective function, x is the decision variable, D is the feasible domain, and g ( x ) represents the system’s constraint. This mathematical framework underlies a wide range of applications, including financial strategy optimization, where the objective may involve maximizing returns, minimizing risk, or both.

3.2. Metaheuristic Optimization Algorithms

Within the field of optimization, there are exact and approximate solution methods. Metaheuristics, are approximate optimization methods that provide high-quality solutions with reasonable computational effort and can be applied to a wide range of optimization problems [43]. They rely on mechanisms such as natural selection and mutation to evolve a population of solutions toward an optimum [44].
To solve this optimization problem, we employ four well-established Metaheuristic algorithms: Differential Evolution (DE) [17], Particle Swarm Optimization (PSO) [18,45], Whale Optimization Algorithm (WOA) [19], and Grey Wolf Optimizer (GWO) [20]. These population-based methods were selected for their proven ability to handle nonlinear, non-differentiable search spaces characteristic of financial problems [46]. Since the mechanics of these algorithms are widely documented in the literature, we omit their detailed mathematical descriptions to focus on their application and the proposed validation framework. The specific control parameters used for each algorithm are specified later in the manuscript.

3.3. Rolling Windows Validation

Rolling Window Validation is a resampling technique specifically developed for time series data, where temporal dependencies must be preserved (like a stock market). Rolling window methods split the dataset into ordered, overlapping segments, each consisting of a training window. The training window is moved forward by a fixed step (the “roll”), discarding the oldest observations and including the next in sequence. This approach allows the model or strategy to be retrained periodically on the most recent data.
This method ensures robustness in a stochastic environment [23], enabling consistent performance despite uncertainty and fluctuations in the underlying system. However, the method increases computational cost due to repeated training and testing cycles, and requires careful selection of window sizes to balance recency and statistical reliability [47]. Formally, let P = { P t } t = 1 T be the price time series of length T. We define a training window size W s i z e and a step size W s t e p (the roll). The validation process consists of K iterations. For the k-th iteration (where k = 1 , , K ), the training set D t r a i n ( k ) is defined as the subset of chronologically ordered observations,
D t r a i n ( k ) = { P t t s t a r t ( k ) t t e n d ( k ) }
where the start and end indices for each window are calculated as follows:
t s t a r t ( k ) = 1 + ( k 1 ) · W s t e p
t e n d ( k ) = t s t a r t ( k ) + W s i z e 1
subject to the constraint t e n d ( k ) T . This formulation mathematically describes the rolling windows process illustrated in Figure 1.

3.4. Technical Indicators

Technical indicators are statistical tools applied to historical market data, such as price or volume, with the goal of identifying patterns, trends, and potential reversals. These indicators assist traders and analysts in making informed decisions by providing insights into market dynamics; for instance, Simple Moving Average (SMA) computes the average price over a period to smooth out short-term fluctuations and identify trends. The formulas for some commonly used indicators are presented in Table 1, in this case, P i is the closed price at time i, N represents the number of periods considered, and k is a constant.

3.5. Trading Strategies

A trading strategy is a set of rules that determine when to open or close positions in the market. These rules are based on the interpretation of technical indicators and are designed with the objective of maximizing returns and/or minimizing risk. For instance, a typical rule might be: "Open a long position when the short-term Simple Moving Average (SMA) crosses above the long-term SMA, and close the position when the reverse crossover occurs." Such strategies can be systematically tested and optimized using historical data to improve their robustness and performance as follows:
  • Open position if S M A s h o r t > S M A l o n g R S I < 70 .
  • Close position if S M A s h o r t < S M A l o n g R S I > 80 .
This work use a simple strategy, selected by their didactic value and ability to show how their performance can change significantly based on the proper optimization of their parameters.

4. Proposed Approach

We address the problem of optimizing technical trading strategies with single-objective optimization techniques in order to identify parameter settings that provide an optimal trade-off between return and risk. A strategy that generates very high returns might also be extremely volatile, exposing a trader to significant losses. Conversely, a low-risk strategy might only yield minimal returns.

4.1. Problem Model

A single-objective optimization problem seeks the best solution with respect to a single criterion. In trading strategy design, this typically involves maximizing average returns. Solving such problems exactly requires an exhaustive exploration of the decision space to identify the global optimum, which is computationally prohibitive when the search space is high-dimensional and nonlinear and when each evaluation is costly due to simulation-based assessments [48]. These limitations justify the use of Metaheuristic approaches, which can approximate high-quality solutions within reasonable computational budgets, even though they do not guarantee global optimality [49].
We briefly summarize the formal structure of the optimization problem to clarify how the proposed trading strategy formulation maps onto the general mathematical framework. We consider the following: Let x be the vector of strategy hyperparameters to be optimized; for this strategy, the hyperparameters are described in Table 2. The evaluation of a candidate solution is performed using a rolling-window approach, where W denotes the size of each window and M is the total number of windows. For a given window j, the trading strategy generates a return r ( j ) ( x ) .
The average return across all windows is given by
μ ( x ) = 1 M j = 1 M r ( j ) ( x )
Therefore this single objective problem aims to maximize the average return μ ( x ) . To solve it, we apply the rolling windows technique [47], transforming the problem into the following single-objective optimization:
f ( x ) = μ ( x ) , to be maximized .
subject to
g ( x ) = max t D t D threshold 0
where D t is the duration of the t-th trade within the training period and D threshold is the maximum allowed trade duration (5 days or 432,000 s); this constraint penalizes configurations with excessively long trades, which are not viable for short- or medium-term strategies.
Solving this problem would require an unacceptable amount of time and computational resources due to the non-convex, simulation-based nature of f ( x ) [48] and these characteristics make exact methods impractical; that is why we use Metaheuristics, which do not rely on gradients or convexity assumptions. The fitness function that determines how good a solution is defined as Equation (5), and its constraints in Equation (6).

4.2. Proposed Methodology

The optimization of trading strategies typically involves a non-convex and non-differentiable solution space, which limits the applicability of traditional gradient-based and convex optimization methods [46]. To effectively address these challenges, we employ four population-based Metaheuristics: Differential Evolution (DE), Grey Wolf Optimizer (GWO), Whale Optimization Algorithm (WOA), and Particle Swarm Optimization (PSO), as they do not require derivatives and can efficiently explore irregular and multimodal search spaces. Each Metaheuristic is executed independently 31 times for 1000 iterations with a population size of 50 solutions. Additional modifications specific to this problem and methodology are detailed later.
Regarding the data employed, a rolling-window approach was applied, in which the training data was split into a series of overlapping windows. The configuration used throughout this study consists of an 8-month training window and a 4-month step. This choice was guided by pragmatic considerations: an eight-month window is long enough to encompass multiple micro-regimes and provide reliable estimates for SMA parameters up to 200 periods, while a four-month roll offers a practical balance between overlap, adaptability, and computational cost. The resulting 50% overlap also helps mitigate the influence of anomalous subperiods by smoothing transitions between windows. All experiments reported in this paper were executed under the 8-month/4-month scheme described above. This approach aligns with standard walk-forward validation techniques widely used in algorithmic trading research [50], which repeatedly retrain models on in-sample periods and test on subsequent out-of-sample data to evaluate performance over time. This is particularly important for our proposed trading strategy, which relies on four Simple Moving Averages (SMA). Although a full sensitivity analysis is beyond the scope of this work, preliminary exploratory checks with shorter (4–6 months) and longer (10–12 months) windows, as well as alternative step sizes, indicated that while absolute performance metrics may vary, the relative performance ranking of the Metaheuristics remained stable.

Proposed Strategy

The proposed strategy, named “Four-SMA Crossover” (hereafter referred to as the SMA strategy for short), is based on signals generated by four Simple Moving Averages, with rules for opening and closing positions according to their crossovers and dynamic ‘take-profit’ (stop-win) and ‘stop-loss’ (stop-loss) levels. The optimizable parameters are described in Table 2. Before detailing the strategy rules, we clarify three key properties of the strategy that are implicitly reflected in the pseudocode. First, the strategy follows a one-position-at-a-time policy: at any given moment, the system may hold either a long or short position, or remain flat, but never two positions simultaneously. Second, both the stop-loss and take-profit levels are updated in a trailing manner, meaning that they adjust dynamically as the price moves in favor of the position while remaining fixed when the price moves against it. Third, all time-dependent variables follow the index convention t for the current candle, t 1 for the previous candle, and t 2 for two periods prior; in particular, crossover signals are evaluated using ( t 2 , t 1 ) to avoid look-ahead bias and ensure proper alignment with backtesting execution.
We can formally describe each SMA as follows:
S M A 1 t = S M A ( C , l e n s m a 1 ) t
S M A 2 t = S M A ( C , l e n s m a 2 ) t
S M A 3 t = S M A ( C , l e n s m a 3 ) t
S M A 4 t = S M A ( C , l e n s m a 4 ) t
where C is the closing price at time t. Therefore, references like S M A 1 t 1 indicate the value of S M A 1 in the previous period, and S M A 1 t 2 indicates the value of S M A 1 two periods prior. A long position is opened at time t if the S M A 1 crosses above S M A 2 , as shown in Equation (7),
S M A 1 t 2 S M A 2 t 2 S M A 1 t 1 > S M A 2 t 1
Upon opening a long position, the entry price is defined as P e n t r y l o n g = C t 1 and M a x I n L o n g t = C t 1 . The long take-profit level is S W L t = C t 1 · k s w l , and the long stop-loss level is defined as S L L t = C t 1 · k s l l . If a long position is already open at time t and the current closing price is greater than the maximum price reached since the position was opened,
M a x I n L o n g t = C t 1
S L L t = C t 1 · k s l l
Otherwise,
M a x I n L o n g t = M a x I n L o n g t 1
S L L t = S L L t 1
The long position closes if one of the following conditions is met:
C t 1 > S W L t 1
C t 1 < S L L t 1
In essence, a long position remains open until the closing price exceeds the long take-profit level or falls below the long stop-loss level. A short position is opened at time t if the following condition is met:
S M A 3 t 2 S M A 4 t 2 S M A 3 t 1 < S M A 4 t 1
Upon opening a short position, the entry price is defined as P e n t r y s h o r t = C t 1 and M i n I n S h o r t t = C t 1 , the short take-profit (stop win) level is given by S W S t = C t 1 · k s w s , and the short stop-loss level is defined as S L S t = C t 1 · k s l s . If a short position is already open and the current closing price is less than the minimum price reached since the position was opened,
M i n I n S h o r t t = C t 1
S L S t = C t 1 · k s l s
The short position closes if one of the following conditions is met:
C t 1 < S W S t 1
C t 1 > S L S t 1
The pseudocode for the Four-SMA Crossover strategy is provided next (see Algorithm 1), detailing the sequence of operations required to evaluate trading signals, manage open positions, and apply the take-profit and stop-loss rules. This structured representation allows for a clearer understanding of the decision-making process and facilitates its implementation in different computational environments.
Algorithm 1 Four-SMA Crossover
  1:
Initialize p o s i t i o n = none
  2:
for each t from 2 to T do
  3:
      Compute S M A 1 t , S M A 2 t , S M A 3 t , S M A 4 t
  4:
      if  p o s i t i o n = none  then
  5:
          if  S M A 1 t 2 S M A 2 t 2 and S M A 1 t 1 > S M A 2 t 1  then
  6:
               Open long position at C t 1
  7:
                M a x I n L o n g = C t 1 ,      S L L = M a x I n L o n g · k s l l
  8:
          end if
  9:
          if  S M A 3 t 2 S M A 4 t 2 and S M A 3 t 1 < S M A 4 t 1  then
10:
               Open short position at C t 1
11:
                M i n I n S h o r t = C t 1 ,      S L S = M i n I n S h o r t · k s l s
12:
          end if
13:
      else
14:
          if  p o s i t i o n = long  then
15:
             if  C t 1 > M a x I n L o n g  then
16:
                    M a x I n L o n g = C t 1 ,      S L L = M a x I n L o n g · k s l l
17:
             end if
18:
             if  C t 1 < S L L  then
19:
                   Close long position
20:
                    p o s i t i o n = none
21:
             end if
22:
          else if  p o s i t i o n = short  then
23:
             if  C t 1 < M i n I n S h o r t  then
24:
                    M i n I n S h o r t = C t 1 ,      S L S = M i n I n S h o r t · k s l s
25:
             end if
26:
             if  C t 1 > S L S  then
27:
                   Close short position
28:
                    p o s i t i o n = none
29:
             end if
30:
          end if
31:
      end if
32:
end for

4.3. Performance Metrics and Backtest Assumptions

To evaluate the effectiveness of the optimized trading strategies, we utilize a comprehensive set of performance metrics generated by the backtesting.py library [51]. These metrics provide insights into various aspects of a strategy’s profitability, risk, and efficiency. Key metrics employed in this study are described in Table 3 below.
These metrics collectively allow for a thorough and rigorous assessment of the optimized strategies, covering absolute profitability, risk-adjusted returns, drawdown resilience, and trade-level efficiency. In the context of this study, annualized return and annualized volatility are considered the most critical indicators [52], as they directly reflect the quality of the solutions. Ratios such as the Sharpe and Sortino further capture the stability of returns, particularly important in the highly volatile cryptocurrency market, while trade-level metrics like win rate, profit factor assess the consistency and robustness of the strategy’s execution. The Diversity metric used in this paper is employed to monitor how the Metaheuristic algorithms evolve over time [53], allowing an in-depth analysis of their search behavior during the optimization process; this helps to identify whether the algorithm is effectively exploring new regions of the search space or converging prematurely toward local optima. To ensure reproducibility, backtest.py was programmed to mimic fees and conditions of Binance to prevent any form of look-ahead bias as follows:
  • 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.
Lets notate the equity series at each timestep as e q u i t y , the total return is computed as [54]
r = e q u i t y [ 1 ] e q u i t y [ 0 ] 1
The effective training duration of the backtest corresponds to the number of trading days in the dataset, denoted as d. In this dataset we have a 356 day trading year; therefore, the annual return can be described as [54]
r a n n u a l = ( 1 + r ) 365 / d 1
The daily volatility is scaled to an annual horizon following the classical square-root-of-time rule [55],
σ = S T D ( r t ) 365

4.4. Diversity

Metaheuristics perform two types of movements: Exploration (Global Search) and Exploitation (Local Search). Exploration refers to an algorithm’s ability to search broad and diverse regions of the search space (the set of all possible solutions) [56]. Its primary goal is to prevent stagnation and avoid becoming trapped in local optima. Exploitation, on the other hand, is the ability to refine and improve already found solutions within a promising region of the search space. However, too much Exploration make the Metaheuristic to constantly move to new areas without focusing on improving any specific solution, while too much Exploitation will lead the algorithm to quickly converge to a local optimum and will be unable to escape to find the global optimum [57]. This balance is quantified through Diversity.
To calculate Diversity in an algorithm we use the definition proposed by Hussain et al. [53],
D i v = 1 l · n d = 1 l i = 1 n | x ¯ d x i d |
In this equation, x ¯ d denotes the mean value of all individuals along dimension d, while x i d represents the i-th individual’s value in that dimension, the term | x ¯ d x i d | measures the distance between an individual x i from the population center x ¯ . Here, n corresponds to the population size, and l denotes the dimensionality of each individual. The percentages of exploration (XPL%) and exploitation (XPT%) are calculated following the approach proposed by Morales-Castañeda [24],
X P L % = D i v D i v m a x · 100
X P T % = | D i v D i v m a x | D i v m a x · 100
D i v is the Diversity defined in Equation (22) while D i v m a x is the maximum Diversity found through the optimization. Each percentage is complementary; therefore, for any moment in the optimization process,
X P L % + X P T % = 100 %
This metric serves as a search behavior guide, providing insights into how a Metaheuristic algorithm transitions between exploration and exploitation during the optimization process. Plotting these values across generations or iterations helps to identify phases of convergence, premature stagnation, or excessive wandering, allowing a deeper understanding of the algorithm’s dynamics and its ability to balance diversification and intensification throughout the search process.

5. Experimental Results

5.1. Data Employed

A dataset from Binance for the BTC/USDC market pair was employed, containing OHLC (Open, High, Low and Close) data sampled every 5 min from 1 January 2020 to 31 March 2025. The data was chronologically ordered, indexed by timestamp, and split into two subsets: a training set (1 January 2020–31 December 2022 see Figure 2 and a validation set (1 January 2023–31 March 2025). The training period was selected to capture a wide range of volatile market conditions.

5.2. Experimental Setup

Table 4 summarizes the main control parameters and their corresponding ranges or fixed values for each Metaheuristic algorithm applied in this study. These configurations were selected based on recommendations from the literature and preliminary tuning experiments to ensure competitive performance.
For the rolling window configuration, we use a window length of 8 months with a roll (step size) of 4 months, resulting in overlapping training periods. For example, the first window spans from January 2020 to August 2020, and the next window spans from May 2020 to December 2020. This setup ensures that the strategy is evaluated under multiple market conditions while maintaining a sufficient amount of historical data for parameter optimization. The comparative results in terms of average, best, and dispersion of performance across all seeds are presented in Table 5. Among the tested algorithms, DE achieved the most stable and consistently high returns, with a narrow distribution centered around 400% in the training stage and exceeding 450% in some validation cases. In contrast, GWO and PSO reached higher best-case values (close to 500%), but at the cost of a much wider dispersion, including runs with strongly negative outcomes. WOA showed intermediate behavior, with robust median returns but also outliers reflecting sensitivity to parameter initialization.
A closer inspection of the optimal solutions reveals recurring patterns: several top-performing configurations favored shorter SMA lengths combined with elevated stop-win factors, increasing responsiveness to short-term price fluctuations. While this amplified potential returns, it also magnified volatility, in line with prior studies on momentum driven SMA strategies [58]. The elevated volatility levels often exceeding 90%, consistent with the intrinsic variability of the BTC/USDC pair [59] and the near continuous exposure inherent in SMA-based strategies. Given the crossing-rule design and static stop levels, all optimized strategies (DE, PSO, WOA, and GWO) maintained near-constant exposure to market movements, naturally reflecting and amplifying underlying asset fluctuations [58].
Figure 3, Figure 4 and Figure 5 illustrate these findings. Figure 3 shows the distribution of average returns per algorithm, highlighting DE’s consistency compared to the broader variability of the swarm-based methods. Figure 4 presents the distribution of standard deviations, confirming that DE is the most volatile in absolute terms but more centered, while GWO and PSO present the largest spread, indicating higher instability across seeds. Finally, Figure 5 displays the best-case results, where PSO and GWO stand out with extreme returns in certain runs, albeit with proportionally high risk.

5.3. Statistical Comparison

Due to the nature of the data, which do not follow a normal distribution and are independent from each other, a Wilcoxon–Mann–Whitney test was conducted to gain an additional perspective on the distributional differences (Table 6). Key findings from this test reinforced the earlier results: DE has a highly significant difference in the average return, outperforming WOA, and DE also presents the highly significant difference in the Std. Dev. Return comparison in the test. DE vs GWO confirmed the significant difference, with DE surpassing GWO in this maximum performance metric.
The statistical analysis reveals a general lack of consistent dominance among the Metaheuristics for most return metrics, reflecting the stochastic nature of Metaheuristic optimization [60] in financial strategy tuning [58]. However, DE stands out for its consistency by showing significant differences that position it above WOA in Average Return and GWO in Best Validation Return.
The most robust difference lies in Std. Dev. Return: DE exhibits a statistically different and higher distribution of the Standard Deviation of Return than GWO, WOA, and PSO. This is consistent with the observation that DE’s optimal configurations favored parameters that, while maximizing returns (Table 5), also induced greater exposure and, consequently, higher volatility. This variation underscores the inherent instability and high variability of the results [60], suggesting that while DE achieved the absolute highest maximum value, the overall distribution of the best cases is not overwhelmingly dominant against all others. These outcomes are consistent with the high intrinsic variability of the BTC/USDC pair [59] and the nature of Simple Moving Average (SMA)-based strategies [58].
To further explore the capabilities of each algorithm, this section analyzes the parameter configurations that achieved the highest validation-period return for each of the four tested Metaheuristics. This perspective allows comparing the performance peaks discovered by each optimizer, highlighting the distinct risk–return profiles emerging from their respective search dynamics. All optimized strategies significantly outperformed a passive Buy and Hold (397.93%) benchmark.
The following table summarizes the key metrics of the best run for each Metaheuristic.
The analysis of the best-performing configurations reveals distinct strategic profiles, evidencing that each Metaheuristic explored and exploited the search space in a unique manner.
WOA discovered the configuration yielding the highest annualized return (120.28%). Remarkably, it also achieved the highest profit factor (5.06) and Sortino Ratio (3.95), along with the lowest maximum drawdown (−28.66%). These results suggest that WOA effectively balanced profit maximization with downside risk control, uncovering a particularly robust trading configuration. PSO converged to a high-frequency strategy (51 trades) characterized by an exceptionally high win rate (94.12%). This translated into the highest Sharpe Ratio (1.086), indicating superior efficiency per unit of total risk. However, its focus on frequent small gains made it vulnerable to large drawdowns, reflected in the worst maximum drawdown (−37.13%) among all methods. GWO achieved the second-highest annualized return (116.79%) and maintained a strong win rate (82.50%). This profile reflects an aggressive yet reliable trading behavior. Nevertheless, its profit factor (2.74) was considerably lower than that of other algorithms, indicating that while its winning trades were frequent, the magnitude of losses was relatively larger. DE identified a low-frequency, trend-following strategy with only 20 trades and an average holding period of 39 days. Although its return (108.86%) was the lowest among the four, it achieved a high profit factor (4.11), suggesting strong performance per trade. This configuration aligns with long-term trend-capturing behavior, prioritizing the magnitude of profits over trading frequency.
These outcomes align with the statistical evidence presented earlier: despite DE reaching one of the highest individual peaks, its distribution of returns exhibits greater variability compared to WOA, GWO, and PSO. This confirms that while DE can uncover extremely profitable configurations, it does so with higher volatility and instability, consistent with the stochastic nature of Metaheuristic search and the inherent variability of SMA-based BTC/USDC strategies [58,59].
It is also important to note that during a strongly bullish market phase, such as the one observed in the validation period, the relative advantage of active strategies tends to diminish, as even a passive Buy and Hold approach captures most of the upward momentum. Consequently, outperforming the market in absolute terms becomes increasingly challenging, and the value of Metaheuristic optimization lies primarily in achieving superior risk-adjusted performance rather than merely higher nominal returns.

5.4. Diversity Analysis of the Search Process

To complement the quantitative performance evaluation, the Diversity metric was employed to analyze the Exploration and Exploitation dynamics of each Metaheuristic during optimization. This analysis allows for an understanding of how each algorithm arrived at its results and explains their differing performance. The reader can observe this behavior in the graphs presented in Figure 6. Each sub-figure displays the percentage of exploration (blue/black line) and exploitation (orange line) across the 1000 generations of the optimization process for each algorithm.
Figure 6a shows the behavior of DE exploration is consistently maintained around 80–85%, while exploitation accounts for the remaining 15–20% throughout the entire process. More on this matter in Section 5.4. Figure 6b and Figure 6d illustrate a very different search profile for GWO and PSO, respectively. Both algorithms begin with a brief, chaotic exploration phase that quickly gives way to a dominant exploitation phase. After approximately 350 generations, exploration becomes almost nonexistent. This rapid focus on exploitation explains why these algorithms can achieve extreme returns in some runs (Figure 5) but also why their results are so variable and unstable. Figure 6c shows that WOA exhibits an intermediate behavior. The algorithm begins with strong exploration that gradually decreases, while exploitation steadily increases until it becomes the dominant behavior. This smoother transition between global and local search aligns with its intermediate performance; it is more robust than GWO and PSO but less consistent than DE.

On the Persistent Diversity of Differential Evolution

DE maintained a persistently high level of exploration throughout the entire optimization process. This behavior arises from the inherently multimodal landscape of financial optimization [46], where different regions of the search space lead to solutions of nearly equivalent quality.
It is presumed that the DE population tends to occupy several basins of attraction simultaneously, producing functional convergence without geometric convergence. Consequently, the Diversity metric (see Equation (22)), which is based on Euclidean dispersion around the population centroid, interprets this spatial separation as sustained exploration, even when the algorithm has stabilized in terms of fitness. Ergo, this does not mean inefficiency in finding good solutions but rather robust adaptation to a fragmented and non-stationary search space. As a consequence, the observed anomalous Diversity reflects the coexistence of multiple stable niches within the solution space.

6. Conclusions

This study addressed the optimization of algorithmic trading strategies via Metaheuristics under a realistic temporal validation protocol. Within a unified experimental framework, we compared four population-based search algorithms (DE, GWO, WOA, and PSO) to calibrate an interpretable moving-average-based strategy, using walk-forward evaluation through rolling windows and nonparametric statistical testing. The objective was to maximize profitability while maintaining robustness to volatility and regime shifts. The results confirm that Metaheuristic optimization substantially improves effectiveness and stability relative to non-optimized configurations, thereby meeting the study’s goals.
Among the findings, DE stood out for its across-run consistency, achieving an average annualized return around 107% (Table 5) with the lowest dispersion across executions, which suggests a more predictable performance in the face of stochastic search. The Wilcoxon–Mann–Whitney contrast indicated significant differences in favor of DE versus WOA for mean return (p < 0.01) and versus GWO for best validated return (p = 0.02), thus reinforcing the statistical validity of its advantage. Even so, the best configurations discovered by DE exhibited the highest absolute volatility among methods, indicating that its average consistency coexists with solutions that take on greater risk exposure—a feature consistent with moving-average strategies on cryptoassets.
The comparative analysis reveals complementary profiles and distinct risk-return trade-offs. WOA achieved the best single execution in annualized return ((≈120.3%), Table 7), together with the highest profit factor (5.06), the best Sortino (3.95), and the most contained maximum drawdown (−28.7%), evidencing an attractive balance between gains and loss control. PSO tended toward high-frequency strategies (51 trades in its best run) with an exceptional hit rate (94.1%) and the highest Sharpe (≈1.09), albeit at the cost of the most severe maximum drawdown (−37.1%), exposing vulnerability to sharp declines despite strong average efficiency. GWO attained the second-best return (≈116.8%) with a high hit rate (≈82.5%), but with a lower profit factor (2.74), indicating frequent gains offset by losses of relatively greater magnitude. In sum, no Metaheuristic dominated all metrics; each offered a different balance among profitability, volatility, and stability, consistent with its search mechanics. A summary of the recommended use cases, advantages, and disadvantages of each Metaheuristic is provided in Table 8 to guide strategy selection based on specific risk-return objectives.
As a benchmark, all optimized strategies outperformed buy-and-holdon risk-adjusted measures. Even though the validation period included a markedly bullish phase during which BTC/USDC buy-and-hold approached 398% cumulative, Metaheuristic strategies matched or exceeded that benchmark with lower risk exposure and greater temporal consistency. Improvements in Sharpe and Sortino support that the added value of the approach lies less in pursuing extreme raw returns and more in raising risk-return efficiency and operational resilience.
These findings enable answers to the research questions. First, Metaheuristic optimization of simple rules does increase profitability and robustness relative to non-optimized configurations under real data and temporal evaluation. Second, DE emerged as the most consistent method on average, validating the hypothesis that an evolutionary algorithm with a sound exploration–exploitation balance can surpass swarm schemes in stability; nevertheless, its average advantage coexists with higher volatility in optimal solutions, so algorithm choice should align with the success criterion (average robustness versus peak returns). Third, rolling-window validation evidenced temporal generalization: strategies sustained positive performance across subperiods with different dynamics, reducing the risk of overfitting to idiosyncratic intervals.
The robustness and validity of the conclusions rest on multiple independent seeds, nonparametric tests for between-algorithm contrasts, and a walk-forward protocol that approximates real operating conditions. The consistency of observed patterns (e.g., higher inherent volatility in SMA-based strategies on cryptoassets) with theoretical expectations and prior evidence further strengthens the external plausibility of the results.
Regarding implications, the methodological contribution lies in a replicable framework that combines temporal validation, standardized comparison of Metaheuristics, and monitoring of search dynamics useful for future studies and for quants who require comparable evaluations. Practically, the findings offer selection criteria by objective: (i) DE when stability across re-optimizations is prioritized; (ii) WOA when seeking a single-run balance of return and risk; (iii) PSO to exploit short-term opportunities while accepting greater sensitivity to drawdowns. Theoretically, the contrast between evolutionary and swarm approaches provides evidence on how update rules condition the risk-return balance of the resulting solutions.
This work has limitations that bound the scope of generalization. The analysis was restricted to a single asset/market (BTC/USDC) and to a family of rules based on moving averages with exit thresholds. Sensitivity to the internal hyperparameters of each Metaheuristic (population sizes, rates, stopping criteria) was not examined, nor were ex-ante experimental-design choices optimized, such as the length and overlap of training windows or the 5-day limit on holding open positions.
Based on this, we outline avenues for future work. Extending the evaluation to other markets and assets would verify whether different environments favor different Metaheuristics. Incorporating additional evolutionary algorithms (e.g., GA) would clarify whether DE’s advantage in consistency is generalizable or specific. Increasing strategy complexity with momentum or volatility-based indicators would assess the framework’s generality beyond SMA. Exploring multiobjective optimization (e.g., return–volatility or Sortino/Sharpe ratios) would yield explicit compromise solutions. Conducting meta-optimization of Metaheuristic hyperparameters would estimate their impact on the relative ranking. Evaluating transfer functions or related mechanisms for discrete variables would enable optimizing structural decisions in the strategy. Analyzing how the DE Diversity behavior emerges from the presence of multiple distant optima, clarifying whether such dispersion consistently enhances robustness or merely reflects structural properties of the financial search space. And finally, analyzing sensitivity to window length and to the 5-day limit would quantify their effect on performance and robustness.

Author Contributions

Conceptualization, K.H.-R. and A.R.; methodology, K.H.-R. and J.L.-R.; software, K.H.-R. and J.L.-R.; validation, K.H.-R. and J.L.-R.; formal analysis, K.H.-R. and J.L.-R.; investigation, A.R., E.V. and A.R.; resources, A.R. and K.H.-R.; data curation, K.H.-R.; writing—original draft preparation, K.H.-R.; writing—review and editing, J.L.-R., M.B.-R. and E.V.; visualization, K.H.-R. and J.L.-R.; supervision, J.L.-R., M.B.-R. and E.V.; project administration, E.V.; funding acquisition, E.V. and M.B.-R. All authors have read and agreed to the published version of the manuscript.

Funding

Marcelo Becerra-Rozas is supported by DI Iniciación PUCV 2025/PUCV/039.725/2025. Emanuel Vega is supported by proyecto di investigación asociativa interdisciplinaria 2025. cod. proyecto: 039.774/2025.

Data Availability Statement

The data presented in this study are available upon request from the corresponding author.

Acknowledgments

The authors are grateful to the editor and anonymous reviewers for their constructive comments and valuable suggestions to improve the quality of the article.

Conflicts of Interest

The authors declare no conflicts of interest.

Abbreviations

The following abbreviations are used in this manuscript:
GAGenetic Algorithm
DEDifferential Evolution
GWOGrey Wolf Optimization
WOAWhale Optimization Algorithm
PSOParticle Swarm Optimization
BTCBitcoin
DivDiversity
XPTExploitation
XPLExploration
SMASimple Moving Average
STDStandard Deviation

References

  1. 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]
  2. 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]
  3. 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]
  4. 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]
  5. 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]
  6. 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]
  7. 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]
  8. 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]
  9. 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]
  10. 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]
  11. 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]
  12. Suhonen, A.; Lennkh, M.; Perez, F. Quantifying Backtest Overfitting in Alternative Beta Strategies. J. Portf. Manag. 2017, 43, 90–104. [Google Scholar] [CrossRef]
  13. 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]
  14. 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]
  15. 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]
  16. Dolvin, S. The Efficacy of Trading Based on Moving Average Indicators: An Extension. J. Wealth Manag. 2014, 17, 140410000314006. [Google Scholar] [CrossRef]
  17. 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]
  18. 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]
  19. Mirjalili, S.; Lewis, A. The Whale Optimization Algorithm. Adv. Eng. Softw. 2016, 95, 51–67. [Google Scholar] [CrossRef]
  20. Mirjalili, S.; Mirjalili, S.M.; Lewis, A. Grey Wolf Optimizer. Adv. Eng. Softw. 2014, 69, 46–61. [Google Scholar] [CrossRef]
  21. 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]
  22. 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]
  23. 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]
  24. 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]
  25. 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]
  26. 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]
  27. 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]
  28. 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]
  29. 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]
  30. Soler-Dominguez, A.; Juan, A.A.; Kizys, R. A Survey on Financial Applications of Metaheuristics. ACM Comput. Surv. 2017, 50, 15. [Google Scholar] [CrossRef]
  31. 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]
  32. 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]
  33. 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]
  34. Trimarchi, S.; Casamatta, F.; Grimaccia, F. A Review of Agent-Based Models for Energy Commodity Markets. Energies 2024, 18, 3171. [Google Scholar]
  35. 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]
  36. 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]
  37. 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]
  38. Dokeroglu, T.; Canturk, D.; Kucukyilmaz, T. A survey on pioneering metaheuristic algorithms between 2019 and 2024. arXiv 2024, arXiv:2501.14769. [Google Scholar]
  39. 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]
  40. Majidi, N.; Shamsi, M.; Marvasti, F. Algorithmic trading using continuous action space deep reinforcement learning. Expert Syst. Appl. 2024, 235, 121245. [Google Scholar] [CrossRef]
  41. 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]
  42. 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]
  43. 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]
  44. Sampson, J.R. Adaptation in Natural and Artificial Systems (John H. Holland). SIAM Rev. 1976, 18, 529–530. [Google Scholar] [CrossRef]
  45. 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]
  46. 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]
  47. 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]
  48. 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]
  49. 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]
  50. Pardo, R.E. The Evaluation and Optimization of Trading Strategies, 2nd ed.; John Wiley & Sons: Hoboken, NJ, USA, 2008. [Google Scholar]
  51. 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).
  52. 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]
  53. 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]
  54. Bodie, Z.; Kane, A.; Marcus, A.J. Investments, 10th ed.; McGraw-Hill Education: Columbus, OH, USA, 2014. [Google Scholar]
  55. Hull, J.C. Options, Futures, and Other Derivatives, 10th ed.; Pearson: London, UK, 2018. [Google Scholar]
  56. 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]
  57. 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]
  58. Fama, E.F.; Blume, M.E. Filter Rules and Stock-Market Trading. J. Bus. 1966, 39, 226–241. [Google Scholar] [CrossRef]
  59. Katsiampa, P. Volatility estimation for Bitcoin: A comparison of GARCH models. Econ. Lett. 2017, 158, 3–6. [Google Scholar] [CrossRef]
  60. Tomar, V.; Bansal, M.; Singh, P. Metaheuristic Algorithms for Optimization: A Brief Review. Eng. Proc. 2023, 59, 238. [Google Scholar] [CrossRef]
Figure 1. Rolling window validation example.
Figure 1. Rolling window validation example.
Mathematics 14 00069 g001
Figure 2. Market price of BTC/USDC over time, from 2020 to early 2024.
Figure 2. Market price of BTC/USDC over time, from 2020 to early 2024.
Mathematics 14 00069 g002
Figure 3. Average return for DE, PSO, WOA and GWO.
Figure 3. Average return for DE, PSO, WOA and GWO.
Mathematics 14 00069 g003
Figure 4. Standard deviation for DE, PSO, WOA and GWO.
Figure 4. Standard deviation for DE, PSO, WOA and GWO.
Mathematics 14 00069 g004
Figure 5. Best return for DE, PSO, WOA and GWO.
Figure 5. Best return for DE, PSO, WOA and GWO.
Mathematics 14 00069 g005
Figure 6. Diversity in each Metaheuristic.
Figure 6. Diversity in each Metaheuristic.
Mathematics 14 00069 g006
Table 1. Technical indicators.
Table 1. Technical indicators.
IndicatorFormula
Simple Moving Average (SMA) SMA t ( P , N ) = 1 N i = 0 N 1 P t i
Standard Deviation (STD) STD t ( P , N ) = 1 N i = 0 N 1 ( P t i μ ) 2
Table 2. Optimizable parameters for the SMA strategy.
Table 2. Optimizable parameters for the SMA strategy.
ParameterDescriptionRange
l e n s m a i Period of the simple moving average i [ 5 , 200 ]
k s w l Take-profit factor for long positions [ 1.0 , 1.3 ]
k s l l Stop-loss factor for long positions [ 0.9 , 0.99 ]
k s w s Take-profit factor for short positions [ 0.9 , 0.99 ]
k s l s Stop-loss factor for short positions [ 1.0 , 1.1 ]
Table 3. Backtest Performance Metrics.
Table 3. Backtest Performance Metrics.
MetricDescription
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 RatioRisk-adjusted return per unit of volatility.
Sortino RatioLike Sharpe Ratio, but penalizes only downside risk.
Max. Drawdown [%]Largest equity drop from peak to trough.
Win Rate [%]Percentage of winning trades.
Profit FactorGross profits divided by gross losses.
Table 4. Main parameters of the Metaheuristic algorithms used in this study.
Table 4. Main parameters of the Metaheuristic algorithms used in this study.
AlgorithmParameterRange or Value Selected
DEF0.4–0.8
C R 0.5–0.9
PSOw0.4–0.9
c 1 1.5–2.0
c 2 1.5–2.0
GWOa0–2.0
WOAa0–2.0
b1
l−1.0–1.0
Table 5. Average and best performance per Metaheuristic.
Table 5. Average and best performance per Metaheuristic.
MetaheuristicAvg. Return
(ann.) [%]
Avg. Volatility
(ann.) [%]
Best Return
(ann.) [%]
Volatility of Best
(ann.) [%]
PSO73.4790.09121.48119.83
WOA92.0598.64118.15115.35
GWO61.8084.21116.79114.85
DE107.36108.85119.62117.64
Table 6. Wilcoxon–Mann–Whitney test results by metric.
Table 6. Wilcoxon–Mann–Whitney test results by metric.
Metric DEGWOWOAPSO
Mean ReturnDE->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. ReturnDE->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 ValidationDE-0.021>0.05>0.05
GWO0.021->0.05>0.05
WOA>0.05>0.05->0.05
PSO>0.05>0.05>0.05-
Note: Bold values indicates significance at p < 0.05 .
Table 7. Performance metrics of the best execution per Metaheuristic.
Table 7. Performance metrics of the best execution per Metaheuristic.
MetricWOAGWOPSODE
Retorno (Anual.) [%]120.28116.79110.84108.86
Volatilidad (Anual.) [%]116.73114.86102.04111.42
Sharpe Ratio1.031.021.0860.977
Sortino Ratio3.953.813.783.49
Max. Drawdown [%]−28.66−29.34−37.13−29.77
Win Rate [%]69.3982.5094.1260.00
Number of Trades49405120
Profit Factor5.062.743.714.11
Note: Bold values indicates the best perfomance in each category.
Table 8. Qualitative summary of the evaluated Metaheuristics.
Table 8. Qualitative summary of the evaluated Metaheuristics.
MetaheuristicRecommended UseProsCons
DESuitable when stability across runs is prioritizedHigh consistency across runs, strong exploration-exploitation balance and robust validation performanceHigh variability in the best found solutions does not necessarily maximize extreme single-run returns
WOASuitable when maximizing single-run performance is desiredBest individual execution with highest profit factor and Sortino, contained maximum drawdownLess consistent than DE: more volatile performance across runs
PSOSuitable for capturing short-term opportunities and high-frequency strategiesHighest Sharpe with exceptional hit rate. Effective for fast-changing market dynamicsLargest drawdowns and higher sensitivity to sharp declines tends to produce more aggressive strategies
GWOSuitable for balanced return-frequency profilesSecond best return with high hit rate and generally stable behaviorModerate 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.

Share and Cite

MDPI and ACS Style

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

AMA Style

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 Style

Herná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 Style

Herná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

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop