1 Introduction

High-frequency financial data are observations on financial variables such as quotations of shares, futures, or currency pairs, quoted daily or at a finer timescale. Data containing the most complete knowledge about quotations of the financial instrument are prices corresponding to each single transaction made on this instrument. They are at the same time the data of the highest possible frequency called ultra-high-frequency data or simply tick-by-tick data.

High-frequency financial data possess unique features absent in data measured at lower frequencies, and analysis of these data poses interesting and unique challenges to econometric modeling and statistical analysis [16]. Analysis of tick-by-tick data is very difficult, among others, due to the very large number of observations, irregular spacing between observations, occurrence price patterns, and long-lived dependencies. For various reasons, high-frequency data may contain erroneous observations, data gaps, and even disordered sequences. Moreover, Lo and Mackinlay consider that the financial market is a complex, nonstationary, noisy, chaotic, and dynamic system but it does not follow a random walk [7]. The main reason is that a huge amount of information is reflected in the financial market. The main factors include an economic condition, political situation, traders’ expectations, catastrophes, and other unexpected events. Thus one can conclude that stock market data should be considered in the framework of uncertainties.

Making investment decisions based on observation of each single quotation is very difficult or even impossible. Therefore a large part of investors very often use price chart analysis to make decisions. The price charts (e.g., the Japanese Candlestick chart) are used to illustrate movements in the price of a financial instrument over time. Note that in using the price chart, a large part of the information about the process is lost; for example, using the Japanese Candlestick chart with daily frequency, for one day, we know only four prices (i.e., open, low, high, and close), while in this time the price has changed hundreds of times. In spite of this, Japanese Candlestick charting techniques are very popular among traders and allow for achieving more than average profits. More details about the Japanese Candlesticks and trading techniques based on them can be found in [12].

In our previous papers [8,9,10] we showed how we can use fuzzy logic, that is, Ordered Fuzzy Numbers (OFNs) defined in Chap.  4 (see also [1,2,3, 5, 13, 14]), to model uncertainty associated with financial data and to keep more information about price movement. The idea, construction methods, and an example of an application of ordered Fuzzy Candlesticks are specifically recalled in this work. In addition some new concepts are also presented.

2 Ordered Fuzzy Candlesticks

Generally, in our approach, a fixed time interval of financial high frequency data is identified with Ordered Fuzzy Numbers and it is called ordered Fuzzy Candlestick (OFC). The general idea is presented in Fig. 10.1. Note that the orientation of the OFN shows whether the ordered Fuzzy Candlestick is long or short. Information about movements in the price are contained in the shape of the f and g functions. In this sense, functions f and g do not depend directly on the variable tick but depend on the relationship between the parameters A and B. In the following sections the details of constructing the ordered Fuzzy Candlestick are presented.

Fig. 10.1
figure 1

Draft of general concept of ordered Fuzzy Candlestick

Previous works listed two cases of construction of ordered Fuzzy Candlesticks. The first assumes that the functions f and g are functions of predetermined type; moreover, the shapes of these functions should depend on two parameters (e.g., linear). Then the ordered Fuzzy Candlestick for a given time series can be defined as follows.

Definition 1

Let \(\{X_t:t\in T\}\) be a given time series and \(T = \{1,2,\ldots ,n\}\). The ordered Fuzzy Candlestick is defined as an OFN \(C = (f,g)\) that satisfies the following conditions 1–4 (for a long candlestick) or \(1^\prime \)\(4^\prime \) (for a short candlestick).

1.:

\(X_1\le X_n\).

2.:

\(f:[0,1]\rightarrow \mathbb {R}\) is continuous and increasing on [0, 1].

3.:

\(g:[0,1]\rightarrow \mathbb {R}\) is continuous and decreasing on [0, 1].

4.:

\(S_1 < S_2,\ f(1) = S_1,\ f(0) = \min \limits _{t\in T}X_t -C_1,\ g(1) = S_2\) and g(0) is such that the ratios \(\displaystyle {\frac{F_g}{A}}\) and \(\displaystyle {\frac{F_f}{B}}\) are equal.

\(1^\prime .\) :

\(X_1 > X_n\).

\(2^\prime .\) :

\(f:[0,1]\rightarrow \mathbb {R}\) is continuous and decreasing on [0, 1].

\(3^\prime .\) :

\(g:[0,1]\rightarrow \mathbb {R}\) is continuous and increasing on [0, 1].

\(4^\prime .\) :

\(S_1 < S_2,\ f(1) = S_2,\ f(0) = \max \limits _{t\in T}X_t + C_2,\ g(1) = S_1\) and g(0) is such that the ratios \(\displaystyle {\frac{F_f}{A}}\) and \(\displaystyle {\frac{F_g}{B}}\) are equal.

In the above conditions the ordered Fuzzy Candlestick center (i.e., added interval) is designated by parameters \(S_1,\,S_2\in \left[ \min _{t\in T}{X_t}, \max _{t\in T}{X_t} \right] \) and can be computed as different kinds of averages (e.g., arithmetic, weighted, or exponential). \(C_1\) and \(C_2\) are arbitrary nonnegative real numbers that further extend the support of fuzzy numbers and can be computed, for example, as the standard deviation or volatility of \(X_t\). The parameters A and B are positive real numbers that determine the relationship between the functions f and g. They can be calculated as the mass of the desired area with the assumed density (see Fig. 10.1). Numbers \(F_f\) and \(F_g\) are the fields under the graph of functions \(f^{-1}\) and \(g^{-1}\), respectively.

Example 1

Trapezoid OFC

Suppose that f and g are linear functions in the form:

$$\begin{aligned} f(x)=\left( b_f-a_f\right) x+a_f\quad \text{ and } \quad g(x)=\left( b_g-a_g\right) x+a_g \end{aligned}$$
(10.1)

then the ordered Fuzzy Candlestick \(C = (f,g)\) is called a trapezoid OFC, especially if \(S_1 = S_2\) where it can also be called a triangular OFC.

Example 2

Gaussian OFC

The ordered Fuzzy Candlestick \(C = (f,g)\) where the membership relation has a shape similar to the Gaussian function is called a Gaussian OFC. It means that f and g are given by functions:

$$\begin{aligned} f(x)=f(z)=\sigma _f\sqrt{-2\ln (z)}+m_f\quad \text{ and }\quad g(x)=g(z)=\sigma _g\sqrt{-2\ln (z)}+m_g \end{aligned}$$
(10.2)

where, for example, \(z = 0.99x + 0.01\).

The procedure of determining the parameters of the function f and g is shown in Algorithm 1 and the examples of realizations of trapezoid and Gaussian ordered Fuzzy Candlesticks are presented in Fig. 10.2.

figure a
Fig. 10.2
figure 2

Examples of trapezoid and Gaussian OFC

The second case of construction of ordered Fuzzy Candlesticks assumes that the functions f and g are defined in a similar way to the empirical distribution in the statistical sciences and called an empirical OFC. The calculation procedure of an empirical OFC is shown in Algorithm 2, whereas the example of realizations is presented in Fig. 10.3.

figure b
Fig. 10.3
figure 3

Example of empirical OFC

3 Volume and Spread

3.1 Volume

In technical analysis the prices are by far the most important. However, another piece of important information about price movement is volume. Volume is the number of entities traded during the time period under study. It is used to confirm trends and chart patterns. Any price movement up or down with relatively high volume is seen as a stronger, more relevant move than a similar move with weak volume [11].

In the case of ordered Fuzzy Candlesticks, adding extra information about volume is very easy, enough to calculate the parameters A and B using the density associated with volume or for empirical OFC, and enough to calculate the empirical distribution using prices repeated by volume times. The example of ordered Fuzzy Candlesticks without and with volume information are presented in Fig. 10.4.

Fig. 10.4
figure 4

Example of Gaussian OFC without and with volume information

3.2 Spread

A spread (bid-ask spread) is simply defined as the price difference between the highest price that a buyer is willing to pay (bid price) for an asset and the lowest price that a seller is willing to accept to sell it (ask price). It is important to remember that spreads are variable, meaning they will not always remain the same and will change sporadically. These changes are based on liquidity, which may differ based on market conditions and upcoming economic data. In an over-the-counter market, dealers act as market makers by quoting prices at which they will buy and sell a security or currency. In this case, the spread represents the potential profit that the market maker can make from this activity, and it’s meant to compensate it for the risk of market making. On the other hand, it is a cost for traders.

In the case of ordered Fuzzy Candlesticks, it is possible to add extra information about the bid-ask spread by calculating the parameters \(S_1\), \(C_1\) and \(S_2\), \(C_2\), using the bid price and ask price, respectively. The examples of ordered Fuzzy Candlesticks without and with spread information are presented in Fig. 10.5.

Fig. 10.5
figure 5

Example of Gaussian OFC without and with spread information

4 Ordered Fuzzy Candlesticks in Technical Analysis

4.1 Ordered Fuzzy Technical Analysis Indicators

Ordered Fuzzy Candlesticks are Ordered Fuzzy Numbers, hence, thanks to their well-defined arithmetic [1, 4, 13] can be used to construct a fuzzy version of technical analysis indicators such as the simple moving average.

The classical simple moving average (SMA) with order s at a time period t is given by formula

$$\begin{aligned} SMA_t(s)=\frac{1}{s}\left( X_t+X_{t-1}+\cdots +X_{t-s+1}\right) \end{aligned}$$
(10.3)

where \(X_t\) is the observation (real) at a time period t (e.g., closing prices).

Now, the ordered fuzzy simple moving average (OFSMA) with order s at a time period t is also given by formula (10.3) but the observations \(X_t\) are OFC at a time period t. Figure 10.6 shows the results of realization of classical (line with xcross symbol) and ordered fuzzy (triangle symbols) simple moving average with order equal to 14 for the dataset covering the period of 80 days from 02-03-2016 till 02-06-2016 of quotations of EUR/PLN. Figure 10.6 also shows the ordered fuzzy simple moving average defuzzification by the center of gravity operator (line with circle symbol). In technical analysis the moving average indicator usually is used to define the current trend. Notice that the ordered fuzzy moving average determines the current trend by orientation of the ordered Fuzzy Candlesticks: if orientation is positive then then the trend is long, else the trend is short. The process of fuzzification of the other technical indicators can be done by analogy.

Fig. 10.6
figure 6

The daily Japanese Candlestick chart of the dataset with realization of a classical and ordered fuzzy simple moving average

4.2 Ordered Fuzzy Candlestick as Technical Analysis Indicator

The method of construction of ordered Fuzzy Candlesticks can be used directly as a technical analysis indicator by doing the calculation of OFC over a moving window of observations (ticks). The size of the window can be defined as the number of observations (e.g., last 100 ticks) or the time (e.g., last 10 min). Figure 10.7 shows the results of realization of empirical ordered Fuzzy Candlesticks as a technical indicator with window size equal to 15 min for the dataset covering the period of 1 hour from 3 PM till 4 PM of 02-06-2016 of quotations of EUR/PLN.

Fig. 10.7
figure 7

Empirical ordered Fuzzy Candlesticks as technical indicator

Indicators are used as a secondary measure to the actual price movements and add additional information to the analysis of securities. Indicators are used in two main ways: to confirm price movement and the quality of chart patterns, and to form buy and sell signals. The most common type of indicators is called oscillators and they fall in a bounded range. Oscillator indicators have a range, for example, between zero and 100, and signal periods where the security is overbought (near 100) or oversold (near zero). In a simple way the indicator based on ordered Fuzzy Candlesticks can be presented in the form of an oscillator by applying normalization. An example of empirical ordered Fuzzy Candlesticks as an oscillator indicator is presented in Fig. 10.8.

Fig. 10.8
figure 8

Empirical ordered Fuzzy Candlesticks as oscillator indicator

5 Ordered Fuzzy Time Series Models

Thanks to the well-defined arithmetic of OFNs, it is possible to construct models of fuzzy time series, such as an autoregressive process (AR), where all input values are OFC, and the coefficients and output values are arbitrary OFNs, in the form of classical equations, without using rule-based systems.

The classical autoregressive model \((\text {AR}(p))\) is one where the current value of a variable, depends only upon the values that the variable took in previous periods plus an error term [15]. In the presented approach, an ordered fuzzy autoregressive model of order p, denoted \(\text {OFAR}(p)\), in a natural way is fully fuzzy \(\text {AR}(p)\) and can be expressed as

$$\begin{aligned} \overline{X}_t=\overline{\alpha }_0+\sum \limits _{i=1}^p\overline{\alpha }_i\overline{X}_{t-i}+\overline{\varepsilon }_t \end{aligned}$$
(10.4)

where \(\overline{X}_{t - i}\) are the ordered Fuzzy Candlesticks at a time period t, \(\overline{\alpha }_i\) are fuzzy coefficients given by arbitrary OFNs, and \(\overline{\varepsilon }_t\) is an error term.

Estimation of OFAR(p) Model

The least squares method is proposed for the estimation of fuzzy parameters \(\overline{\alpha }_i = (f_{\alpha _i},g_{\alpha _i})\) in the \(\text {OFAR}(p)\) model and one is defined using a distance measure. The measure of the distance between two OFNs is expressed by the formula:

$$\begin{aligned} \text{ d }(A,B)=\text{ d }\left( (f_A,g_A),(f_B,g_B)\right) =\Vert f_A-f_B\Vert _{L^2}+\Vert g_A-g_B\Vert _{L^2} \end{aligned}$$
(10.5)

where \(\Vert \,\cdot \,\Vert \) is a metric induced by the \(L^2\)-norm. Hence, the least squares method for \(\text {OFAR}(p)\) is to minimize the following objective function,

$$\begin{aligned} E=\sum \limits _t\text{ d }\left( \overline{X}_t,\overline{\alpha }_0+\sum \limits _{i=1}^p\overline{\alpha }_i\overline{X}_{t-i}\right) \end{aligned}$$
(10.6)

Forecasting Using the OFAR(p) Model

Forecasts of the \(\text {OFAR}(p)\) model are obtained recursively in a similar way as for the classical \(\text {AR}(p)\) model. Let t be the starting point for forecasting. Then, the one-step-ahead forecast for \(\overline{X}_{t+1}\) is

$$\begin{aligned} \hat{\overline{X}}_{t+1}=\overline{\alpha }_0+\sum \limits _{i=1}^p\overline{\alpha }_i\overline{X}_{t+1-i}. \end{aligned}$$
(10.7)

The result of the forecast is an Ordered Fuzzy Number, which includes three kinds of predictions:

  • Point forecast: Given by the value of a defuzzification operator (for defuzzification operators see [2, 6])

  • Interval forecast: Given by the subset of support of the OFN in its classical meaning

  • Direction forecast: Given by orientation of the OFN.

6 Conclusion and Future Works

In this chapter, the representation of financial data using the concept of the ordered Fuzzy Candlestick is described. The ordered Fuzzy Candlestick holds more information about the prices than the classical Japanese Candlestick. Moreover, it is also possible to include information about the volume and spread. Based on well-defined arithmetic of Ordered Fuzzy Numbers, the proposed approach enables us to build the technical analysis indicators and the fuzzy financial time series models in the simple form of classical equations. It allows reducing the size of models compared to models based on fuzzy-rule-based systems. For future work, our approach can be extended by adding the concept of fuzzy random variables, which can allow for the simulation of models and their application in many other areas of financial engineering.