• No results found

Intelligent Dynamic Backlash Agent: A Trading Strategy Based on the Directional Change Framework

N/A
N/A
Protected

Academic year: 2021

Share "Intelligent Dynamic Backlash Agent: A Trading Strategy Based on the Directional Change Framework"

Copied!
29
0
0

Loading.... (view fulltext now)

Full text

(1)

Article

Intelligent Dynamic Backlash Agent: A Trading

Strategy Based on the Directional Change Framework

Amer Bakhach1,*, Venkata L. Raju Chinthalapati2, Edward P. K. Tsang1and

Abdul Rahman El Sayed3

1 Centre for Computational Finance and Economic Agents, University of Essex, Colchester CO4 3SQ, UK; [email protected]

2 Department of Accounting and Finance, University of Greenwich, London SE10 9LS, UK; [email protected]

3 Department of Mathematics, Normandie University, 76620 Normandie, France; [email protected] * Correspondence: [email protected]; Tel.: +961-70-412514

Received: 17 September 2018; Accepted: 26 October 2018; Published: 28 October 2018

Abstract:The Directional Changes (DC) framework is an approach to summarize price movement in financial time series. Some studies have tried to develop trading strategies based on the DC framework. Dynamic Backlash Agent (DBA) is a trading strategy that has been developed based on the DC framework. Despite the promising results of DBA, DBA employed neither an order size management nor risk management components. In this paper, we present an improved version of DBA named Intelligent DBA (IDBA). IDBA overcomes the weaknesses of DBA as it embraces an original order size management and risk management modules. We examine the performance of IDBA in the forex market. The results suggest that IDBA can provide significantly greater returns than DBA. The results also show that the IDBA outperforms another DC-based trading strategy and that it can generate annualized returns of about 30% after deducting the bid and ask spread (but not the transaction costs).

Keywords:algorithmic trading; trading strategy; directional change; forex; forecasting

1. Introduction

Directional Change (DC) is an approach to summarizing market price movements [1]. Under

the DC framework, the market is cast into alternating upward trends, which we call uptrend, and

downward trends, which we call downtrend [2]. A trend is identified as a change in market price

larger than, or equal to, a given threshold. This threshold, namedtheta, is set by the observer and

usually expressed as percentage. A trend ends whenever a price change of the same threshold, theta,

is observed in the opposite direction. For example, a market downtrend ends when we observe a

price rise of magnitude theta; in this case, we say that the market changes its direction to an uptrend.

Similarly, a market’s uptrend ends when we observe a price decline of magnitudetheta, in which case

we say that the market changes its direction to a downtrend.

Before we continue, we cite other studies that show the DC framework has helped in analyzing

financial markets. For example, Glattfelder et al. [3] discovered twelve scaling laws which unveil new

characteristics in the Forex (FX) market. These scaling laws are based on the DC concept. They aimed to establish mathematical relationships among price moves, duration and frequency. In addition,

Bisig et al. [4] presented the so-called Scale of Market Quakes (SMQ) based on the DC concept. SMQ

aims to quantify FX market activity during significant economic and political events declarations.

Furthermore, Masry [5] reported a study that deciphers FX market activity based on the DC

concept. She introduced an approach that lays “the foundations for understanding how FX market

(2)

activity changes as the price movement progresses” and explains how minor differences in market

activities can change the price trend, under definite conditions, during the overshoot (OS) event [5].

Bakhach et al. [6] presented a model to forecast market trend’s direction under the DC framework.

They tried to forecast whether a DC trend would continue for a specific threshold before the market’s

trend reverses. AlKhamees and Fasli [7] proposed a DC-based approach with a dynamic threshold

definition method to analyze the reaction of financial market to the published news (e.g., political, economic). They claimed that their approach can be used by investors to detect movements in the market so that they can, potentially, react to and take advantage of.

Tsang et al. [8] introduced an approach to profiling companies and financial markets. Their

methodology embraces a set of innovative indicators that are based on the DC framework. These indicators aim to analyze and classify financial markets. They concluded that information obtained

through DC-based analysis and from time series complement each other. Tsang and Chen [9] suggested

an approach to profile a particular market over a rolling time window, and track the change of market

positions over time. They employed some of the DC indicators previously introduced in [8] observed

under different price events. They applied their approach to identify regime change during the Brexit period (more particularly between May and July 2016).

In addition, some studies have tried to develop trading strategies based on the DC framework

(e.g., [10–13]). In this paper, we are particularly interested in the DC-based trading strategy named

Dynamic Backlash Agent (DBA) by Bakhach et al. [14]. The preliminary results suggest that DBA

can generate positive returns in many cases. However, DBA has two critical weaknesses: (a) it does not have any order size management; and (b) it does not have any risk management module. In this paper we introduce an improved version of DBA called Intelligent DBA (IDBA). IDBA is designed to overcome these two weaknesses of DBA.

This paper continues as follows: Section2describes the concept of Directional Changes. Section3

provides a brief review of the existing trading strategies that are based on the DC framework. Section4

provides a summary of the trading strategy named DBA. We present the components of IDBA and

explain how it functions in Section5. We discuss the selection and preparation of the datasets in

Section6. The details of the experiments, conducted to evaluate the performance of IDBA, are provided

in Section7. Section8reports and discusses the results of these experiments. Finally, we summarize

the major findings of this paper in Section9.

2. Directional Changes: An Introduction

In this section, we explain how market prices are summarized based on the DC concept. Under the DC framework, the market is represented as alternating uptrends and downtrends. The basic idea is that the magnitude of price change during an uptrend, or a downtrend, must be at least

equal to a specific thresholdtheta. Here,thetais a percentage that the observer considers substantial

(usually expressed as a percentage). For example, Figure 1depicts a price’s drop between points

A and A0.1. This price drop is equal to the selected, hypothetical, threshold of 0.1%. In this case,

we say that we have a DC downtrend that starts at point A. Any price change less than the identified

threshold,theta, will not be considered as a trend when summarizing price movements [1,2]. Under

the DC framework, each uptrend is followed by a downtrend and vice versa. The detection of a new uptrend, or downtrend, is a crucial task. The detection of a new downtrend, or uptrend, is a two-step algorithmic approach:

Step 1: If the market is currently in a downtrend, letPEXTnext denotes the lowest price in this downtrend.

The value ofPEXTnext may change as the price movement continues. We use Table1to exemplify this note.

For example, at time 20:55:00, in Table1, the mid-price is 1.48260. The lowest price observed between

time 20:55:00 and 20:58:00 is 1.48230 which was observed at time 20:56:00. Therefore, the value ofPEXTnext,

at time 20:58:00 is 1.48230. However, as the price’s movement continues, at time 21:01:00, the mid-price becomes 1.48180. In this case, the lowest price observed between point time 20:55:00 and time 21:01:00

(3)

becomesPEXTnext =1.48150 (which was observed at time 21:00:00). Similarly, if the market is currently in

uptrend, thenPEXTnext would refer to the highest price in this uptrend.

Algorithms 2018, 11, x FOR PEER REVIEW

3 of 29

Figure 1. The black line indicates GBP/CHF mid-prices sampled minute by minute from 1 January 2013 19:05:00 to 1 February 2013 02:05:00 (UK). The red line exemplifies what a DC downtrend looks like. Table 1. The progress of the value of 𝑃 during the period from 20:55:00 and 21:05:00. According to

Figure 1 this period refers to a downtrend. In such a case, 𝑃 refer to the lowest price observed so far

during this downtrend.

Time Mid-Price ( 𝑷𝒄) 𝑷𝑬𝑿𝑻𝒏𝒆𝒙𝒕 Point

20:55:00 1.48260 1.48260 20:56:00 1.48230 1.48230 20:57:00 1.48240 1.48230 20:58:00 1.48260 1.48230 20:59:00 1.48200 1.48200 21:00:00 1.48150 1.48150 B (Extreme point) 21:01:00 1.48180 1.48150 21:02:00 1.48170 1.48150 21:03:00 1.48159 1.48150 21:04:00 1.48280 1.48150 21:05:00 1.48310 1.48150 B0.1 (DCC point)

Step 2: Let 𝑃 be the current price. We say that the market switches its direction from a downtrend to

an uptrend if 𝑃 becomes greater than 𝑃 by at least 𝑡ℎ𝑒𝑡𝑎 (where 𝑡ℎ𝑒𝑡𝑎 is the threshold

predetermined by the observer). Similarly, we say that the market switches its direction from an

uptrend to a downtrend if 𝑃 becomes less than 𝑃 by at least 𝑡ℎ𝑒𝑡𝑎. The detection of a new DC

uptrend or a new DC downtrend is a formalized inequality, as shown in Equation (1). For example,

in Table 1, at time 21:05:00, the current price, 𝑃, is 1.48310. At time 21:05:00, the 𝑃 is 1.48150

(which was observed at time 21:00:00). In this case, the magnitude of price’s change between 𝑃 and

𝑃 is ≥ 0.1%. Thus, the inequality in Equation (1) holds and we can confirm the observation of a

new DC uptrend. In other words, at time 21:05:00, we can confirm the observation of a new DC uptrend which has started at time 21:00:00. If the inequality in Equation (1) holds, then the time at

which the market traded at 𝑃 is called an “extreme point” (e.g., point B in Table 1) and the time

at which the market trades at 𝑃 is called a DC confirmation point, or DCC point for short (e.g., point

B0.1 in Table 1). By definition, the extreme point of an uptrend has the lowest price amongst all points

of current uptrend and the immediately preceding downtrend. Similarly, the extreme point of a 1.478 1.480 1.482 1.484 1.486 1.488 1.490 19 :0 5 19 :1 6 19 :2 7 19 :3 8 19 :4 9 20 :0 0 20 :1 1 20 :2 2 20 :3 3 20 :4 4 20 :5 5 21 :0 6 21 :1 7 21 :2 8 21 :3 9 21 :5 0 22 :0 1 22 :1 2 22 :2 3 22 :3 4 22 :4 5 22 :5 6 23 :0 7 23 :1 8 23 :2 9 23 :4 0 23 :5 1 0: 02 0: 13 0: 24 0: 35 0: 46 0: 57 1: 08 1: 19 1: 30 1: 41 1: 52 2: 03 G B P /C H F r at e Time A0.1 A 0.1%

Figure 1.The black line indicates GBP/CHF mid-prices sampled minute by minute from 1 January 2013 19:05:00 to 1 February 2013 02:05:00 (UK). The red line exemplifies what a DC downtrend looks like. Table 1.The progress of the value ofPEXTnextduring the period from 20:55:00 and 21:05:00. According to Figure1this period refers to a downtrend. In such a case,PEXTnext refer to the lowest price observed so far during this downtrend.

Time Mid-Price (Pc) PnextEXT Point

20:55:00 1.48260 1.48260 20:56:00 1.48230 1.48230 20:57:00 1.48240 1.48230 20:58:00 1.48260 1.48230 20:59:00 1.48200 1.48200 21:00:00 1.48150 1.48150 B (Extreme point) 21:01:00 1.48180 1.48150 21:02:00 1.48170 1.48150 21:03:00 1.48159 1.48150 21:04:00 1.48280 1.48150 21:05:00 1.48310 1.48150 B0.1(DCC point)

Step 2: LetPcbe the current price. We say that the market switches its direction from a downtrend to an

uptrend if Pcbecomes greater thanPnext

EXTby at leasttheta(wherethetais the threshold predetermined

by the observer). Similarly, we say that the market switches its direction from an uptrend to a

downtrend if Pcbecomes less thanPEXTnextby at leasttheta. The detection of a new DC uptrend or a new

DC downtrend is a formalized inequality, as shown in Equation (1). For example, in Table1, at time

21:05:00, the current price, Pc, is 1.48310. At time 21:05:00, thePnext

EXTis 1.48150 (which was observed at

time 21:00:00). In this case, the magnitude of price’s change between Pc andPEXTnext is≥0.1%. Thus, the

inequality in Equation (1) holds and we can confirm the observation of a new DC uptrend. In other words, at time 21:05:00, we can confirm the observation of a new DC uptrend which has started at

time 21:00:00. If the inequality in Equation (1) holds, then the time at which the market traded atPnext

EXT

is called an “extreme point” (e.g., point B in Table1) and the time at which the market trades atPc

(4)

the extreme point of an uptrend has the lowest price amongst all points of current uptrend and the immediately preceding downtrend. Similarly, the extreme point of a downtrend has the highest price amongst all points of current downtrend and the immediately preceding uptrend.

Pc −PEXTnext PEXTnext ≥theta (1)

Figure2illustrates the identification of extreme and DCC points for a given financial time series.

In Figure2, points A, B, C, D, E, F and G are the “extreme points”, whereas points A0.1, B0.1, C0.1,

D0.1, E0.1, F0.1, and G0.1are the “DCC points”. An extreme point can be seen as a local minimum

(e.g., point D in Figure2) or a local maximum (e.g., point C in Figure2). An extreme point is only

recognized in hindsight-precisely at the DCC point (i.e., when the inequality in Equation (1) becomes

true). For example, in Figure2, at point A0.1, we confirm that point A is an extreme point. Similarly,

in Figure2, at point D0.1, we confirm that point D is an extreme point. We denote by “price extreme”

(PEXT) the price at which a trend starts. Eventually, when Equation (1) holds, i.e., when a new DC

trend is recognized (either uptrend or downtrend), thePEXTnext becomes thePEXT of this new DC trend.

Algorithms 2018, 11, x FOR PEER REVIEW

4 of 29

downtrend has the highest price amongst all points of current downtrend and the immediately preceding uptrend.

≥𝑡ℎ𝑒𝑡𝑎 (1)

Figure 2 illustrates the identification of extreme and DCC points for a given financial time series.

In Figure 2, points A, B, C, D, E, F and G are the “extreme points”, whereas points A0.1, B0.1, C0.1, D0.1,

E0.1, F0.1, and G0.1 are the “DCC points”. An extreme point can be seen as a local minimum (e.g., point

D in Figure 2) or a local maximum (e.g., point C in Figure 2). An extreme point is only recognized in hindsight-precisely at the DCC point (i.e., when the inequality in Equation (1) becomes true). For

example, in Figure 2, at point A0.1, we confirm that point A is an extreme point. Similarly, in Figure 2,

at point D0.1, we confirm that point D is an extreme point. We denote by “price extreme” (𝑃 ) the

price at which a trend starts. Eventually, when Equation (1) holds, i.e., when a new DC trend is

recognized (either uptrend or downtrend), the 𝑃 becomes the 𝑃 of this new DC trend.

Figure 2. An example of a DC-based summary of the price series shown in Figure 1. Threshold

𝑡ℎ𝑒𝑡𝑎= 0.1%. The black line indicates GBP/CHF mid-prices sampled minute by minute. Solid red lines

represent DC events. Dashed red lines represent OS events. Each of the points A, B, C, D, E, F, and G is an extreme point. Each of the points A0.1, B0.1, C0.1, D0.1, E0.1, F0.1, and G0.1 is a DC confirmation point (DCC point).

Under the DC framework, a trend is dissected into a DC event and an overshoot (OS) event. A DC event starts with an extreme point and ends with a DCC point. We refer to a specific DC event by its starting point, i.e., extreme point, and its DCC point. For example, in Figure 2, the DC event which

starts at point A and ends at point A0.1 is denoted as [AA0.1]. An OS event starts at the DCC point and

ends at the next extreme point. 2.1. The DC Summary

The DC summary of a given market is the identification of the DC and OS events, governed by

the threshold 𝑡ℎ𝑒𝑡𝑎. Figure 2 shows an example of a DC summary with 𝑡ℎ𝑒𝑡𝑎 = 0.1%. Note that we

can produce multiple DC summaries for the same considered price series by selecting multiple thresholds. For example, Figures 2 and 3 illustrate two distinct DC summaries for the same price series using two thresholds: 0.1% for Figure 2 and 0.2% for Figure 3.

1.478 1.480 1.482 1.484 1.486 1.488 1.490 19 :0 5 19 :1 6 19 :2 7 19 :3 8 19 :4 9 20 :0 0 20 :1 1 20 :2 2 20 :3 3 20 :4 4 20 :5 5 21 :0 6 21 :1 7 21 :2 8 21 :3 9 21 :5 0 22 :0 1 22 :1 2 22 :2 3 22 :3 4 22 :4 5 22 :5 6 23 :0 7 23 :1 8 23 :2 9 23 :4 0 23 :5 1 0: 02 0: 13 0: 24 0: 35 0: 46 0: 57 1: 08 1: 19 1: 30 1: 41 1: 52 2: 03 G B P /C H F r at e Time GBP/CHF DC summary. theta = 0.1% DC event B D E F G A0.1 B0.1 C0.1 D0.1 E0.1 F0.1 G0.1 OS event A 0.1% C

Figure 2.An example of a DC-based summary of the price series shown in Figure1. Thresholdtheta

= 0.1%. The black line indicates GBP/CHF mid-prices sampled minute by minute. Solid red lines represent DC events. Dashed red lines represent OS events. Each of the points A, B, C, D, E, F, and G is an extreme point. Each of the points A0.1, B0.1, C0.1, D0.1, E0.1, F0.1, and G0.1is a DC confirmation point (DCC point).

Under the DC framework, a trend is dissected into a DC event and an overshoot (OS) event. A DC event starts with an extreme point and ends with a DCC point. We refer to a specific DC event by its

starting point, i.e., extreme point, and its DCC point. For example, in Figure2, the DC event which

starts at point A and ends at point A0.1is denoted as [AA0.1]. An OS event starts at the DCC point and

(5)

2.1. The DC Summary

The DC summary of a given market is the identification of the DC and OS events, governed by

the thresholdtheta. Figure2shows an example of a DC summary withtheta=0.1%. Note that we can

produce multiple DC summaries for the same considered price series by selecting multiple thresholds.

For example, Figures2and3illustrate two distinct DC summaries for the same price series using two

thresholds: 0.1% for FigureAlgorithms 2018, 11, x FOR PEER REVIEW2and 0.2% for Figure

3. 5 of 29

Figure 3. An example of a DC-based summary of the price series shown in Figure 1. Threshold 𝑡ℎ𝑒𝑡𝑎 =

0.2%. The black line indicates GBP/CHF mid-prices. Solid green lines represent DC events. Dashed green lines represent OS events. Each of the points A, B, E is an extreme point. Each of the points A0.2, B0.2, E0.2 is

a DC confirmation point.

Keep in mind that the observer should specify the value of the DC threshold 𝑡ℎ𝑒𝑡𝑎. One observer

may consider 0.1% to be an important change, while another observer may consider 0.2% as important. The chosen threshold determines what constitutes a directional change [2,3]. If a greater threshold had been chosen, then fewer directional changes would have been concluded between the points. For instance, in Figure 2, the DC summary of threshold 0.1% uncovers four downtrends and three uptrends, whereas, in Figure 3, the DC summary of threshold 0.2% uncovers two downtrends and one uptrend.

2.2. DC Notations

In this section, we introduce some basic notations related to the DC concept. These notations were initially introduced in Tsang et al. [8] and reshaped to fit with the context of this paper.

- 𝑃: This denotes the current price.

- Extreme point: This is the point at which the current DC event starts.

- 𝑃 : It is the price at the extreme point of the current DC event. In the case of a downward DC

event, 𝑃 refers to the highest price in this trend. In the case of an upward DC event, 𝑃 refers

to the lowest price in this trend.

- 𝑃 : If the market is in a downtrend (uptrend), then 𝑃 would refer to the lowest (highest)

price in this downtrend (uptrend).

- 𝑃 ↓and 𝑃 ↑: The interpretations of these two variables depend on whether the market is in

uptrend or downtrend:

o If the market is in uptrend, then 𝑃 ↑ would denote the minimum price required to

confirm the current uptrend (see Equation (3)). If the market is in downtrend, then

𝑃 ↑would denote the minimum price required to confirm the next downtrend.

o If the market is in downtrend, then 𝑃 ↓ would denote the highest price required to

confirm the current downtrend (see Equation (2)). If the market is in downtrend, then 𝑃 ↓

would denote the highest price required to confirm the next uptrend.

- 𝑃𝐷𝐶𝐶: If the market is currently in downtrend, then we have 𝑃𝐷𝐶𝐶 = 𝑃 ↓; otherwise,

𝑃𝐷𝐶𝐶=𝑃 ↑. In the case of downtrend, we compute 𝑃𝐷𝐶𝐶 as:

1.478 1.480 1.482 1.484 1.486 1.488 1.490 19 :0 5 19 :1 6 19 :2 7 19 :3 8 19 :4 9 20 :0 0 20 :1 1 20 :2 2 20 :3 3 20 :4 4 20 :5 5 21 :0 6 21 :1 7 21 :2 8 21 :3 9 21 :5 0 22 :0 1 22 :1 2 22 :2 3 22 :3 4 22 :4 5 22 :5 6 23 :0 7 23 :1 8 23 :2 9 23 :4 0 23 :5 1 0: 02 0: 13 0: 24 0: 35 0: 46 0: 57 1: 08 1: 19 1: 30 1: 41 1: 52 2: 03 G B P /C H F r at e Time GBP/CHF DC summary. theta = 0.2% A A0.2 B B0.2 E E0.2 O S ev en t DC event 0.2%

Figure 3.An example of a DC-based summary of the price series shown in Figure1. Thresholdtheta= 0.2%. The black line indicates GBP/CHF mid-prices. Solid green lines represent DC events. Dashed green lines represent OS events. Each of the points A, B, E is an extreme point. Each of the points A0.2, B0.2, E0.2is a DC confirmation point.

Keep in mind that the observer should specify the value of the DC thresholdtheta. One observer

may consider 0.1% to be an important change, while another observer may consider 0.2% as important.

The chosen threshold determines what constitutes a directional change [2,3]. If a greater threshold

had been chosen, then fewer directional changes would have been concluded between the points.

For instance, in Figure2, the DC summary of threshold 0.1% uncovers four downtrends and three

uptrends, whereas, in Figure3, the DC summary of threshold 0.2% uncovers two downtrends and

one uptrend.

2.2. DC Notations

In this section, we introduce some basic notations related to the DC concept. These notations were

initially introduced in Tsang et al. [8] and reshaped to fit with the context of this paper.

- Pc: This denotes the current price.

- Extreme point: This is the point at which the current DC event starts.

- PEXT : It is the price at the extreme point of the current DC event. In the case of a downward DC

event,PEXT refers to the highest price in this trend. In the case of an upward DC event,PEXT

refers to the lowest price in this trend.

- PEXTnext: If the market is in a downtrend (uptrend), thenPEXTnext would refer to the lowest (highest)

(6)

- PDCC↓andPDCC↑: The interpretations of these two variables depend on whether the market is in uptrend or downtrend:

# If the market is in uptrend, thenPDCC↑ would denote the minimum price required to

confirm the current uptrend (see Equation (3)). If the market is in downtrend, thenPDCC↑

would denote the minimum price required to confirm the next downtrend.

# If the market is in downtrend, thenPDCC↓ would denote the highest price required to

confirm the current downtrend (see Equation (2)). If the market is in downtrend, then

PDCC↓would denote the highest price required to confirm the next uptrend.

- PDCC: If the market is currently in downtrend, then we havePDCC=PDCC↓; otherwise,PDCC

=PDCC↑. In the case of downtrend, we computePDCCas:

PDCC=PDCC↓=PEXT ×(1 − theta) (2)

otherwise:

PDCC= PDCC↑=PEXT ×(1 + theta) (3)

- OSV(theta): The objective of Overshoot Value (OSV) is to measure the magnitude of an overshoot event. Instead of using the absolute value of the price change, we would like this measure to be

relative to the threshold,theta.OSVwas initially formalized by Tsang et al. [8] as:

OSV= ((Pc−PDCC)/PDCC)/theta (4)

More details and examples regarding as to how to computePDCC↑andOSVare provided below.

3. Related Works

In this section, we review some existing DC-based trading strategies. However, firstly, we list and explain some common evaluation metrics that are usually employed to evaluate the performance of a trading strategy.

3.1. Evaluation Metrics

Many studies define success solely based on returns and win ratios, which, practically, has little

value [15,16]. In fact, an investor might be interested in other metrics that evaluate the risk and

risk-adjusted performance of a given trading strategy [17,18]. In this section, we explain a range of

evaluation metrics that were marked as adequate for a decent evaluation of the performance of a given

trading model [17,19].

• Rate of return: The rate of return (RR) symbolizes the bottom line for a trading system over a

definite period. Total Profit (TP) represents the profitability of total trades.TPis computed by

removing the sum of all losing trades from the sum of all winning trades (Equation (5)).TPcan

be negative when the loss is greater than the gain. We denote byRR(Equation (6)) the gain or

loss on an investment over a given evaluation period expressed as a percentage of the amount

invested. In Equation (6),INVdenotes the initial capital employed in investment.

TP=sum of all profits−sum of all losses (5)

RR= TP

I NV×100 (6)

• Profit factor [17]: The profit factor is defined as the sum of profits of all profitable trades divided

by the sum of losses of all losing trades for the entire trading period. This metric measures the amount of profit per unit of risk, with values greater than one signifying a profitable system.

(7)

Pro f it f actor= sum of all profits

sum of all losses (7)

• Max drawdown (%) [20]: The drawdown (Equation (8)) is defined as the difference, in percentage,

between the highest profit (or capital), previous to the current time point, and the current profit

(or capital) value. The Maximum Drawdown (MDD) is the largest drawdown observed during a

specific trading period.MDDmeasures the risk as the “worst case scenario” for a trading period.

This metric can help measure the amount of risk incurred by a system and determine if a system

is practical. In Equations (8) and (9),tidenotes the time-index (i.e., time-stamp).capital(ti) denotes

the value of capital at timeti. Themaximum capital(ti) refers to the peak capital’s value that has

been reached since the beginning of trading up to timeti. Thus, drawdown(ti)(Equation (8)) is

interpreted as the peak-to-trough decline from the start of the trading period up to timeti. The

MDD(Equation (9)) is the maximum value among all computeddrawdown(ti). Many studies

(e.g., [11,21,22]) have usedMDDto measure the risk of a trading strategy. If the largest amount of

money that a trader is willing to risk is greater than the maximum drawdown, the trading system is not suitable for the trader.

drawdown(ti) =

capital(ti)− maximum capital(ti) maximum capital(ti)

(8)

MDD= Max(drawdown(ti)), ∀time ti ∈trading period (9)

• Win ratio [17]: The win ratio is calculated by dividing the number of winning trades by the total

number of trades for a specified trading period. It expresses the probability that a trade will have a positive return.

Win ratio= number o f winning trades

total number o f all trades (10)

• Sharpe ratio [22]: The Sharpe ratio (Equation (11)) is a measure for calculating risk-adjusted return.

The basic purpose of the Sharpe ratio is to allow an investor to analyze how much greater a return he or she is obtaining in relation to the level of additional risk taken to generate that return. The Sharpe ratio can be seen as the average return earned in excess of the risk-free rate per unit of volatility or total risk. To date, it remains one of the most popular risk-adjusted performance

measures due to its practical use. Some studies (e.g., [23,24]) have reported that, despite its

shortcomings, the Sharpe ratio indicates similar performance rankings to the more sophisticated

performance risk-adjusted ratios (e.g., Treynor ratio [25]).

Sharpe ratio= Rp− Rf

σp (11)

whereRpdenotes the expected portfolio returns over the entire trading period andRf is the

risk-free rate. In the context of this paper,σp, in Equation (11), denotes the standard deviation

of the monthly returns. One intuition of the Sharpe ratio calculation (Equation (11)) is that a portfolio engaging in “zero risk” investment, such as the purchase of U.S. Treasury bills (for which the expected return is the risk-free rate), has a Sharpe ratio of exactly zero.

3.2. DCT1

In 2012, Aloud et al. [26] presented a DC-based trading strategy named Zero Intelligence

Directional Change Trading (ZI-DCT0). ZI-DCT0 runs a DC summary with a threshold named

“∆xDC”. ZI-DCT0 has two trading rules:

(a) It initiates a trade at the DC confirmation point of a DC event. The type of trade can be either:

(8)

exhibits a downtrend with the expectation that this downward trend will reverse. A TF (trend follower) trader opens their position with the expectation that the current trend will continue. In the case of CT, ZI-DCT0 opens a position against the market’s trend. TF does the opposite. The user must specify the type of trade: either CT or TF.

(b) ZI-DCT0 closes the position at the DC confirmation point of the succeeding DC event.

When trading with ZI-DCT0, the trader must determine two parameters:

• The type of trade: CT or TF.

• The threshold∆xDCto be used for conducting the DC summary.

In 2015, Aloud [10] presented a trading strategy called “DCT1”. The DCT1 was presented as

an updated version of ZI-DCT0. The trading rules of DCT1 are the same as ZI-DCT0 (i.e., Rules (a) and (b) shown above); however, DCT1 is designed to automatically compute the two parameters: the

DC threshold∆xDCand the type of trade (CT or TF). Firstly, the trader defines a range of thresholds.

Secondly, DCT1 automatically examines the profitability of each threshold, included in the specified range, using historical price data (as the training set). To this end, for each threshold value, the DCT1 applies the trading rules of ZI-DCT0 from two points of view: counter trend (CT) and trend follow (TF). In other words, during the training period, the DCT1 examines the profitability of all possible combinations of: (1) threshold, included in the range; and (2) the trade type (CT or TF). DCT1 returns

the threshold∆xDCand the type of trade (CT or TF) corresponding to the highest produced returns

during the training period. It then uses these values to trade over the trading period.

DCT1 was tested using high frequency data of the EUR/USD currency pair. The author reported that DCT1 was able to produce a rate of return of 6.2% during a testing period of one year (with bid-ask spread being taken into concern). The author did not report any: (a) comparison to a benchmark;

(b) measurement of risk (e.g.,MDD); or (c) evaluation of risk-adjusted metrics (e.g., Sharpe ratio).

3.3. Alpha Engine

In 2017, Golub et al. [12] presented a DC-based trading strategy called “Alpha Engine”. The

Alpha Engine is a contrarian trading strategy. The mechanism of initialization of new positions and the management of existing positions in the market works as follow:

Initially, the Alpha Engine opens a new position, against the market trend, during the OS event

when the price’s change exceeds a certain threshold named “ω”.ωis a function of the predetermined

DC thresholdthetaand a parameter namedα(Equation (12)). The value ofαis governed by a specific

money management module.

ω=α×theta (12)

The Alpha Engine does not have an explicit stop-loss rule. Instead, it employs a sophisticated money management approach. When Alpha Engine opens a new position, it keeps managing the size of this position until it closes in a profit. The Alpha Engine is capable of opening and managing multiple positions concurrently. The Alpha Engine increases and decreases the size of each position as the price progresses. The basic idea is that an existing position is increased by some increment in case of a loss, bringing the average closer to the current price. For a de-cascading event, an existing position is decreased, realizing a profit.

When triggering a new trade, Alpha Engine must decide the “time” and the “size” of that trade.

For this purpose, the Alpha Engine takes into concern two main factors:

(a) The inventory size which will be used to control the value ofαin Equation (12) and consequently

the time of when to trigger a trade.

(b) The market behavior which is modeled as a transition network adopted from the study of

Golub et al. [27] to find whether the market exhibits normal or abnormal (e.g., observation of an

unlikely strong trend) behavior. They use the status of the market behavior to control the size of an order.

(9)

The above modules, (a) and (b), help the Alpha Engine not to build up large positions which

they cannot unload and to keep theMDDat a reasonable level. The Alpha Engine was extensively

backtested using a portfolio of 23 currency rates sampled tick-by-tick over a period of eight years: from the beginning of 2006 until the beginning of 2014. Alpha Engine produces a return of 21.34% over eight years (they used the bid and ask prices), with a maximum drawdown of 0.71% (calculated on a daily basis). The authors reported an annual Sharpe ratio (Equation (11)) of 3.06. However, they did not specify the used risk-free rate!

3.4. DC + GA

In 2017, Kampouridis and Otero [11] proposed a DC-based trading strategy named “DC + GA”.

DC + GA runs multiple DC summaries concurrently (using multiple thresholds). For each threshold, DC + GA calculates the average time length of each DC and OS event for every DC trend during a training (in-sample) period. DC + GA employs two variables to express the average ratio of the OS

event length over the DC event length. These two variables areruandrd, whereruis the average ratio

of the upwards OS event, andrdis the average ratio of the downwards OS event. Thus, DC + GA

analyses uptrends and downtrends separately. The objective is to be able to anticipate the end of an uptrend, or downtrend, (approximately) and as a result make trading decisions (buy or sell) once an

OS event had reached the average ratio ofruorrd. Theoretically, DC + GA initiates a trade when the

length of an OS event exceedsruorrd.

The authors formed two parameters, namelyb1andb2, which define a range of time within the

OS period, where trading is allowed. For instance, if a trader expects the OS event to last for 2 h (this

expectation is based on the calculus ofruandrd), and assuming that the range of [b1,b2] is [0.9, 1.0],

then this means that DC + GA is going to trade (buy or sell) at the last 10% of the 1 h duration, i.e., in the last 6 min.

Recall that DC + GA runs multiple DC summaries simultaneously (using multiple thresholds) for

a given currency pair. LetNthetabe the number of employed DC thresholds. The user/trader should

chose the values of theNthetathresholds. DC + GA assigns a weight to each DC threshold. For a given

price observation, each threshold provides a recommendation (buy, sell or hold). At a given time, the Nthetathresholds provideNthetarecommendations. TheseNthetarecommendations are combined to produce the final decision: buy, sell or hold. DC + GA employs a Genetic Algorithm (GA) approach to

find the best combination of theseNthetarecommendations. The GA module of DC + GA employs a

fitness function which aims to minimize the maximum drawdown (MDD) and maximize returns at

the same time.

To evaluate the performance of DC + GA, the authors considered five currency pairs sampled

with a 10-min interval over one year. The authors concluded that DC + GA “. . .could not consistently

return profitable strategies and thus their mean returns were negative”. The authors have adopted the buy

and hold approach as a benchmark. They reported that the proposed trading strategy “. . .return a

similar average return with BH”. We should finally note that the reportedMDDof DC + GA is less than

0.15% (measured on daily basis) in all considered cases (Table 11 in [11]). We consider this value as an

attractive level of the drawdown risk. 3.5. TSFDC

In 2018, Bakhach et al. [13] presented a DC-based trading strategy named TSFDC. They presented

two versions of TSFDC, namely TSFDC-down and TSFDC-up. However, they reported that there is no difference between the performances of both versions. Therefore, in this section, we describe only TSFDC-down (henceforth, TSFDC). TSFDC relies on the forecasting model previously developed by

Bakhach et al. [6] which aims to answer the question of whether the current DC trend will continue

for a specific percentage, denoted asBTheta, before the trend reverses. To formalize this objective, the

authors tracked price changes with two thresholds simultaneously:BThetaandSTheta(withBTheta>

(10)

0.1% is [AA0.1]. Point A0.1is the DCC point of the DC event [AA0.1]. The objective, in this example,

is to predict at A0.1whether the trend of the DC event [AA0.1] will continue so that its total magnitude

will be at least equal toAlgorithms 2018, 11, x FOR PEER REVIEWBTheta.

10 of 29

Figure 4. The synchronization of two DC summaries with two thresholds: STheta= 0.1% (in red lines) and

BTheta= 0.2% (in green) for GBP/CHF rate sampled minute by minute from 1 January 2013 19:05:00 to 1

February 2013 02:05:00. Source: Bakhach et al. [6]. 3.6 Summary

In this section, we provide some technical comments and a brief critical review for the trading strategies revised above. For instance, the evaluation of the performance of DCT1 did not include any

measurement of risk (e.g., MDD) or risk-adjusted performance (e.g., Sharpe ratio) [10]. Furthermore,

the author backtested the performance of DCT1 using only one currency pair (namely, EUR/USD). These notes pose serious questions regarding the feasibility of DCT1.

The Alpha Engine strategy [12] has been extensively backtested using 23 currency pairs over a period of eight years. The author reported that the Alpha Engine can produce a cumulative rate of return of 21.34% over this period. They also reported that it can produce an annualized Sharpe ratio of 3.06. However, they did not report the employed risk-free rate. This is very critical. For example, if they have considered an annualized risk-free rate of 3%, as we do below, then the cumulative rate of return, of a risk-free rate investment, would be more than 26% over the same period of eight years. Thus, there is a great chance that the Sharpe ratio of the Alpha Engine would be negative in such a case.

Even though DC + GA has an attractive MDD, the reported monthly returns in [11] show that

the DC + GA incur losses in about 50% of the cases! The authors concluded that the proposed model “…could not consistently return profitable strategies and thus their mean returns were negative”. Besides, the author did not report any risk-adjusted measurement. However, if we consider a risk-free rate of 3% per annum, then we find that DC + GA produced negative Sharpe ratio in all considered currency pairs.

Finally, the evaluation of TSFDC did not take into concern the bid and ask spread. The authors employed the mid-prices for their experiments [13]. This is a very severe limitation because the performance of a trading strategy can be extremely sensitive to the bid and ask spread [14], which imposes serious doubt regarding the overall performance and reported results of TSFDC.

In this paper, we present a trading strategy which is also based on the directional changes framework. However, we adopt a higher standard of evaluation methodology than the aforementioned strategies. This, hopefully, provides sufficient evidence regarding the feasibility of the strategy presented in this paper.

1.478 1.480 1.482 1.484 1.486 1.488 1.490 19 :0 5 19 :1 7 19 :2 9 19 :4 1 19 :5 3 20 :0 5 20 :1 7 20 :2 9 20 :4 1 20 :5 3 21 :0 5 21 :1 7 21 :2 9 21 :4 1 21 :5 3 22 :0 5 22 :1 7 22 :2 9 22 :4 1 22 :5 3 23 :0 5 23 :1 7 23 :2 9 23 :4 1 23 :5 3 0: 05 0: 17 0: 29 0: 41 0: 53 1: 05 1: 17 1: 29 1: 41 1: 53 2: 05 G B P /C H F r at e Time A0.2 A B B0.2 E0.2 E B0.1 C C0.1 D0.1 D F0.1 E0.1 F G G0.1 A0.1 ST he ta BT he ta

Figure 4.The synchronization of two DC summaries with two thresholds:STheta=0.1% (in red lines)

andBTheta=0.2% (in green) for GBP/CHF rate sampled minute by minute from 1 January 2013

19:05:00 to 1 February 2013 02:05:00. Source: Bakhach et al. [6].

TSFDC decides when to trigger a new trade based on the made forecast. TSFDC is a contrarian strategy (e.g., it triggers buy order when the market exhibits a downtrend). Consider, for example,

the downward DC event [AA0.1]. The forecasting model make prediction at point A0.1. If it predicts

that the trend will reverse before reaching the thresholdBThetathan TSFDC generates buy order

immediately at point A0.1. Otherwise, TSFDC will wait until a DC event of threshold ofBThetais

confirmed (i.e., at point A0.2in this example) and then generates a buy order.

The performance of TSFDC was examined using eight currency pairs and a rolling window approach. Each rolling window was composed of a training (24 months in length) and an applied period (one month in length). For each currency pair, the authors considered seven rolling windows;

thus, the overall applied period’s length is seven months. The results reported in [13] suggested that

TSFDC can be amazingly profitable with a rate of return of more than 500%, and Sharpe ratio of up to 4.2. However, the authors did not consider the bid and ask prices nor the transaction costs.

3.6. Summary

In this section, we provide some technical comments and a brief critical review for the trading strategies revised above. For instance, the evaluation of the performance of DCT1 did not include any

measurement of risk (e.g.,MDD) or risk-adjusted performance (e.g., Sharpe ratio) [10]. Furthermore,

the author backtested the performance of DCT1 using only one currency pair (namely, EUR/USD). These notes pose serious questions regarding the feasibility of DCT1.

The Alpha Engine strategy [12] has been extensively backtested using 23 currency pairs over a

period of eight years. The author reported that the Alpha Engine can produce a cumulative rate of return of 21.34% over this period. They also reported that it can produce an annualized Sharpe ratio of 3.06. However, they did not report the employed risk-free rate. This is very critical. For example, if they have considered an annualized risk-free rate of 3%, as we do below, then the cumulative rate of

(11)

return, of a risk-free rate investment, would be more than 26% over the same period of eight years. Thus, there is a great chance that the Sharpe ratio of the Alpha Engine would be negative in such a case.

Even though DC + GA has an attractiveMDD, the reported monthly returns in [11] show that the

DC + GA incur losses in about 50% of the cases! The authors concluded that the proposed model “. . . could not consistently return profitable strategies and thus their mean returns were negative”. Besides, the author did not report any risk-adjusted measurement. However, if we consider a risk-free rate of 3% per annum, then we find that DC + GA produced negative Sharpe ratio in all considered currency pairs. Finally, the evaluation of TSFDC did not take into concern the bid and ask spread. The authors

employed the mid-prices for their experiments [13]. This is a very severe limitation because the

performance of a trading strategy can be extremely sensitive to the bid and ask spread [14], which

imposes serious doubt regarding the overall performance and reported results of TSFDC.

In this paper, we present a trading strategy which is also based on the directional changes framework. However, we adopt a higher standard of evaluation methodology than the aforementioned strategies. This, hopefully, provides sufficient evidence regarding the feasibility of the strategy presented in this paper.

4. Dynamic Backlash Agent

In 2016, Bakhach et al. [14] developed a trading strategy named Dynamic Backlash Agent (DBA),

which is based on the DC framework. The objective of this paper is to provide DBA with additional modules to improve its overall performance. In this section, we provide detailed description as to how DBA functions.

4.1. DBA: Basic Trading Rules

In this section, we describe the trading strategy named Dynamic Backlash Agent (DBA),

as introduced in [14]. DBA is only applicable when the market is in a downtrend. DBA consists

of two rules:

Rule DBA.1: (generate buy signal)

If the current OS event is on a downtrend andOSV≤down_ind, then generate buy signal.

Rule DBA.2: (generate sell signal)

IfPc≥PDCC↑and a buy order has been fulfilled, then generate sell signal.

InRule DBA.1:OSVis the variable previously defined in Section2.2anddown_indis a trading

parameter. In simple terms, DBA generates a buy signal when the Overshoot Value (OSV) drops below

a certain threshold, namelydown_ind, during a downtrend’s OS event. DBA generates a sell signal

when the DC confirmation point of the next upward DC event is confirmed.

InRule DBA.2,PDCC↑ denotes the minimum price required to confirm the observation of the

subsequent uptrend DC event (see Section2.2). The condition ofRule DBA.2denotes the case under

which we confirm the DCC point of the next uptrend DC event of thresholdtheta. Note thatRule

DBA.2is applicable only if a buy signal has been triggered. In other words, no short selling is allowed.

DBA.2plays two roles at the same time:take-profitandstop-loss. WhenDBA.2triggers a sell signal,

it may incur losses (hence, functioning asstop-loss) or generate profits (thus, working astake-profit).

Table2illustrates an example of a DC summary. We use Table2to provide an example of how the

trading rules of DBA function by examining the downward DC event [CC0.1], of threshold 0.10%,

(12)

Table 2. An example of a DC summary of GBP/CHF mid-prices sampled minute-by-minute from 21:41:00 to 22:01:00on 1 January 2013 (UK time). Excessive and unnecessary observation were omitted.

theta=0.10%. We also compute the values ofPDCCandOSV.

Time Mid-Price DC Event PDCC Point OSV

21:41:00 1.48690 start DC event (DOWNTREND) C

21:42:00 1.48480 start OS event (DOWNTREND) 1.48541310 C0.1 −0.41274713

21:43:00 1.48470 −0.48006847

21:44:00 1.48520 −0.14346177

21:45:00 1.48495 −0.31176512

21:46:00 1.48412 start DC event (UPTREND) D −0.87053224

. . . .

22:01:00 1.48570 start OS event (UPTREND) 1.48560412 D0.1 0.0645394

(a) Suppose that the trader has chosendown_ind=−0.45.

(b) At time 21:43:00 (shown in column “Time”), the value ofOSVis−0.48006847 (shown in column

“OSV”), which is less thandown_ind(−0.45). In this example,OSVis computed as follows:

# C is the extreme point of the downward DC event [CC0.1]. Astheta=0.001, based on

Equation (2) (Section2.2), we get:

PDCC=PEXT×(1− 0.001) =1.48690×0.999=1.48541310.

At time 21:43:00, the mid-price is 1.48470. Thus, based on Equation (4) (Section2.2):

OSV = ((Pc−PDCC)/PDCC)/theta (13)

OSV = ((1.48470 − 1.4854131)/1.4854131)/0.001=−0.48006847.

(c) Based on (a) and (b), both conditions ofRule DBA.1are fulfilled. Therefore DBA generates a buy

signal at time 21:43:00.

(d) [DD0.1] is the upward DC event, which immediately follows the downward DC event [CC0.1].

At time 22:01:00, we confirm the DCC point of [DD0.1], which is D0.1. Based onRule DBA.2,

DBA will generate a sell signal at time 22:01:00. 4.2. Finding the Value of down_ind

DBA comprises two stages. In the first stage, DBA automatically determines the value of the

parameterdown_ind. For this purpose, DBA applies a procedure, named FIND_DOWN_IND, to a

training (i.e., in-sample) dataset to determine the value ofdown_ind. In the second stage, DBA uses the

two rules (Rule DBA.1andRule DBA.2) to trade over a trading, out-of-sample, dataset using the value

ofdown_indreturned by FIND_DOWN_IND.

The objective of the procedure FIND_DOWN_IND is to find an appropriate value for the

parameter down_indto be utilized in trades with DBA during the applied period. The output of

the procedure FIND_DOWN_IND is one numerical variable, namedbest_down_ind. To determine

best_down_ind, FIND_DOWN_IND applies the trading rules of DBA to the training dataset using

100 different values ofdown_ind(from−0.01 to−1.00, with a step size of−0.01). For each value of

down_ind, we compute the returns, either profits or losses, obtained by applying DBA to the training dataset. Thus, for a given training period we get 100 returns—one return for each distinct value of down_ind. We definebest_down_indas the value ofdown_indunder which DBA generated the highest

returns using the training dataset. In the second stage, DBA applies the trading rules (Rule DBA.1and

Rule DBA.2) with the input parameter “down_ind” being assigned the value ofbest_down_indto trade over the trading dataset.

(13)

5. Intelligent Dynamic Backlash Agent: IDBA

The objective of this paper is to develop an improved version of the trading strategy DBA. In this section, we introduce a trading strategy named Intelligent Dynamic Backlash Agent (IDBA) which is based on the DC framework. IDBA overcomes two weaknesses of DBA as it incorporates: (a) an intelligent module to control the size of an order; and (b) a risk management module. In this section, we explain the main modules of IDBA.

5.1. The Learning Module

IDBA adopts the same trading rules of DBA (Section4.1). Thus, IDBA has two trading parameters

thetaanddown_ind(Section4.1). The authors in [14] proposed a computational approach to find an

appropriate value of the parameterdown_ind(Section4.2). However, the experimental results reported

in [14] suggest that the performance of DBA can also be affected by the values oftheta(see Figure5).

The authors did not present any method as to how to find an appropriate value fortheta.

IDBA extends the search space of DBA in that IDBA searches for the best couple (theta,down_ind).

For this purpose, IDBA follows a similar computational approach to that of DBA. In details, IDBA

considers a range of values for the thresholdthetain addition to the range of the parameterdown_ind

[−0.01 to−1.00]. The user has to select the range of values for the thresholdtheta. For simplicity,

we consider the values with only one decimal value. For example, iftheta ∈[0.1%, 2.5%]then IDBA

will consider the 25 values from 0.1% up to 2.5% with a step size of 0.1. IDBA scans the entire search

space, i.e., it tries all values of couples (theta, down_ind), to find an appropriate couple of values

from the parametersthetaanddown_ind. In this example, IDBA will consider 25×100 different

values of couples (theta, down_ind) when applying the two trading rules of DBA (Section4.1) to

the training period. The couple of (theta,down_ind) which produces the highest returns, during the

training period, will then be employed to trade over the trading period. Let (best_theta,best_down_ind)

denote this couple of trading parameters. The authors of [14] also reported that the initial version of

DBA is extremely sensitive to the bid-ask spread (see Figure5). Thus, in this paper, we examine the

performance of IDBA using the instantaneous bid and ask spread.

Algorithms 2018, 11, x FOR PEER REVIEW

13 of 29

the training period, will then be employed to trade over the trading period. Let (𝑏𝑒𝑠𝑡_𝑡ℎ𝑒𝑡𝑎,

best_down_ind) denote this couple of trading parameters. The authors of [14] also reported that the initial version of DBA is extremely sensitive to the bid-ask spread (see Figure 5). Thus, in this paper, we examine the performance of IDBA using the instantaneous bid and ask spread.

Figure 5. Variation of cumulative profits generated by DBA using mid-prices (dashed blue line) and using bid/ask price (solid red line). Source: Bakhach et al. [14].

5.2. Calculating Order Size

IDBA essentially follows the same trading rules as DBA (Rule DBA.1 and Rule DBA.2 in Section

4.1). IDBA will generate a buy order when the conditions of Rule DBA.1 are full filled. However, DBA

does not incorporate any specific approach to determine the size of a buy order. DBA uses all available capital whenever a buy order is triggered [14]. By contrast, IDBA embraces a specific approach to decide the size of an order. In this section, we present an original mechanism which IDBA follows to decide the size of a buy order.

To decide the size of an order, IDBA tries firstly to forecast whether a specific trade will generate profit. IDBA will then compute the size of a buy order based on this forecasting. This forecasting approach has three principal elements: (a) the dependent variable (the one to be predicted); (b) the independent variables; and (c) the machine learning algorithm (employed to find the relationship between the dependent and independent variables). First, we need to define the dependent variable.

We call this variable the Boolean Return (BR). We associate an instance of BR to each trade. Here, a

trade is defined as the execution of the two trading rules Rule DBA.1 and Rule DBA.2 (not just one of

them). BR can be either True or False. If the return of a specific trade is positive, then the instance of

BR associated with this specific trade will be True; otherwise, BR will be False. In this section, we

provide a forecasting model which aims to predict whether the BR of a specific trade will be True.

An essential part of a forecasting model is the choice of the independent variable(s). To predict

the value of BR, we will use two independent variables and employ an appropriate machine learning

algorithm. In this section, we present these independent variables and the selected machine learning algorithm. We then explain how an order’s size is computed.

5.2.1. The Independent Variables

In this section, we introduce the two independent variables that are used as explanatory

variables to predict BR. We want to recap that IDBA triggers a buy order based on Rule DBA.1 (Section

4.1) which states that:

If (the current OS event is on a downtrend) and (𝑂𝑆𝑉 ≤ down_ind) then generate a buy signal.

In other words, IDBA triggers a buy order when the market exhibits a downtrend under

threshold 𝑡ℎ𝑒𝑡𝑎 and when the overshoot value (𝑂𝑆𝑉) drops below down_ind. The two prospective

13.39 -20 0 20 40 60 80 0.1 0.2 0.3 0.4 0.5 0.6 0.7 C um ul at iv e P ro fi t ( % ) theta

GBP/CHF: Trading with DBA

mid-price bid_ask

Figure 5.Variation of cumulative profits generated by DBA using mid-prices (dashed blue line) and using bid/ask price (solid red line). Source: Bakhach et al. [14].

5.2. Calculating Order Size

IDBA essentially follows the same trading rules as DBA (Rule DBA.1andRule DBA.2in Section4.1).

IDBA will generate a buy order when the conditions ofRule DBA.1are full filled. However, DBA does

not incorporate any specific approach to determine the size of a buy order. DBA uses all available

(14)

decide the size of an order. In this section, we present an original mechanism which IDBA follows to decide the size of a buy order.

To decide the size of an order, IDBA tries firstly to forecast whether a specific trade will generate profit. IDBA will then compute the size of a buy order based on this forecasting. This forecasting approach has three principal elements: (a) the dependent variable (the one to be predicted); (b) the independent variables; and (c) the machine learning algorithm (employed to find the relationship between the dependent and independent variables). First, we need to define the dependent variable.

We call this variable the Boolean Return (BR). We associate an instance ofBRto each trade. Here,

a trade is defined as the execution of the two trading rulesRule DBA.1andRule DBA.2(not just one of

them).BRcan be eitherTrueorFalse. If the return of a specific trade is positive, then the instance ofBR

associated with this specific trade will beTrue; otherwise,BRwill beFalse. In this section, we provide a

forecasting model which aims to predict whether theBRof a specific trade will beTrue.

An essential part of a forecasting model is the choice of the independent variable(s). To predict

the value ofBR, we will use two independent variables and employ an appropriate machine learning

algorithm. In this section, we present these independent variables and the selected machine learning algorithm. We then explain how an order’s size is computed.

5.2.1. The Independent Variables

In this section, we introduce the two independent variables that are used as explanatory variables

to predictBR. We want to recap that IDBA triggers a buy order based onRule DBA.1(Section4.1)

which states that:

If (the current OS event is on a downtrend) and (OSV≤down_ind) then generate a buy signal.

In other words, IDBA triggers a buy order when the market exhibits a downtrend under threshold thetaand when the overshoot value (OSV) drops belowdown_ind. The two prospective independent variables are intended to designate the market behavior between the period from the beginning of the downward DC event (i.e., at the extreme point) and the time of triggering the buy order (i.e., when the

conditions ofRule DBA.1are fulfilled). These two variables are:

1. Time for triggering buy order (TBO)

The variableTBOdenotes the length of the period between the extreme point of the current

downtrend and the time when the conditions ofRule DBA.1is triggered are full filled (see Figure6).

Simply put, for a particular trade:

TBO=time(OSV <down_ind)− time(Extreme point) +1 (14)

where time(OSV < down_ind) denotes the time at which IDBA triggers the buy order and

time(Extreme point)denotes the time at which the extreme point of that particular DC downtrend

has been observed. For example, in Table3, suppose thatdown_ind=−0.45. At time 21:43:00 (shown

in column “Time”), we determine that theOSV=−0.48006847 (shown in column “OSV”), which is

less thandown_ind(−0.45). In this example, IDBA will trigger a buy order at 21:43:00. Essentially,

TBOis employed to measure period of time. Thus, its unit of measure would be minutes, hours,

days, etc. In Equations (14) and (15), we only consider the numeric value ofTBOwithout the unit of

measurement. In this example, we will have:

TBO=43− 41+1=3 (15)

where 43 is the minute-index at which we confirm thatOSV<down_ind(see Table3) and 41 is the

(15)

Algorithms2018,11, 171 15 of 29 independent variables are intended to designate the market behavior between the period from the beginning of the downward DC event (i.e., at the extreme point) and the time of triggering the buy

order (i.e., when the conditions of Rule DBA.1 are fulfilled). These two variables are:

1. Time for triggering buy order (TBO

The variable 𝑇𝐵𝑂 denotes the length of the period between the extreme point of the current

downtrend and the time when the conditions of Rule DBA.1 is triggered are full filled (see Figure 6).

Simply put, for a particular trade:

𝑇𝐵𝑂 = 𝑡𝑖𝑚𝑒(𝑂𝑆𝑉 < 𝑑𝑜𝑤𝑛_𝑖𝑛𝑑) − 𝑡𝑖𝑚𝑒(𝐸𝑥𝑡𝑟𝑒𝑚𝑒 𝑝𝑜𝑖𝑛𝑡) + 1 (14)

where 𝑡𝑖𝑚𝑒(𝑂𝑆𝑉 < 𝑑𝑜𝑤𝑛_𝑖𝑛𝑑) denotes the time at which IDBA triggers the buy order and

𝑡𝑖𝑚𝑒(𝐸𝑥𝑡𝑟𝑒𝑚𝑒 𝑝𝑜𝑖𝑛𝑡) denotes the time at which the extreme point of that particular DC downtrend

has been observed. For example, in Table 3, suppose that down_ind= −0.45. At time 21:43:00 (shown

in column “Time”), we determine that the 𝑂𝑆𝑉 = −0.48006847 (shown in column “𝑂𝑆𝑉”), which is

less than down_ind (−0.45). In this example, IDBA will trigger a buy order at 21:43:00. Essentially,

𝑇𝐵𝑂 is employed to measure period of time. Thus, its unit of measure would be minutes, hours, days,

etc. In Equations (14) and (15), we only consider the numeric value of 𝑇𝐵𝑂 without the unit of

measurement. In this example, we will have:

𝑇𝐵𝑂 = 43 − 41 + 1 = 3 (15)

where 43 is the minute-index at which we confirm that 𝑂𝑆𝑉 <down_ind (see Table 3) and 41 is the

minute-index at which the extreme point, of this particular downtrend, was observed.

Figure 6. Illustration of DC summary with 𝑡ℎ𝑒𝑡𝑎 = 0.1%. [AA0.1] denotes a downward DC event. The point

marked with a red “x” denotes the time at which IDBA triggers a buy order (Rule DBA.1). 𝑇𝐵𝑂 denotes the

time length between the time at which the DC event [AA0.1] starts (i.e., the extreme point “A”) and point

“x”. 1.478 1.480 1.482 1.484 1.486 1.488 1.490 19 :0 5 19 :1 6 19 :2 7 19 :3 8 19 :4 9 20 :0 0 20 :1 1 20 :2 2 20 :3 3 20 :4 4 20 :5 5 21 :0 6 21 :1 7 21 :2 8 21 :3 9 21 :5 0 22 :0 1 22 :1 2 22 :2 3 22 :3 4 22 :4 5 22 :5 6 23 :0 7 23 :1 8 23 :2 9 23 :4 0 23 :5 1 0: 02 0: 13 0: 24 0: 35 0: 46 0: 57 1: 08 1: 19 1: 30 1: 41 1: 52 2: 03 G B P /C H F r at e Time GBP/CHF DC summary. theta = 0.1% DC event B D E F G A0.1 B0.1 C0.1 D0.1 E0.1 F0.1 G0.1 A 0.1% C

x

𝑇𝐵𝑂

Figure 6.Illustration of DC summary withtheta =0.1%. [AA0.1] denotes a downward DC event. The point marked with a red “x” denotes the time at which IDBA triggers a buy order (Rule DBA.1).TBO

denotes the time length between the time at which the DC event [AA0.1] starts (i.e., the extreme point “A”) and point “x”.

Table 3. An example of a DC summary of GBP/CHF mid-prices sampled minute-by-minute on 1 January 2013 from 21:41:00 to 22:01:00 (UK time). Excessive and unnecessary observation were omitted.

theta=0.10%. We also compute the values ofPDCCandOSV.

Time Mid-Price DC Event PDCC Point OSV

21:41:00 1.48690 start DC event (DOWNTREND) C 2.64231213

21:42:00 1.48480 start OS event (DOWNTREND) 1.48541310 C0.1 −0.41274713

21:43:00 1.48470 −0.48006847

21:44:00 1.48520 −0.14346177

2. Standard Deviation of Price Series

Letσpdenotes the mathematical standard deviation of prices observed between the beginning of

a downward DC event and the time at which IDBA triggers a buy order. The standard deviation (see

Equation (16)), denoted asσp, can be considered as a measure of the instability of a financial time series

over a particular period [17]. In this case, the length of this period is equal to the numerical value of

TBO. Thus, in the example of Table3, the value ofTBOis 3 (see Equation (15)).

σp= s ∑TBO i=1 (Pi−AP) 2 TBO (16)

whereTBOrefers to the variable in Equation (14). Here,Pidenote theith price observation andAP

denotes the mathematical mean of the market’s prices during the considered period. In the example of

Table3,σpwould be computed as the standard deviation of the prices recorded between time 21:41:00

(16)

5.2.2. C4.5

The C4.5 algorithm descends from the divide-and-conquer algorithm for generating decision

trees [28]. C4.5 has three main steps. First, for each attributeλ, it computes the normalized information

gain ratio from splitting onλ.Letλ_bestbe the attribute with the highest normalized information gain.

Second, it creates a decision nodendthat splits onλ_best. Third, it recurs on the sub-lists obtained by

splitting onλ_best, and adds those nodes as children of nodend. The three steps are repeated until a

base case is reached. This algorithm has multiple base cases:

• All samples in the list belong to the same class. When this happens, it simply creates a leaf node

for the decision tree saying to choose that class.

• None of the features provide any information gain. In this case, C4.5 creates a decision node

higher up the tree using the expected value of the class.

• Instance of previously-unseen class encountered. Again, C4.5 creates a decision node higher up

the tree using the expected value.

5.2.3. Computing the Order Size

The objective of forecasting whether aBRof a specific trade is to decide the size of the buy order

of that particular trade. To this end, we use the concept of confusion matrix. A confusion matrix is a specific table layout that allows visualization of the performance of a classification algorithm such as

C4.5. Table4illustrates a typical confusion matrix.

Table 4.An illustration of a confusion matrix.

Actual True False Predicted True TP FP

False FN TN

In the context of this paper:

- TPdenote the number of correctly classifiedTrueinstances ofBR.

- FPdenotes the number ofFalseinstances ofBRfalsely predicted to beTrue.

- FNdenote the number ofTrueinstance ofBRfalsely predicted to beFalse.

- TNdenote the number of correctly classifiedFalseinstances ofBR.

Based on Table4, we define two ratios, namely the Positive Predictive Value (PPV) and False

Negative Rate (FNR), as in Equations (17) and (18), respectively.

PPV= TP

TP+FP (17)

FNR= FN

FN+TN (18)

We callPPVandFNRthe “order size parameters”. LetFBRdenote the forecasted value ofBR.

The value ofFBR, which can be eitherTrueorFalse, is determined by the C4.5 algorithm with the

variablesTBOandσpconsidered as the input attributes. Let “Order Size” denote the size of a buy

order generated by IDBA. LetCapitaldenote the capital available at the current time. Whenever IDBA

generates a buy order, the size of an order is calculated as follow:

ifFBR=True, then

References

Related documents

This modification allows the user to enter the invoice in USD, enter the payment amount in AUD in the AUD bank account, allocate the USD invoice to the AUD payment and then se -

other power plants hasshown temperature as an important factor in increasing biomass, primary productivity and changes in species dominance of phytoplankton around the vicinity

Customer engagement archetype (figure 7, section 4.5.2 of chapter 4) attempts to create and capture value using a different mechanism, one where the company invests into the core

But to our knowledge there is no comparison of up to date instrumental estimators, like the system estimator proposed by Blundell and Bond (1998) and direct bias corrected

It should be noted that I use the social model of disability because it seems coherent with communitarianism, this is because the force thesis and the normative

[r]

In Act 1, scene 7, for instance, Macbeth muses on Duncan’s many good qualities, reflects that Duncan has been kind to him, and thinks that perhaps he ought not to kill his king..

WellLight: A lab device for supporting labwork with 96 (and 386) well plates – US Patent pending, released for marketing and distribution TB test to detect TB infection and latent