1 Introduction

This work looks at the relevance of technical analysis (TA) as an aid to forex trading and aims to evaluate the feasibility of using TA indicators to achieve superior performances and infer conclusions about market efficiency. In a recent paper, Cavalcante et al. (2016) review the application of computational intelligence methods. They cover a broad spectrum of techniques applied to optimization in finance and show their suitability for that kind of complex problems. In Aguilar-Rivera et al. (2015), genetic algorithms (GAs) are suggested as very good tools for solving financial trading problems, in particular TA indicator optimization problems. In this context, it was natural for the purpose of this work to develop a GA designed to optimize the indicator parameters. One of our major concerns was to expand the number of tested indicators in order to better understand the validity of TA in forex markets. The main contributions of the article are: (1) the GA structure, which allows the testing of a vast array of different TA indicators with the possibility of recovering latent genetic material; (2) gathering evidence of forex markets’ efficiency, particularly when considering trading costs; and (3) finding evidence of differences in market maturity and available trading opportunities, supporting the adaptive market hypothesis (AMH) portrayed by Andrew Lo.

The media and specialized industry literature have reported the increased relevance of TA in financial markets. In the last ten years, this topic has been approached from a more scientific perspective, e.g. Reitz (2006), Menkhoff and Taylor (2007), Aronson (2007), Kirkpatrick and Dahlquist (2011), Falbo and Pelizzari (2011) and Fang et al. (2014). But despite TA’s significant role in the trading industry, its proponents face difficulties in gaining acceptance of their postulates from academia. This could partly be because of the predominant mainstream mentality in finance, the efficient-market hypothesis (EMH), a theory postulated by Fama (1965a, b, 1970), Fama et al. (1969) used as an assumption for TA optimization purposes, e.g. Taylor (1989). It could also be due to some TA subjective nature (chart patterns, Elliott Wave Theory, Gann) and the ensuing lack of credibility—Lo et al. (2000). Still, the EMH could not explain such phenomena as herding, the existence of trading moguls or market panics/crashes, criticisms devised by Behaviorists, supported by the existence of biases —Tversky and Kahneman (1974), Kahneman and Tversky (1979)—and inconsistencies in human behavior—Tversky and Kahneman (1981)—that undermined the very assumption of rationality. More recently, an attempt to reconcile the two has been presented by the AMH— Lo (2004, 2005)—where markets are seen in different stages of development with respect to efficiency. Lo considers the possibility of markets having a nature of their own, a specific DNA, that evolves with time, adapting to new circumstances as the inflow of new investors and outflow of old ones proceeds. In Lo’s words “(...) under the AMH, investment strategies undergo cycles of return and loss in response to changing business conditions, the number of competitors entering and exiting the industry, and the type and magnitude of profit opportunities available”. The AMH explains how periods of market efficiency are followed by periods of relative inefficiency, thus allowing profit opportunities and vice versa. Investors and arbitrageurs react to the awareness of those opportunities, changing their behavior and the market global structure until those opportunities no longer subsist. Fear and greed are also acknowledged as driving forces with an important role in the evolving nature of markets, impelling the inflow/outflow of market agents and their actions. Empirical evidence supporting the AMH is set out in Neely et al. (2009).

The last two decades have been fertile in research regarding optimization techniques applied to finance, e.g. Meade and Salkin (1989), Lee and Eom (1989), Suganya and Pai (2012), Hsu (2014). Important results are based on TA inspired models with respect to forex markets (Olson 2004; Schulmeister 2008, 2009), and use of GA (Lo et al. 2000; Hryshko and Downs 2004; Chiam et al. 2009; Pavlova and Parhizgari 2011; Mendes et al. 2012; Godinho 2012). Some new articles—Pavlova and Parhizgari (2011), Bajgrowicz and Scaillet (2012), Lin et al. (2011), Chen (2010), Fang et al. (2014), Kuang et al. (2014)—question the value of TA in achieving abnormal excess returns in a more empirically sustained way, especially when taking trading costs into account. Nevertheless, most of the published TA articles focus on a single or reduced set of technical indicators, leaving many unmentioned or untested.

Kuang et al. (2014) study the use of TA indicators in emerging Forex markets, concluding that above-normal profits are an illusion caused by data snooping bias. Similar results are reported in Fang et al. (2014), where an out-of-sample test of TA techniques in stock markets shows no evidence of TA predictive power. An interesting conclusion, similar to one of our own, is found in Yu et al. (2013) where the use of moving averages and breakout systems shows important return figures in emerging stock markets in Asia, but, after taking trading costs into consideration these profits vanish. Pavlova and Parhizgari (2011) use a GA applied to stock portfolios to try to find the usefulness of momentum trading strategies in improving return. Their GA allows an improvement of annual returns of 2–6%, a gain that worsens once trading costs are taken into account, as portfolios do not appear to generate abnormal returns. Bajgrowicz and Scaillet (2012) suggest “(...) an investor would never have been able to select ex ante the future best-performing rules”. They seriously question the economic value of TA techniques, claiming good return figures may be a consequence of data snooping. Similar conclusions supporting the EMH are expressed in Chen et al. (2009), concerning Asian stock markets. In futures trading, Yen and Hsu (2010) examined the return of TA techniques applied to ten markets. Their results suggest market efficiency in nine of them.

In this article we apply a GA to a set of in-sample data: the solutions obtained in this training phase are determined as sets of indicator parameters. Each set of parameters is then applied as a trading strategy to out-of-sample data and the results are analyzed with respect to a measure of return. The data used to train the trading model are not the same data used to test the model, thus allowing us to avoid potential data snooping. The aim of the model is not to forecast exchange rates.

The rest of the paper is organized as follows. Section 2 presents the trading model, including the selected TA indicators and their assumptions, the chromosome configuration and the description of the GA algorithm. In Sect. 3, empirical results are presented and discussed. The article ends with Sect. 4, where conclusions are drawn and new lines of research are discussed.

2 The Trading Model

The model tries to replicate the trading environment in the forex market with typical TA indicators and trading strategies commonly used by the industry. The purpose is to obtain and compare optimized solutions in three different TA categories—momentum, trend and breakout—and assess which ones produce better average outcomes. A solution consists of one indicator (belonging to one of these categories) with a given setting for its parameters.

Due to the complexity of the optimization task, a metaheuristic technique was chosen. A genetic algorithm is a suitable technique to achieve the proposed goal. It can easily embody the multi-dimensionality of the problem, that is, it can optimize simultaneously the solution structure (selection of the TA indicator) and the solution parameters (parameters of the indicator). In addition, the randomness factor in population generation and the variation of the parameters can help to avoid the trap of local optima and premature convergence in the optimization process, at the same time as the population evolves to yield solutions with a better fit. Our methodology seems better suited to the purpose at hand than other metaheuristics applied to forex, such as artificial neural networks (ANNs), e.g. Andreou et al. (2002); genetic programming (GP), e.g. Neely and Weller (2003), Wilson and Banzhaf (2010); grammatical evolution (GE), e.g. Brabazon and O’Neill (2004). This is because GAs allow optimization of parameters of isolated TA indicators. GP is better for optimizing TA rules, combining them into more complex structures and even designing whole trading systems. ANNs are better suited for pattern recognition, establishing evolving relations through complex input-output models. GP or GE are more useful for finding new optimized rules, which is not the objective in mind—we deliberately assume the trading rules as predefined and stable, since it is those rules used by the trading industry that we want to verify. Moreover, with GP or GE, new trading rules could emerge that are completely unrelated to the TA philosophy.

To achieve the proposed objective, the GA will optimize the evaluation function (EF) represented in (1):

$$\begin{aligned} EF={profit(A_T )}\Big /{MDD(A_T )} \end{aligned}$$
(1)

where \(A_{T}\) is the account at the end of time T (end of the period) and \(MDD (A_{T})\) is the maximum drawdown of the account at the same time, defined in (2). The MDD is the largest drop from peak to trough in a time span, the worst fall in account value observed for the trading activity.

$$\begin{aligned} MDD(A_T )=\mathop {\max }\limits _{1\le i<T} \left\{ {\mathop {\max }\limits _{i<j\le T}\left\{ A_i -A_j ;0\right\} }\right\} \end{aligned}$$
(2)

with i = 1, 2,...,  T−1; j = 2,...,T. That is, of all the account declines (each peak to trough decline expressed by \(\mathop {\max }\nolimits _{i<j\le T} \left\{ {A_i -A_j ;0} \right\} )\), MDD represents the greatest. This expression is equivalent to (3).

$$\begin{aligned} MDD(A_T )=\mathop {\max }\limits _{1\le i<j\le T} \left\{ A_i -A_j;0\right\} \end{aligned}$$
(3)

The intention is to maximize the ratio EF (in-sample), where the numerator has the measure of total profit, and the denominator has a risk measure—the maximum drawdown (MDD). Once the maximization process has been completed the optimized trading strategies (indicator and parameters) are applied to out-of-sample data. The analysis will be conducted as a measure of return, Return on Equity (RoE), computed as in (4).

$$\begin{aligned} RoE=\frac{profit(A_T )}{Initial\_Capital}\times 100\% \end{aligned}$$
(4)

2.1 Assumptions

The study concentrates on three major currency markets: EUR/USD, GBP/USD and USD/JPY. We use daily quotes.Footnote 1 Throughout the article, currency crosses are expressed under the ISO 4217 code format (“BBB/CCC”, where “BBB” = Base currency and “CCC” = Counter currency). Traded quantities are designated in base currency. A standard lot trades 100,000 base currency units, with a leverage of 1:100, meaning that for every traded lot we allocate the equivalent to 1000 base currency units to margin, expressed in counter currency. The interest rate differential, for rollover computation, is defined as the arithmetic difference between base currency and counter currency daily interest rates. Rollovers are calculated at the end of the day (time t) and multiplied by the respective closing price to become expressed in counter currency terms. For simplification, absolute profits, percentage in point (pip), margins, standard deviations and trading costs are designated in counter currency. At any given time t, the trading signal devised by an indicator assigns a trading position \(Y_{t}\) (long, short or out-of-the-market, indicated by signals “1”, “−1” and “0”, respectively) at the beginning of time \(t+1\). The difference between \(Y_{t}\) and \(Y_{t-1}\) defines the action to take at time \(t+1\). For instance, if \(Y_{t-1}=-1\) and \(Y_{t}=-1\), the short position remains unchanged and no action is taken; if \(Y_{t-1}=-1\) and \(Y_{t}=+1\) the position is reversed from a short position to a long position and 2 lots of 100,000 currency units are bought (\(Y_{t}-Y_{t-1}=+2\)); if \(Y_{t-1}=-1\) and \(Y_{t}=0\), this implies a change from a short position of 1 lot to an out-of-the-market situation by buying 1 lot (\(Y_{t}-Y_{t-1}=+1\)) in \(t+1\), and so on. Execution prices in \(t+1\) are, by assumption, taken at the opening price. To compute MDD and the RoE in percentage terms we consider a starting trading account size (equity) of 50,000.00 currency units for the EUR/USD and GBP/USD markets, 5,000,000.00 units for USD/JPY. For every period, the account size restarts with the mentioned equity figures. Whenever an account hits zero value, an order is triggered to clear all open positions and exit the market.

2.2 Example of Indicator Application and RoE Calculation

We present an example of the computation of a solution RoE (Table 1). For simplification purposes, we have restricted the period of potential transactions to a 15-day span and ignored trading costs. SMA(n) represents a simple moving average with a moving window of n observations.

Assume the algorithm has generated (in the training phase) a solution within the trend category where the selected indicator is an SMA crossover, taking long positions when SMA(3) > SMA(5) and short positions otherwise. This strategy is applied to the out-of-the sample data in Table 1. The moving averages are applied to the close prices and are presented in columns (6) and (7) of Table 1. The difference between the two averages is given in column (8) and the respective positions to assume on each day are in column (9), where “1” represents long and “−1” short positions. In this case we can only have a position signal after the \(5{\mathrm{th}}\) day, as the longest SMA needs 5 days to compute its first value. On day 5 we can see the system signals a long position, which will be taken on the next day at the opening price. Therefore, at the end of day 6 we have 1 trading lot of 100,000 base currency units bought at 1.2820 and valued at 1.2789. This represents a loss of −310.00 counter currency units [(1.2789 − 1.2820)*100,000= −310.00]. On day 7 we keep a long position of one lot (signal at day 6) and so the profit will be equal to the difference of the closing price on day 7 and the closing price on day 6, i.e. [(1.2870 − 1.2789)*100,000 = +810.00]. When the position changes from long to short on day 8 (signal on day 7) we sell 2 lots at 1.2867–one to offset the previous trading position and the other to take a short position. At the end of day 8 we have produced 730.00 in counter currency profits: (1.2867 − 1.2870)*100,000 + (1.2867 − 1.2791)*100,000 = −30.00 (loss for offsetting previous position) + 760.00 (profit from the short position). Following this reasoning, at the end of the period we would have a net cumulative profit of 770.00, which represents a RoE of 770/50,000 = 1.54%.

Table 1 Computation of a solution’s RoE

Below we present the formulae used to calculate daily profit (\(DP_t\)), where we take into account all the possible scenarios for the position held at each time point.

  1. 1.

    Continuous long position, \(Y_{t-2}=1\) and \(Y_{t-1}=1\):

    $$\begin{aligned} DP_t =\left( P_t^{close} -P_{t-1}^{close}\right) \end{aligned}$$
    (5)
  2. 2.

    Reversing from a short to a long position, \(Y_{t-2}=-1\) and \(Y_{t-1}=1\):

    $$\begin{aligned} DP_t =\left( P_t^{close} -P_t^{open}\right) +\left( P_{t-1}^{close} -P_t^{open}\right) \end{aligned}$$
    (6)
  3. 3.

    Continuous short position, \(Y_{t-2}=-1\) and \(Y_{t-1}= -1\):

    $$\begin{aligned} DP_t =-\left( P_t^{close}-P_{t-1}^{close}\right) =\left( P_{t-1}^{close} -P_t^{close}\right) \end{aligned}$$
    (7)
  4. 4.

    Reversing from a long to a short position, \(Y_{t-2}=1\) and \(Y_{t-1}=-1\):

    $$\begin{aligned} DP_t= & {} -\left[ {\left( P_t^{close} -P_t^{open}\right) +\left( P_{t-1}^{close} -P_t^{open}\right) }\right] \nonumber \\= & {} \left( P_t^{open}-P_t^{close}\right) +\left( P_t^{open} -P_{t-1}^{close}\right) \end{aligned}$$
    (8)
  5. 5.

    From a long position to out of the market, \(Y_{t-2}=1\) and \(Y_{t-1}=0\):

    $$\begin{aligned} DP_t =\left( P_t^{open} -P_{t-1}^{close}\right) \end{aligned}$$
    (9)
  6. 6.

    From a short position to out of the market, \(Y_{t-2}=-1\) and \(Y_{t-1}=0\):

    $$\begin{aligned} DP_t =-\left( P_t^{open}-P_{t-1}^{close}\right) =\left( P_{t-1}^{close} -P_t^{open}\right) \end{aligned}$$
    (10)
  7. 7.

    From out of the market to a long position \(Y_{t-2}=0\) and \(Y_{t-1}=1\):

    $$\begin{aligned} DP_t =\left( P_t^{close}-P_t^{open}\right) \end{aligned}$$
    (11)
  8. 8.

    From out of the market to a short position, \(Y_{t-2}=0\) and \(Y_{t-1}=-1\):

    $$\begin{aligned} DP_t =-\left( P_t^{close} -P_t^{open}\right) =\left( P_t^{open} -P_t^{close}\right) \end{aligned}$$
    (12)

    \(P_t^{open}\) and \(P_{t}^{close}\) stand for open and close prices at a given day t.

The account profit is computed as in (13):

$$\begin{aligned} profit(A_T )=\sum _{t=1}^T {DP_t } \end{aligned}$$
(13)
Table 2 Technical indicators and their parameters
Table 3 Trading rules

2.3 Technical Indicators

We consider TA indicators of three categories: trend, momentum and breakout. Regarding the trend category, the indicators were mainly based on crossing moving averages: double simple moving average crossover, double exponential moving average crossover, triple simple moving average crossover, directional movement index and moving average convergence divergence. The goal of these indicators is to portray some extent of the tendency of price movement. Within the momentum category the following indicators were considered: relative strength index, Williams’ %R and stochastic oscillator. The purpose of these indicators is to measure the velocity of price under the assumption that intense price moves in one direction, to create a situation of an overbought or oversold market, are usually followed by a price reaction, with the market reversing direction. Breakout indicators use bands around price. Their rationale is that when price breaks through some of these thresholds (upper/lower), a major move is building in the price direction. We have considered average true range (ATR), Bollinger Bands, close price, exponential moving average +/− k standard deviations and double exponential moving average breakout. All indicators, parameters, constraints and associated trading rules are given in Tables 2 and 3. For a detailed knowledge of all indicators, parameters and TA trading rules involved in this study, we recommend (Colby 2003).

There are five distinct kinds of parameters on which the indicators depend:

  • \(\alpha _{i}=\frac{w_{t-1}}{w_t}=\) ratio between weights of observations in time \(t-1\) and time t, (real number, \(0<\alpha _{i} \le 1\)), in the computation of an exponential moving average for indicator i;

  • \(n_{i}=\) moving window length (positive integer) for the calculation of indicator i;

  • \(ub_{i}=\) upper bound or threshold (real number) in indicator i;

  • \(lb_{i}=\) lower bound or threshold (real number) in indicator i,

  • \(k_{i}=\) number of standard deviations (positive real number) for the calculation of indicator i.

2.4 Chromosome Configuration

A solution (chromosome) is composed of a set of parameters, confined to a category of TA indicators. For every solution, the GA activates only one indicator (represented by Boolean variables); the rest remain latent as shadow indicators, with their respective parameters. Indicators of the same category are thus competing with each other. In the generic example shown in Fig. 1, the hypothetical category in question consists of three different indicators: Boolean variables \(d_{1}, d_{2}, d_{3}\) identify whether the respective indicators are active or not (only one can be active); parameters \(p_{ij}\) refer to the parameters of each current indicator (\(p_{ij}\) is the parameter j of the indicator i). In this example, indicator 2 is active.

Fig. 1
figure 1

Representation (encoding) of a single generic solution of a hypothetical category, where indicator 2 is active and indicators 1 and 3 are inactive (latent indicators)

This configuration allows more flexibility than the use of a single indicator because it provides an opportunity for indicator interchange and hence more diversity in the optimization process. We chose to use the optimization of individual indicators and not a combination of two or more so that the validity of each single TA indicator could be discerned.

2.5 Algorithm Structure and Optimization Rationale

In the training phase, the objective is to identify the combination of parameters that maximizes EF, defined as a risk-adjusted return. The procedure includes a training phase, where the category/indicator selection and the parameter optimization are fulfilled by the GA, and a testing phase. In this last phase, the previously optimized solutions are applied to the out-of-sample data. Different experiments for each category of indicators within each single market are performed. Every experiment consists of an in-sample training period of two years and an out-of-sample testing timespan of one semester, according to the schedule in Fig. 2.

Fig. 2
figure 2

Rolling window timespans

For each market, indicator category and timespan (as depicted in Fig. 2), our genetic algorithm will produce a set of N optimized solutions, each resulting from an independent run, \(n=1,{\ldots }, N\). We have considered \(N=50\) for each of the 16 timespans. The purpose is to assess the average return (RoE) of each set to draw conclusions. A solution is composed of an active indicator and its parameters.

2.5.1 Algorithm

It is a difficult task to define the most appropriate size of a population and a suitable number of iterations in a GA. While small populations and/or small numbers of iterations run the risk of under-covering the solution space (being trapped in local optima), large populations and/or large numbers of iterations may require an excessive computational effort. Schaffer et al. (1989) concluded that for a representative series of multiple genetic algorithms, an appropriate population size should be set between 20 and 30. A similar result was reported by Haupt and Haupt (2000), who argue that small population sizes combined with larger mutation rates perform better, not only by achieving better results but also by doing so in a shorter execution time. Papadamou and Stephanides (2007) also suggested a population of 30 as a suitable population size for GAs applied to TA indicator analysis, taking into consideration performance and computational effort.

We did a preliminary test using the same markets, taking a population size of 30 and a very large number of iterations in order to set an appropriate number of iterations to use. The results showed that the algorithm produced large improvements up to the \(100{\mathrm{th}}\) iteration for most of the trials, but, after that iteration, the improvements were generally not significant. Further experiments were conducted in our algorithm with different population sizes: 50, 100 and 200 chromosomes, all with 500 iterations. The average performances are presented in Fig. 3 and show evidence that after the \(100{\mathrm{th}}\) iteration there are only small improvements. We may see that around the \(80{\mathrm{th}}\) iteration average performances of the GA become very similar. In this context, we have decided to use 100 iterations and a population size of 30 in the optimization process.

Fig. 3
figure 3

Comparison of the GA performance with different population sizes (30, 50, 100 and 200). Each line represents the average performance of a sample of 10 independent runs for each population scenario in the EUR/USD market

The following scheme describes the optimization process. The algorithm starts with the random generation of a population of J trading strategies that will be subject to crossover and mutation through I iterations. At the end of the Ith iteration, the algorithm will produce an in-sample optimized solution. As stated above, J and I will be 30 and 100, respectively.

  • i = Iteration number, \(i = 1, \ldots , I\)

  • \(\hbox {P}(i)\) = Population per market for each TA indicators’ category at the end of iteration i

  • \(S_{ij}=j\mathrm{th}\) solution (trading strategy) at iteration \(i; i=1,\ldots , I; j=1,\ldots , J\);

  • \(\hbox {P}(i)=\{S_{ij;\,j=1,\ldots ,J}\}\),

Generate P(0), the original population, formed by J random trading strategies (solutions)

figure a

In the end, considering all markets, categories and periods, we ought to have a set of 7200 optimized trading strategies (\(S^{***})\) covering all scenarios (\(N\cdot \#\textit{markets} \cdot \#\textit{categories} \cdot \#\textit{periods}\) = 50*3*3*16 = 7200), to be tested with out-of-sample data.

2.5.2 Crossover and Mutation

The adopted crossover operator is a binary crossover with a single randomly selected cutting point. For every population of J valid solutions, the algorithm picks the first solution (our reference element), which will be compared with an offspring generated by the crossover operator. Next, the algorithm randomly selects two different solutions from the population and applies the crossover operator, originating a single offspring. The offspring receives the genetic material from the first parent up to the cutting point and from the second parent thereafter. The offspring must have only one indicator active. Whenever this condition does not hold the algorithm goes on to select one active indicator (randomly, to prevent excessive elitism)—see an example in Fig. 4.

Fig. 4
figure 4

Crossover operator: a solution obtained by crossover where indicator 1 becomes active (randomly selected). Genetic material from indicators 2 and 3 remains latent

The algorithm compares the EF value of the offspring with the reference element’s value and the best of them is selected to integrate the population of the next iteration. Then, the algorithm applies mutation with a certain probability to this solution. The solution obtained after mutation replaces the original solution in the population of the next iteration only if it has a better EF value. The algorithm picks the next solution \((2{\mathrm{nd}})\) as reference element and repeats the procedure until all J solutions of the current population have been evaluated against J alternative offspring.

Regarding the mutation operator—mutation is a unary genetic operator responsible for small changes in chromosomes as it is only applied to a few genes. The probability of mutation of each gene (parameter of the indicator) is 1% except for the Boolean variables \(d_{i}\). There is also the possibility of genetic material recovery provided by a random re-selection of the active indicator. This consists of a recalculation of the \(d_{i}\) values, so that each indicator has the same probability of being chosen. Only one \(d_{i}\) can take the value “1”. The type of mutation depends on the specificities of each parameter, according to the following conditions:

  • \(\Delta \alpha _{i}, \Delta ub_{i}, \Delta lb_{i}\in ] -0.05000;+0.05000[\), following a uniform density probability function

  • \(\Delta n_{i}\in \{-1;+1\},\) with equal probability of choosing each element

  • \(\Delta k_{i}\in ]-0.50000;+0.50000[\), following a uniform density probability function

Variations in parameters \(\alpha _{i}, ub_{i}, lb_{i}\) and \(k_{i}\) occur in figures up to five decimal places, as shown above in the intervals. The major contribution of this mutation operator and re-selection procedure lies in the possibility of recovering latent or shadow genetic material, which may prevent a premature convergence of the algorithm. Our algorithm presents a linear time complexity O(n), where n stands for data input (daily open-high-low-close price quotes). The time required to execute our algorithm increases in proportion to the used amount of input data, making it a less time consuming algorithm.

3 Empirical Results and Discussion

In this section, we will apply the optimized solutions obtained by the GA in the in-sample data to the out-of-sample data. The results in terms of the average RoEs will be compared with those obtained from the preeminent indicator (the most frequently selected indicator in each set of 50 optimized solutions), considering the usual industry values for the parameters. We can therefore evaluate the GA’s ability to optimize the parameter values. The commonly used parameter values, according to the industry—Aronson (2007), Colby (2003), Kirkpatrick and Dahlquist (2011), Murphy (1999), Schwager (1996)—are:

  • RSI: \(n= 14\); upper threshold = 70%; lower threshold = 30%

  • Williams’%R: \(n=10\); upper threshold = -20%; lower threshold = −80%

  • Stochastics: \(n_{Fast\% K}=5; \alpha _{Fast\% D}= 1; n_{Fast\% D}=3; \alpha _{Slow\% D}= 1; n_{Slow\% D}= 3\)

  • Moving average crossovers: \(n_1=5\) (short term—a trading week); \(n_2=20\) (medium term—a trading month); and if necessary \(n_3=60\) (long term—three trading months)

  • For the EMAs, consider all \(\alpha =0.8\)

  • MACD: \(n_{FastEMA}=12; n_{SlowEMA}= 26; n_{Signal}= 9\); all \(\alpha = 0.8\)

  • DMI: \(n_{DMI}= 14\); all \(\alpha =0.8\)

  • ATR: \(n_{CP\_EMA\_ATR}=5; n_{ATR}= 14\); all \(\alpha =0.8\)

  • BB: \(n=10\); all \(k=2\)

  • \(CP\pm k\sigma : n=5\); all \(k=1; \alpha = 0.8\)

The training process was executed in the simplest possible way, trading one standard lot without trading costs and stops. In Forex markets we deal with two distinct kinds of costs: (1) spreads and (2) rollover, usually a fraction of the spread measured in pips (around 0.2 pips in EUR/USD or GBP/USD markets, for instance) that accrues to interest rate differentials, increasing unfavorable or attenuating favorable differentials. In our case, the rollover (effective cost) was excluded from the training phase but not the interest rate differential itself, which may be a cost or a profit to the trader. In-sample RoEs are in 6 month adjusted rates (in proportion), so they may be related and compared to out-of-sample RoEs.

3.1 Trading Strategy Return without Trading Costs

The analysis of in-sample results allows us to conclude that all kinds of TA techniques present positive returns; breakout systems have consistently the worst in-sample RoE performances within each market and momentum and trend optimized strategies show very similar figures. Figure 5 presents a boxplot with the returns of all combinations of currency crosses and TA categories.

Fig. 5
figure 5

Return (%) of the optimized solutions, in-sample without costs, from the \(1{\mathrm{st}}\) semester of 2001 to the \(2{\mathrm{nd}}\) semester of 2008. On the top, in brackets, are presented the average semestral returns (%) for each combination currency cross/TA category. The bottom, middle and top of the boxes represent the 25th, 50th and 75th percentiles, respectively; the top and bottom whiskers stand for the maximum and minimum, respectively, excluding outliers; outliers are represented by ‘+’

Table 4 Return (%) of the optimized solutions, out-of-sample without costs
Fig. 6
figure 6

Return (%) of the preeminent TA indicator, out-of-sample without costs, from \(1{\mathrm{st}}\) semester 2003 to the \(2{\mathrm{nd}}\) semester 2010. In brackets are presented the average RoEs (%) for each combination currency cross/TA category. The bottom, middle and top of the boxes represent the 25th, 50th and 75th percentiles, respectively; the top and bottom whiskers stand for the maximum and minimum, respectively, excluding outliers; outliers are represented by ‘+’

In this figure it is possible to see the median value in the middle of each box. The bottom of the box represents the lower quartile (\(25{\mathrm{th}}\) percentile of RoEs), meaning 25% of all RoEs stand bellow that value, while the top of the box stands for the upper quartile (\(75{\mathrm{th}}\) percentile RoE value), meaning 75% of all RoE observations are lower than that mark. The lower and the upper whiskers stand for the minimum and maximum values, excluding outliers. Outliers are represented with crosses (plus sign) and represent extreme values, less than 1.5 times of lower quartile or higher than 1.5 times of upper quartile. On the top of each figure, in brackets, are shown the average RoE values for each currency cross/TA category combination. We may see how the optimization procedure produces very different outcomes by market, enabling us to conclude that each market has its own singularities and inherent characteristics promoting or preventing the exploitation of TA profitable trading opportunities, in tune with Lo’s AMH.

Table 4 presents the profitabilities for out-of-sample data, per semester. The table is organized by market, and within each market we have three columns with the mean profitabilities by TA category followed by the respective return median values. Below the median stands the respective p-value to the non-parametric Wilcoxon test, where “\(\hbox {H}_{0}\): The median is statistically equal to zero” and “\(\hbox {H}_{1}\): The median is not statistically equal to zero”, to assess the statistical significance of the measures of central tendency. A very small p-value is indicative against the null hypothesis. On a fourth column of each market it is presented the correspondent semester price variation of the first currency in relation to the second one.

Regarding the mean profitabilities, it is noticeable how all TA categories produce out-of-sample aggregate positive outcomes. These positive semestral returns show consistency, in particular with reference to the GBP/USD market. This market produces the best outcomes, with trend based profitabilities staying well ahead. When comparing TA strategy based results with price variation, we may see in the EUR/USD market that average results are consistently better when the EUR appreciates against the USD. In four out of the 11 semesters in which the EUR rises against the USD, all TA categories present good average RoEs, while the same only happens once in the five semesters in which the dollar appreciates against the euro. The other semesters present mixed results, depending on the TA category. The same is true regarding the GBP/USD when the GBP appreciates against the USD, although the trend category behaves positively in some cases when the opposite happens (see \(2005\hbox {-}2{\mathrm{nd}}\) and \(2008\hbox {-}2{\mathrm{nd}}\) semesters). In the USD/JPY market there is not a defined tendency—when the JPY appreciates strongly against the USD (2003-2, 2004-2, 2008-1, 2008-2 or 2010-2) the trading returns vary from heavy losses to strong profits. Mixed results are attained when the USD appreciates against the JPY.

Figure 6 presents a box-plot of the TA preeminent indicator profitabilities for each period, market and category. Figure 7 shows another box-plot with the difference between the returns obtained by the GA optimization process and those of the preeminent indicators, i.e., the excess returns from the optimized solutions.

Fig. 7
figure 7

Excess returns (%) of the optimized solutions with respect to the preeminent TA indicator of each period, out-of-sample without costs, from \(1{\mathrm{st}}\) semester 2003 to the \(2{\mathrm{nd}}\) semester 2010. In brackets are presented the average excess returns (%) for each combination currency cross/TA category. The bottom, middle and top of the boxes represent the 25th, 50th and 75th percentiles, respectively; the top and bottom whiskers stand for the maximum and minimum, respectively, excluding outliers; outliers are represented by ‘+’

It may also be seen in Fig. 7 how excess returns are positive in the majority of cases. This shows our GA was able to fine-tune the parameters in a way that allowed it, in most cases, to beat the correspondent TA indicators using the parameter values commonly accepted by the trading industry. The consistency is also corroborated by the cumulative positive excess returns. All cumulative returns are above 40% and, in some cases (in the GBP/USD market for instance), they are much higher.

Table 5 Out-of-sample return correlations between TA categories, by market
Table 6 Out-of-sample return correlations between markets, split by TA category
Fig. 8
figure 8

MDD (%) for the optimized solutions, in-sample without costs, from \(1{\mathrm{st}}\) semester 2001 to the \(2{\mathrm{nd}}\) semester 2008. In brackets are presented the average MDDs (%) for each combination currency cross/TA category. The bottom, middle and top of the boxes represent the 25th, 50th and 75th percentiles, respectively; the top and bottom whiskers stand for the maximum and minimum, respectively, excluding outliers; outliers are represented by ‘+’

Fig. 9
figure 9

MDD (%) for the optimized solutions, out-of-sample without costs, from \(1{\mathrm{st}}\) semester 2003 to the \(2{\mathrm{nd}}\) semester 2010. In brackets are presented the average MDDs (%) for each combination currency cross/TA category. The bottom, middle and top of the boxes represent the 25th, 50th and 75th percentiles, respectively; the top and bottom whiskers stand for the maximum and minimum, respectively, excluding outliers; outliers are represented by ‘+’

A comparison of out-of-sample average returns with the average returns of a large set (10,000) of random solutions was also performed. These solutions were generated by randomly creating trading position signals out of the three possible (“+1”, “−1” or “0” to designate long, short or out-of-the-market positions), each with equal probability of being selected. All the averages of random solutions are very close to zero and our out-of-sample results present significantly better cumulative figures. Regarding the predictive power of TA indicators per se, the out-of-sample overall results without costs (Table 4), present somewhat attractive figures for the timespan of eight years, with the majority of periods showing positive outcomes in all markets. Return varies within markets and with the kind of applied strategy. The USD/JPY presents lower marks in almost all categories, suggesting fewer opportunities for sustained trading profits. This fact may also suggest a greater level of market development in terms of efficiency—a notion that is consistent with the AMH theorized by Andrew Lo. Among all three sorts of trading strategies, trend category seems to produce the best outcome.

Correlations between return of categories within the studied markets (Table 5) show a positive tendency—the only two negative correlations are very close to zero (EUR/USD breakout vs. trend: −0.002; GBP/USD breakout vs. momentum: −0.044); the others are mildly (e.g., GBP/USD momentum vs. trend: \(+\)0.199) to highly positive (see for instance USD/JPY breakout vs. trend or breakout vs. momentum: \(+\)0.834 and \(+\)0.612, respectively). This suggests optimized solutions for a given period in each market tend to generate outcomes with similar signal and overall proportion, with particular focus to the USD/JPY, no matter what TA category of indicators is used.

Table 7 Return (%) of the optimized solutions, out-of-sample, with costs

In Table 5, price variation vs TA category return correlations show in the EUR/USD and USD/JPY how returns are negatively correlated with USD price variation, i.e., RoEs in all categories tend to be positive when USD price decreases against the other currency. In the GBP/USD there is a strong positive correlation of GBP price variation and TA momentum category (equivalent to a strong negative correlation of USD price variation and momentum category), but this tendency does not hold regarding the other TA categories: the correlation varies from −0.332 with trend to \(+\)0.612 with momentum and almost zero correlation with breakout strategy categories.

The correlation between markets intends to assess the consistency of TA trading strategy’s categories throughout all studied markets, i.e., whenever a TA category works (does not work) in a period in a specific market, it should (should not) work in the other markets. We can see in Table 6 there is not consistency in profitabilities of TA strategies throughout the studied markets for each TA category, which in turn may imply that markets seem to possess, at any given period, distinct inherent characteristics preventing them from reacting evenly to similar trading strategies. This might be a consequence of structural market divergences or circumstancial differences following a process of change (different stages of market efficiency).

Fig. 10
figure 10

Return (%) of the preeminent TA indicator in each period, out-of-sample, with costs, from \(1{\mathrm{st}}\) semester 2003 to the \(2{\mathrm{nd}}\) semester 2010. In brackets are presented the average \(\hbox {RoE}s\) (%) for each combination currency cross/TA category. The bottom, middle and top of the boxes represent the 25th, 50th and 75th percentiles, respectively; the top and bottom whiskers stand for the maximum and minimum, respectively, excluding outliers; outliers are represented by ‘+’

Fig. 11
figure 11

Excess returns of the optimized solutions compared to the preeminent TA indicator of each period, out-of-sample, with costs, from \(1{\mathrm{st}}\) semester 2003 to the \(2{\mathrm{nd}}\) semester 2010. In brackets are presented the average excess returns (%) for each combination currency cross/TA category. The bottom, middle and top of the boxes represent the 25th, 50th and 75th percentiles, respectively; the top and bottom whiskers stand for the maximum and minimum, respectively, excluding outliers; outliers are represented by ‘+’

Regarding risk, measured by MDD (Figs. 8, 9), we may see how in-sample results seem to be much more concentrated around the median. Out-of-sample MDD values are more widespread and present a considerable greater number of outliers than in-sample results. The divergence between in-sample and out-of-sample risk levels shown by momentum and trend systems versus breakout systems increases in out-of-sample MDD. This might suggest breakout strategies (which present less risk) possess inherent risk-mitigating characteristics that may rely, for instance, in their signal generator ability to promptly react to price change, and with that avoid more effectively unfavorable market moves. When put into a market’s perspective, we may acknowledge the USD/JPY shows better MDD percentages, qualifying as the less risky market. The GBP/USD shows signs of being the riskiest of all studied markets, but it should not be forgotten this is the market that allows greatest return, so we may detect a direct relation between risk and return applied to the use of TA.

3.2 Trading Strategy Return Considering Spreads and Rollover Costs

In the simulation with costs we have considered spreads of 2 pips and rollover costs of 0.2 pips for the EUR/USD and GBP/USD markets; 200 and 20 pips respectively for the USD/JPY market. These spreads are to be taken on a per turn basis, i.e., they are in reference to a single market’s action of buying or selling. Rollover costs are added (subtracted) to (from) unfavorable (favorable) interest rate differentials.

With the inclusion of reasonable trading costs (Table 7), we notice how apparently attractive out-of-sample profits simply disappear. The medians of the observed results remain, in general, statistically different from zero, but the aggregate average returns suffer deeply. An exception seems to be the GBP/USD market, with the use of trend strategies, which still presents some interesting results. The outcomes suggest these markets might be, considering more realistic assumptions, relatively efficient. We can see in Figs. 10 and 11 how the returns of optimized solutions remain superior compared to those of the correspondent preeminent indicators applying the industry parameters. In spite of that, the inclusion of trading costs in our analysis suggests a decline of the excess returns of the strategies provided by the GA compared to figures without costs, with the exception of momentum and breakout techniques in the GBP/USD market, where there is a small improvement in RoE’s (compare Fig. 7 with 11).

Another conclusion we may draw refers to the inclusion of trading costs—breakout strategies demonstrate more resiliency (their outcomes suffer less). This assessment is reinforced by the lower observed risk levels stressed by the MDD values, comparing Fig. 9 with 10.

Fig. 12
figure 12

MDD (%) for the optimized solutions, out-of-sample, with costs, from \(1{\mathrm{st}}\) semester 2003 to the \(2{\mathrm{nd}}\) semester 2010. In brackets are presented the average MDDs (%) for each combination currency cross/TA category. The bottom, middle and top of the boxes represent the 25th, 50th and 75th percentiles, respectively; the top and bottom whiskers stand for the maximum and minimum, respectively, excluding outliers; outliers are represented by ‘+’

Momentum and trend strategies’ risk levels remain close to each other. Breakout systems seem to produce consistently smaller MDD values. Nevertheless, the inclusion of trading costs only increases the MDD by about 1.5–2 percentage points, a change that does not acutely affect average risk levels (Fig. 12).

4 Concluding Remarks

Some important conclusions emerge from this study, which may be summarized as follows. The proposed GA presents a good advantage in comparison to the most commonly used GAs: a wide set of solutions in the search process with the possibility of genetic material recovery from shadow indicators allows greater diversity of inherited genetic material and prevents a precocious convergence in the optimization process. The use of a large number of in-sample/out-of-sample timespans with reference to the overall trading period minimizes the likelihood of obtaining results misled by data mining. For the aggregate period of 2003–2010, the out-of-sample results obtained from the optimized solutions outperform substantially the corresponding most frequently used TA indicators with traditional industry parameters. Results vary widely within the considered markets and the TA trading strategy categories—which suggests not all kinds of trading strategies present the same predictive power; and not all markets perform equally or show the same inner characteristics. This may be a symptom of the existence of different stages of efficiency development, an idea compatible with Andrew Lo’s AMH. The inclusion of trading costs dramatically changes the landscape in terms of average return—the majority of results turns negative, and the existence of profitable trading opportunities seems elusive when considering more realistic assumptions. This suggests markets may be more efficient than return without costs implied, an observation showing strong evidence in favor of the EMH for the three major Forex markets. There is also a negative correlation between USD price variation and TA categories RoEs, with a few exceptions in the GBP/USD market.

The somewhat interesting return figures and the statistical significance of attained results do not provide the conditions or sustenance to assert the validity of TA as an effective isolated tool in trading activities within the three major Forex markets, particularly when considering more realistic terms. This may be seen as an argument in favor of market efficiency. Shmilovici et al. (2009) also tested efficiency in several Forex markets concluding in favor of market efficiency, particularly when dealing with intraday data. Also Ozturk et al. (2016) tested the EUR/USD and GBP/USD with crossover, Bollinger Bands and divergence TA indicators, reaching similar results to the presented in this article – limited positive results and profits in 60% of the number of trades, but without trading costs. Our findings are consistent with Kuang et al. (2014) and Fang et al. (2014), that conclude there are no strong evidences of TA indicator’s predictive power. We may also see in Yu et al. (2013) how the inclusion of trading costs affects return, turning profits into losses, just as shown in our article.

In spite of several limitations, it is our conviction the article’s emerging ideas may stimulate further work and provide a contribution in the field of Operational Research applied to Finance. An interesting follow-up would be assessing the predictive power of TA in other markets such as Stock, Bonds or Commodities, or evaluating how the application of similar techniques to fundamental analysis may produce a good Investment model.