3.1. Assumptions
The course trajectory of a given financial instrument can be seen as a change process of the market state. This process reflects the behavioral patterns of the investors. The foundation of the state modelling as well as other methods of technical analysis is the assumption about the existence of statistically more frequent patterns in exchange rate fluctuations than it would imply from the assumption of its completely random fluctuations in the rate (
Peters 1996;
Yao and Tan 2000;
Li et al. 2019). The change patterns represent investors’ behaviors and are defined in the models as sequences of state changes. They occur as a response to the current market state. An example can be the occurrence of corrections after a certain period of increases caused by the publication of important information (e.g., about interest rates). Part of the investors assumes that the price is already overestimated and they start to sell the instrument, which leads to a fall in the price (i.e., the so-called correction). On the psychological grounds, such parameters such as risk aversion force the investors to make decisions according to some defined patterns (
Oberlechner 2005). Another argument for the existence of repetitive behavioral patterns of investors is technical and fundamental analysis methods, which are popularized in numerous publications. As a result, one can assume that a large number of investors will make similar decisions and, as a consequence, will influence the course trajectory in the same way.
State modelling of the exchange rate trajectory in a binary representation consists in defining the states in such a way that the specific set of changes can be always assigned a given state. We assume that the states change at the end of change duration in the binary model. The state-space includes a limited number of states. The state model can be described by the so-called transition process graph, which shows a “picture” of the market that reflects the process of market changes. The graph presents all possible transitions between the states. Based on historical data of the considered instrument one can assign probabilities of transitions between states and next, corresponding probabilities of the future changes, which are saved in a so-called prediction table. The prediction table can, in turn, be a basis for constructing an HFT system.
3.2. Binary State Model
The first and simplest state model in the binary representation is the SMBR model (State Model in Binary Representation) (
Stasiak 2016). The main idea of the model is to define the states of the market as a set of possible directions of a given number of binary changes in the course trajectory. Next, the probability of the direction of a next change is to be calculated based on the analysis of transition frequency between states. In the SMBR model, the course for
N observed changes is presented as a binary sequence
, given by (1). Therefore, we have:
SMBR model assumes, that the order of changes in its newest history (i.e., m last changes) influences the probability of the future change direction. Thus, the model uses the order and type of changes in the binary representation to analyze behavior patterns of investors, yet it does not analyze the duration of the changes.
State in SMBR model is defined as a set
of ensuing course changes:
Depending on the parameter
m we can determinate the state space we can determinate the state space
where the number of states
k is described by the number of all m-element permutations with repetitions from the two-element set {0,1}:
It is worth noting that during the observation period of N ensuing changes, the trajectory of the change process in the SMBR model would consist of N − m + 1 ensuing states.
Based on the defined states one can construct a graph of the change process, in which the states are represented by vertices and edges define the set of possible transitions between states. Each edge of the graph is assigned frequency value of the transition between given states, that are calculated based on historical data:
where
in the number of returns to the state
, and
is the number of transitions between
and
. Frequencies (6) are interpreted as probability estimators for transitions between given states, and can in consequence be used in the prediction of future changes. SMBR model for a given instrument in the presented notation can be described by two parameters:
and
m (that is, the discretization unit and the number of ensuing course changes). In further considerations, it will be thus referred to by SMBR(
,
m).
Figure 1 presents an exemplary graph of the change process for the SMBR(25,2) model.
Let us now consider the performance of the SMBR(25,2) model. The state-space consists of four states: , . Each state has two possibilities of transition to the neighboring states: first in case of the course increase and second in case of the decrease. Let us assume, that the market during the i-th change is in the state . If an increase occurs, the next change will be equal to and the model will change its state to . On the other hand, in case of a fall, the process will stay in the state .
Based on historical data analysis, we can assess the probability distribution of transitions between particular states and then the change direction probability distributions (i.e., probabilities for increases and decreases). In the SMBR model, both of those distributions are identical. In
Table 1 we can see quotation results from the 1 January 2014–31 December 2015 time period for the AUD/NZD instrument of SMBR(25;3).
The probability distribution of the future change along with the information about a more probable change direction can stand as a recommendation for concluding transactions and can be presented in form of a prediction table (
Table 2).
Each state model allows for the construction of a prediction table of a structure presented in
Table 2. Based on the prediction table one can construct an HFT system, which would automatize the investment process (
Piasecki and Stasiak 2019,
2020). An example of such a system description will be given in
Section 4.
SMBR model stands as a kind of base state model for binary-temporal representation of an exchange rate trajectory. In the model, only the direction of a fixed number of (m) changes is analysed. This kind of basic information hypothetically allows for a market advantage. The information is taken into account also in more advanced models. Therefore, comparing the results of the simplest model with more advanced ones allows for estimating their effectiveness. However, there is one restriction: the model does not analyze the duration of changes. Other research suggests that time has a significant predictive value.
3.3. Binary-Temporal State Model
An extension of the SMBR model that takes into consideration the duration of a change is called a state model in a binary temporal representation (SMBTR) (
Stasiak 2018). The model assumes that the duration of a change has a significant influence on the probability distribution of the future change direction. This fact can be explained by psychological aspects (e.g., when the increase or decrease lasts for too long, investors start to open opposite positions). Also, the majority of investors make similar decisions based on indices that are calculated for the candlestick representation, and thus including the duration of changes (
Stasiak 2020).
SMBTR model is founded on the binary-temporal representation of exchange rate trajectory changes, given in (2). A state in this model is defined similarly to the SMBR model (that is, based on previous changes (4) and additional information that can be referred from the registration of duration of changes). The parameter of registered durations for given states would have been an intuitive solution, but it would have led to the need of considering even ten thousand different states. Since the number of possible states has to be limited, the author decided to assign each
i-th binary change a parameter
, describing the duration using a threshold method:
In (7) we use threshold
, which enables the distinction of the duration of particular changes. It is easy to note that
describes the elimination of time influence in the model and collapses it to the SMBR model. In the SMBTR model, the course for
N observed changes is given as a sequence of binary pairs
:
It is worth noting that due to the threshold method of calculating duration, , where is given by (2).
The state in the SMBTR model is defined as the set
(
m ∈
N) of ensuing course changes and
(
n ∈
N) of ensuing durations, given in binary values:
Parameter
m, similarly to the SMBR model, describes the number of historical changes, Parameters
m and
n describe the space the space
, where the number of states
k is defined by the number of all (
n + m)—element permutations with repetitions from the 2-element set {0,1}:
The state change in the SMBTR model depends only on the course change of a given discretization unit (). Therefore, in the observation period of N ensuing course changes in the SMBTR model, the trajectory will consist of N − m + 1 ensuing states, analogously to the SMBR model.
Proceeding in the same way as in the SMBR model, based on appropriately defined states, it is possible to construct a change process graph, in which states are represented by vertices, while the edges of the graph define a set of possible transitions between states. SMBTR model can be described by four parameters:
m,
,
and
n, that is the number of ensuing changes, discretization unit, the duration threshold and the number of ensuing durations, respectively. In further considerations, we will refer to it by SMBTR(
,
m,
).
Figure 2 shows an exemplary process graph for the changes in SMBTR(25,2,1,300) model.
Let us follow the performance of the SMBTR(25,2,1,300) model. We assume that the market is in the state {(0,0);1}. If an increase in the course occurs next 52 s (52 < 300), then the market will make a transition to the state {(0,1);0}. On the other hand, if a decrease occurs in next 450 s (450 > 300), then the market will stay in the {(0,0);1} state. Similarly, if next 103 sec a decrease occurs, (103 < 300), the market transitions to {(0,0);0}. Finally, if the rate increases in 512 s (512 > 300), the market reaches {(0,1);1}.
Based on the historical data analysis, we can assess the probability distribution for transitions between states, and next, the probability distribution of change direction (i.e., probability of an increase and a decrease in the quotations), for particular states. Based on the probability distributions, we can assess the probability of a future change direction.
The probability distribution calculated for transitions between states in the SMBTR model is not identical with the probability distribution of changes, similarly to the SMBR model. For each state in the SMBTR model we can distinguish four possible types of changes:
- -
An increase in a time shorter than the threshold value ;
- -
An increase in a time longer than the threshold value ;
- -
A decrease in a time shorter than the threshold value ;
- -
A decrease in a time longer than the threshold value .
Again, similarly to the SMBR model, we can construct a prediction table, based on historical data. The prediction table can next be used to design a proper HFT system.
3.4. State Modelling with the Use of Moving Average
3.4.1. Moving Average in a Binary-Temporal Representation
The moving average is one of the basic parameters of technical analysis, used in the analysis of the course trajectory in candlestick representation. We can distinguish simple moving average (SMA), which is an arithmetic average of the closing prices from
n previous candles, and a group of weighted moving averages (WMA) (
Lim 2015).
Let us consider using moving averages in the analysis of course trajectory given in the binary-temporal representation. In the binary representation, it is not easy to define a simple moving average SMA. To describe an average based on only the size of a change in n periods would lose the information about the order of changes and about the times of their occurrence. Due to this observation, we introduce a so-called “binary average”, which consist in appointing an average from the binary changes expressed by the time parameter.
In the proposed method of calculating the binary average, we transform the notation of a single course change from
to
. In this notation, a decrease is assigned a value (−1), and the increase is assigned a 1. Therefore, for
i-th change, we have:
In the model, we assume that the average will be appointed based on an n-element sequence of ensuing changes. By the symbol
, where
, we denote the sum of durations and first changes of the n-element sequence:
Each change in the considered sequence can be assigned a corresponding weight. Weight of the
i-th change
is defined in the model as the ratio between the duration of first
i changes
, to the duration of all n analyzed changes
:
In the model, we assume that weight increases with the increase of the change index. This means that the newest changes (those closest to
n) have the highest weight. The last,
n-th change has the highest possible weight, which is 1. Now, based on the weights and their normalization to a probabilistic measure we can calculate the binary-weighted average
:
Such construction of the average places the calculated value in the [−1, 1] interval. The inclusion of time in the determining weights for the moving average allows for obtaining better results of course modelling than the threshold time analysis in the binary-temporal model. This is proven by empiric research results performed by the Author, which is partially presented in
Section 5.
3.4.2. State Model for Moving Average in a Binary-Temporal Representation
Let us now consider a model which uses information about the binary average to find the probability distribution (i.e., state model of the binary moving average (SMBMA)). The main idea of this model, as in the classic technical analysis methods, is that the current moving average influences the probability distribution of the future change of direction. The model uses binary-temporal representation given by (2).
A state in the SMBMA model is described analogously as in the SMBR as last m changes (4) and additional information that can be inferred from assigning each change an average value, calculated based on the previous sequence of
n changes. However, using averages given by (15) to describe all binary states would have led to generating a large number of states which would have made the practical applications of the model rather impossible. Therefore, due to the need of limiting the general number of states, each
i-th change is assigned a
parameter, describing the average from
n previous changes.
where
is the assumed discretization threshold for the average. In the SMBMA model, the course for
N observed changes is represented as a sequence of pairs
:
A state in the SMBMA model is defined as the set of m consecutive course changes and average from last n course changes
expressed using a threshold, calculated at the last
m-th change:
where
is described by (16) for
I =
m.
Parameters m and
describe the state space
, where the number of states
k is defined by the multiplication of all m-element permutations with repetitions from the 2-element set {0,1} and a single element from the set {−1,0,1}:
The SMBMA model is defined by four parameters:
,
m,
n and
. In further considerations, it will be therefore referred to as SMBMA (
,
m,
n,
).
Figure 3 presents an exemplary process graph for changes in SMBMA (300,2,4,0.55) model. Since not all of the states can occur (they are dependent on the threshold, etc.) the graph shows only those states, which have occurred at least once.
In the considered model, at each state two last changes are analyzed (m = 2), as well as the binary average, described based on the four last changes (n = 4). If at any state I the average form the last four changes is higher than = 0.55, then . If parameter is smaller than 0.55 and at the same time higher than −0.55, then . However, if the parameter is smaller than −0.55, then . Let us assume that after i-th consecutive change the market finds itself in the state {(0,0);−1}. If in the next change an increase occurs and the average will be equal to = 0.1, then the market will make the transition to the state {(0,1);0}. On the other hand, if in the next change we have an increase but the average equals = 0.57, then the market will go to the state {(0,1);1}.
Based on the historical data and analogously to SMBR and SMBTR models, we can calculate the probability distribution of the transitions between states. Furthermore, based on it we can create a corresponding prediction table that can be further used in the construction of an HFT system.