A pattern recognition algorithm 255
two different periods. Therefore, our algorithm takes the pattern number for eachith
cutoff value and it computes
di,j=
∣
∣
∣n
j
1 ,i−n
j
2 ,i
∣
∣
∣,i=^1 ,^2 ,...,^18 , (1)
wheredi,jis the absolute value of the difference between the number ofj-type chart
patterns of the period 1 and that of period 2, for each cutoff value. So, we are able to
define the similarity coefficientSjas
Sj=
⎧
⎪⎨
⎪⎩
∑ncj
i= 1
1
2 di,j
ncj
,ncj≥ 1
0 , ncj= 0.
(2)
The similarity coefficient assumes values that lie between 0 and 1 andncjis the
number of possible comparisons. At this step, our algorithm gives ten similarity coef-
ficients connected to the ten technical patterns named above. The next step consists of
computing a single value that gives informational content on the similarity between
the periods. We refer to this value as Global Similarity (GS) and we define it as a
weighted average
GS=
∑^10
j= 1
wjSj. (3)
The weightswjare defined as the ratio between the comparisons number of thejth
pattern and the sum of comparisons numberntof all patterns (see formula 4).
wj=
ncj
nt
,nt=nc 1 +nc 2 +...+nc 10 (4)
∑^10
j= 1
wj= 1. (5)
Moreover, the sum of weightswj, withjfrom 0 to 10, is equal to 1 (see formula 5).
Computing the global similarity GS through the (3), we assign more weight to the
similarity coefficients with greater comparisons number.
The next step is related to the choice of time period amplitude for training and
trading phases. For the trading set, we consider the time series of a certain year.
Therefore, we consider the exchange rates that start from the end of the time series
until the six preceding months. In this manner, we obtain a semester in the year
considered. Subsequently, we create the second semester, starting from the end of the
year minus a month, until the six preceding months. Thus, we obtain a certain number
of semesters. Therefore, we compare these trading semesters with various semesters
of the previous years. Subsequently, a selection of training and trading semesters pairs
is accomplished, splitting the pairs with positive slopes and those with negative slopes.
So, we compute the profits^1 of the trading semesters by considering the optimised
(^1) To compute the profits, we use the DMAC filter rule [32].