<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Search for optimization of a real-time neural trading system</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Michal Pobucký</string-name>
          <email>michal.pobucky@fpf.slu.cz</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>The Institute of Computer Science, Silesian University in Opava</institution>
          ,
          <country country="CZ">Czech Republic</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>We describe the development of a complex modular system that should be able to predict the movement of the currency market (FOREX) using real-time neural networks and then automatically issue instructions for buying or selling individual currencies. To access the currency market, we use the free MetaTrader 5 application, which is linked to the Thisifi Trading Terminal (TTT) application that we created. TTT first reads the data needed for network training and then selects the training sets. The samples serve as input for training the neural network. Once the network is trained, the user can switch to online mode, where the network responds in real time to a change in the currency market and passes to MetaTrader instructions for the transaction.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Business trading tools aided with artificial intelligence
methods, and artificial neural networks in particular, are
a frequent research topic. We aim at a development of a
a complex modular trading system which shoudl be fully
autonomous. The article focuses on the development of
that part of the system that should be able to trade
automatically on the currency market - FOREX. We
experiment with trading strategies using multilayer perceptrons
with the Backpropagation training and we present results
of this initial study. While this network model is standard,
the novelty of our approach lies in the composition of the
training dataset. Future extensions of our trading system
are described in Conclusions. The reader is referred to [
        <xref ref-type="bibr" rid="ref20">20</xref>
        ]
for a more detailed description of our trading system.
      </p>
      <p>
        The strategy of the trading system should not be based
on the fact that based on the input data we will predict the
exact movement of the price by the predicted value, such
as [
        <xref ref-type="bibr" rid="ref27">27</xref>
        ], where the input of the neural network is the set
of last 25 High or Low values. Currently, currency
market traders perform either fundamental or technical
analysis. The vast majority of them use technical analysis based
on a specific set of mathematical tools – indicators. Each
broker uses an application that displays a graph on which
the broker sees the current price of a currency pair and its
movement up or down. The broker can also add indicators
to this basic chart, which can indicate whether the price
will rise or fall, and tries to predict future movement of
the market on the basis of his experience and knowledge
of individual indicators. Various analytical tools and the
choice of right methods can reduce the effect of errors and
also increase profitability [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ][
        <xref ref-type="bibr" rid="ref17">17</xref>
        ].
      </p>
      <p>
        With the help of the MetaTrader application, we gain
access to the online trading system on currency markets.
First, we programmed an automatic expert system, the
so-called ExpertAdvisor, which obtains the values of
individual indicators from the market and stores them in a
database. We programmed this automaton in a special
language MQL. This ExpertAdvisor stores all types of
indicators, i.e. trend indicators [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ], [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ], [
        <xref ref-type="bibr" rid="ref25">25</xref>
        ], [
        <xref ref-type="bibr" rid="ref26">26</xref>
        ],
oscillators [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ], [
        <xref ref-type="bibr" rid="ref18">18</xref>
        ], [
        <xref ref-type="bibr" rid="ref22">22</xref>
        ], [
        <xref ref-type="bibr" rid="ref28">28</xref>
        ], volume
indicators [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ], [
        <xref ref-type="bibr" rid="ref24">24</xref>
        ] and Bill Williams indicators [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ], [
        <xref ref-type="bibr" rid="ref21">21</xref>
        ].
      </p>
      <p>
        The values of individual indicators are sent to the
input of the neural network - indicators that take the values
1 (buy), -1 (sell) or 0 (no instruction). The broker, as a
human person, himself evaluates the information from
individual indicators and, based on his own experience,
subsequently instructs the currency market. At this stage, our
trading system will evaluate the values of the indicators,
not the actual price position in the market. This procedure
is different from previous research. For instance, [
        <xref ref-type="bibr" rid="ref29">29</xref>
        ]
focuses on eight indicators, four of which are simple
moving averages and four are exponential. [
        <xref ref-type="bibr" rid="ref30">30</xref>
        ] used LSTM
model with 11 indicators, [
        <xref ref-type="bibr" rid="ref23">23</xref>
        ] then gives an overview of
the neural networks that were used for prediction on
financial time series and indicators are represented here rather
marginally. So far, the research has not focused on a
training set comprising several hundred market indicators.
      </p>
      <p>
        We trade on the currency pair EUR/USD, because it has
the greatest volatility. Trading is minute by minute, so
we work with minute charts and data. Other authors use
also 1-hour time frequencies [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ], daily and monthly
frequencies [
        <xref ref-type="bibr" rid="ref11">11</xref>
        ]. All fees (broker AdmiralMarkets),
including slippage, are already included in the profit of
individual trades, so the net financial profit is really the profit that
comes to the client’s account. The lot size is set to 0.1.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Network settings</title>
      <p>
        We used a classical multilayer perceptron with the
Backpropagation training [
        <xref ref-type="bibr" rid="ref12">12</xref>
        ] based on gradient descent
method [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ], while the activation function is similar to a
hyperbolic tangent of the form:
f (x) = p
      </p>
      <p>x
1 + x2
and its derivation is
f 0(x) =
(1 + x2) 23</p>
      <p>Within each adaptation cycle we check whether the
network has already been trained by at least 95% of samples.
When this threshold is reached, we let the unlearned
samples be trained more often and regularly by a special rule,
to ensure that the network learns the whole training set.</p>
      <p>For the gradual evaluation of the found patterns, we had
to define the scope of individual business instructions. For
each time T0, the price movement at time T1 to T10 is
evaluated, and based on the size of the movement, it is assigned
to one of the categories. By optimizing the network
topology, the output layer is extended to 15 neurons, three of
which are Buy, Sell and Zero, the others are auxiliary (4th
to 15th). If the maximum price value in period hT1; T10i is
within 0.00005, it is neither an increasing nor a
decreasing trend. The price is holding almost unchanged and it is
a signal called Zero. On the other hand, everything that is
at least 0:00140 from the original value is the Buy signal
and everything that is at least 0:00140 from the original
value is then the Sell signal. See Table 1 for an overview.
The autonomous trading system consists of four separate
neural networks, which were trained separately on their
own data sets. Depending on the user settings, it is
possible to specify in more detail how these networks will
cooperate with each other. At the same time, general conditions
for trading on the currency market can be set. We will
compare results of trading systems with various settings
in the tables that follow. Setting of the trading system is
denoted by numbers and letters as follow.</p>
      <p>The numerals 2, 3 and 4 denote a trading system where
2, 3 or 4 neural networks were required to issue an order
to buy or sell.</p>
      <p>Letter K means correction. This makes it possible to
eliminate situations where neural networks generate, for
example, a Buy signal and at least one network generates a
Sell, then the output of the trading system will be the value
991 and not Buy. Similarly, if the networks generate a Sell
signal and at least one network indicates a Buy signal, the
system result will be 992 and not Sell.</p>
      <p>The letter M indicates that we will only accept buy or
sell signals if the same signal was generated in the
previous time period. This means at least two identical
instructions in a row.</p>
      <p>The letter N indicates that we will not trade at night
between 22:00 and 06:00. During this period, trades are the
lowest and at the same time the most unusual signals
appear here.
3.2</p>
      <sec id="sec-2-1">
        <title>Changes in network topology</title>
        <p>The search for the optimal network began with four
indicators in the input layer, one output neuron and one or two
hidden layers. The maximum allowed error is set to 0.1
(Buy will be detected in the range from 1 to 0.9 and Zero
in the range from -1 to -0.9.), the total number of cycles
to 100,000, with one cycle making 100 random selections
from the training data set. Data was used from one trading
day. None of the tested networks achieved 100% success,
so none of the networks fully adapted to the training data.
Similar results were obtained when expanding the number
of indicators to 7 and 13.</p>
        <p>When the input layer expands range from 14 to 26
neurons, some of the four networks gradually adapt. While in
networks with 14 and 15 inputs only two out of four were
successful, after 25 thousand to 50 thousand cycles, for
example ad for 21 inputs is already enough 4 to 20 thousand
cycles and in 26 input neurons all networks have already
fully adapted and with one exception, 3 to 7 thousand
cycles were enough. It was similar to up to 40 indicators in
the input layer.</p>
        <p>We tested a larger range of the input layer and
programmed 151 indicators that will be on the input. The
network topology is now 151 – X – 1, X 2 h10; 63i, maximum
allowed error at 0.25, total number of cycles 300,000, 146
training samples from 3 trading days. From 16 neurons in
the inner layer, the networks are capable of full adaptation
and 40 to 50 thousand iterations are needed. When the
training set is extended to 5 trading days and 187 training
samples, the error increases and none of the tested
networks is able to fully adapt.</p>
        <p>We programmed the maximum of indicators and sent
them to the input layer, which has now expanded to 236
neurons. We also test in parallel on 1,180 input
neurons, where information from five consecutive bars is
input within one data set, with a clear tendency to
overfitting. Neural networks show similar results of adaptation,
with the topology 1,180 – X – 1 being able to learn the
same percentage of training samples in the previous cycle.
From 110 to 130 neurons in the inner layer, we get to a
network success of about 80%, slightly increasing from 240
neurons onwards.</p>
        <p>Adaptation on 537 training samples shows a success
rate in the range of 61 to 63% in the 236 – X – 1
network, from the 110th internal neuron to 280. In the 1,180
– X – 1 network, in the range of 67 to 73%, from 210
internal neuron after 320. The average error is then in the
range of 0.46 to 0.51 for the 236 – X – 1 topology and
in the range of 0.30 to 0.44 for the 1,180 – X – 1
topology, which means that we already have about twice the
average error of networks. These results indicate that the
constant increase in the training set is already becoming
counterproductive and the reliability of the trained neural
network is declining. Therefore, next we examined the
effect of changes in the initialization of the weights and the
changes of the training rate coefficient a on the quality of
results.</p>
        <p>
          We generated various hidden layer sizes and initial
weight settings. The best variant had 240 neurons in the
hidden layer and the initial value of the weights and bias
is in the range from h 1.0; 1.0i to h 2.0; 2.0i.
Subsequently, adaptation testing with a different magnitude of
the a coefficient was performed, as well as was sent to
the input layer from one to seven bars, so that the input
layer was large from 236 to 1,652 neurons. The most
important aspect of adapting these networks is that none of
these twenty networks was able to fully learn the complete
training set, so even resetting the input layer range, inner
layer, initializing weights and biases or training coefficient
did not lead to the goal. The best setting for the a training
coefficient is 0.001, unlike for example [
          <xref ref-type="bibr" rid="ref15">15</xref>
          ], where it is
0.05.
3.3
        </p>
      </sec>
      <sec id="sec-2-2">
        <title>Optimization of complex network activation</title>
        <p>The optimization will now take place in terms of the width
of the neural network output layer. We expanded the
output layer from one output neuron, which recognizes three
output values to a set of three neurons, with the first
neuron, when excited, indicates the Buy signal, the second
neuron the Zero signal, and the third neuron the Sell signal.
We also standardized the training set to 637 samples, with
Buy signals 207, Zero signals 209 and Sell signals 221.</p>
        <p>The search for the optimal topology was performed on
X – 240 – 3 networks, with the number of bars ranging
from three to seven, so that the size of the input layer
was 708, 944, 1,180, 1,416 and 1,652 neurons. There are
two conclusions – all networks have learned to recognize
a complete set of training samples, and less than 5,000
repetitions, in some cases even less than 3,000 repetitions,
were almost always enough for the learning itself.</p>
        <p>Topology 708 – 240 – 3, after activating a complex
test data set that contained 14,382 samples, we received
instead of 207 Buy signals 3,177 to 3,369 signals (on
four separate neural networks), instead of 221 Sell
signals 3,077 to 3,564 signals and instead of 209 Zero signals
2,163 to 2,468 signals. Thus, instead of 637 recognized
signals, the networks generated 8,798 to 8,928 signals.</p>
        <p>Topology 708 – 240 – 4, we decided to add another
neuron to the output layer, which will be evaluated in all other
cases where the samples will not be evaluated as Buy, Sell
or Zero. Within the training set, two cases were tested –
either 100 or 200 samples for the 4th neuron. The training
set contains 737 and 837 samples.</p>
        <p>A neural network with four neurons in the output layer
has significantly better results, as we can see in Table 2.
False signals (The neural network misinterpreted the Buy
or Sell signal and there would be a financial loss in real
trading.) for Buy fell by 36%, in the variant with 200
training samples even by 42 to 46%. There was a
similar decrease in false signals for both Zero (by 28 to 30%
and 42 to 44%, respectively) and Sell (by 32 to 36% and
40 to 46%, respectively). By creating the 4th neuron, we
eliminated more than 2,000 erroneously detected signals,
and even by simply increasing the set of training samples
from 100 to 200 for the 4th neuron, we moved the nearly
a thousand misrecognized samples that were divided
between Buy, Zero, and Sell to the 4th neuron category.</p>
        <p>Net 1
1
-01
4th sig.</p>
        <p>Total
Net 3
1
-01
4th sig.</p>
        <p>Total
3N
3,369
2,352
38,,07-7978
3N
3,201
2,163
38,,59-6248
4N 100
2,125
1,574
2,257
784
6,740
4N 100
2,070
1,557
2,101
793
6,521
4N 200
1,812
1,328
1,897
1,667
6,704
4N 200
1,743
1,237
1,860
1,858
6,698</p>
        <p>Net 2
1
-01
4th sig.</p>
        <p>Total
Net 4
1
-01
4th sig.</p>
        <p>Total
3N
3,230
2,290
38,,38-2444
3N
3,177
2,468
38,,28-2605
4N 100
2,147
1,612
2,074
690
6,523
4N 100
2,023
1,716
2,071
687
6,497
4N 200
1,942
1,287
1,851
1,499
6,579
4N 200
1,709
1,372
1,825
1,549
6,455</p>
        <p>Topology 708 – 240 – 6, the training set contains 937
and 1,237 samples (for 100 and 200 samples on the 4th to
6th neurons). The neural network again has significantly
better results, finding the Buy signal in 1,472 to 1,778
cases, and for the 200 variant in 1,067 to 1,117 cases. This
is an improvement of 17-27% (respectively 37-42%) in
removing Buy, Sell and Zero spurious signals over the four
neurons in the output layer. The overall improvement over
the three neurons in the output layer is then 47-53%
(respectively 66%).</p>
        <p>There has been a change in the ratio between the signals
we require and the auxiliary signals (4th to 6th neurons).
For networks with four neurons in the output layer, the
ratio of generated signals was only 11% in favor of auxiliary
neurons (738.5 out of 6,570.25) and 24% (1,643.25 out
of 6,609), respectively, while for neural networks with six
output neurons, this ratio is already 25% (1607.75 out of
6328.75) and 47% (2906.5 out of 6102.25), respectively.
This condition is desirable because the adaptation of the
network to Buy, Zero and Sell signals is being refined.</p>
        <p>The adaptation rate with 708 neurons in the input layer
begins to reach 9,384 to 9,911 cycles in 1,237 training
samples, so an additional input bar was added and the
topology was changed to 1,180 – 240 – 6, where the
adaptation rate is only 1,887 to 2,300 cycles.</p>
        <p>Topology 1,180 – 240 – 7, the training set contains
1,437 samples (200 samples on the 4th to 7th neurons),
the testing set contains 14,375 samples as usual. The 7th
neuron was created by dividing the 4th neuron, so that only
one new neuron was added to the network topology in the
output layer, so it is not surprising that the improvement
in network results is not so great. The improvement for
Buy reaches a maximum of 5%, for Zero 10% and for Sell
15%.</p>
        <p>Topology 1,652 – 240 – 9, the training set contains
1,837 samples. The improvement for Buy is 31-32%, for
Zero 26-30% and for Sell 32-34%. The total number of
identified signals then dropped below six thousand in three
cases out of four for the first time and remained in the
range from 5,894 to 6,008. The ratio of generated signals
is now 66% in favor of auxiliary neurons (3,946.25 out of
5,954).</p>
        <p>Topology 2,124 – 240 – 15 and topology 2,360 – 240 –
15, the training set contains 3,067 samples. We decided to
add more output neurons at once – a total of 15, as shown
in Table 1. The adaptation rate was 610 to 800 cycles and
560 to 880 cycles, respectively, indicating that it
deteriorated in some cases. We got to the edge of the suitability
of the topology, and therefore we chose the better one for
further optimization, i.e. the topology 2,124 – 240 – 15
with nine bars at the input. In terms of improving the
network’s results, we found that there was an improvement
again, but it is no longer a leap. With each increasing
neuron in the output layer, the network adaptation results will
improve, however, this improvement will be smaller and
smaller. That’s why we decided to change our
optimization strategy.
3.4</p>
      </sec>
      <sec id="sec-2-3">
        <title>Business system optimization</title>
        <p>
          We decided to perform a simulation on a time series and
observe what results of adaptation and complex activation
we will get. We will now optimize the entire trading
system based on 4 separate neural networks. The division of
the training and test set is in a certain ratio (for example,
[
          <xref ref-type="bibr" rid="ref15">15</xref>
          ] uses 70:30), we use a floating layout, where the
training set includes data with a minimum size of two weeks, a
maximum of eight and test data are always from one week.
The training set is generated by an automaton, which
gradually goes through the historical data after a minute, and
assigns them the corresponding values of the output signal.
Two-week data Training set: 2,543 samples (October 1 –
14, 2018), Buy 208 times, Zero 56 times, Sell 115 times,
duration: 503 - 702 cycles, test set: 14,371 data. As we
can see in table 3, all trading systems show a weekly profit,
the best ones almost $ 900. The individual settings of
trading systems are based on the names from the chapter 3.1.
The best weekly earnings results are highlighted in bold.
Strikethrough are settings that show worse or similar
results than their previous variation. We will no longer count
on these settings. The underlined value of gross loss
signals an excellent ratio of gross profit versus gross loss.
        </p>
        <p>In the figure 1 we see the balance on the trading account
of The Two system with a correction.
The validation of trading systems was performed on
new data from the period from 15 to 21 October of the
same year. The success of a data set that the network has
never dealt with is significantly lower, and neither setting
generates any gain but loss, as we can see in table 4.
Although the network is able to predict movements in the
currency market, it has not been able to generalize
training to data that was not part of the training set.
Three-week data Training set: 2,888 samples
(September 24 to October 14, 2018), Buy 299 times, Zero 72 times,
Sell 229 times, duration: 1,116 - 1,316 cycles, test set:
21,565 data. The maximum weekly profit is around $ 600
to $ 700, see table 5. None of the settings used reached
the same ratio between gross profit and gross loss as in
the two-week data. For two-week data, this ratio was even
equal to 55.37, for three-week data it ranges from 3 to 5.</p>
        <p>Settings
4
3
22K
3M
3N
2N
2KM
2KN
2MN</p>
        <p>The validation of trading systems was performed on
new data from the period from 15 to 21 October of the
same year. Setting 4 is profitable, however $ 10.69 per
week is not a successful strategy. If we look at the
profitability of trades by hour, then it is clear that this setting
has the largest losses during the night hours. The 3M setup
is also profitable, however, only 11 transactions per week
and a net profit of less than $ 30 is still low. There was
an increase in the number of transactions for all trading
systems, ranging from 1.76 times to 3.66 times, compared
to trading systems with a two-week set of training data.
There was an increase in net profit for the 4, 3M, 3N,
2KM and 2MN settings, gross profit for all settings and
gross loss for all but 3M, where the gross loss decreased
from $ 5.80 to $ 1.50. See table 6.</p>
        <p>Because the adaptation on all neural networks took
more than two days, we decided to shorten the training
data set, where in addition to the Buy, Sell and Zero
signals, the signals of the 10th and 15th neurons remain,
which are in the immediate vicinity of the Buy and Sell
signals.</p>
        <p>Three-week data truncated Training set: 888 samples
(September 24 to October 14, 2018), Buy 299 times, Zero
72 times, Sell 229 times, duration: 106 - 151 cycles, test
set: 21,565 data. The results of the three-week truncated
data set are remarkable, see table 7. The maximum weekly
profit is around $ 700 to $ 820, which is an improvement
over the full data set by more than $ 100. The number of
transactions increased rapidly from a maximum of 1,600
to 1,700 to 7,000 and 9,000.</p>
        <p>Although the results of the trading system are very
satisfactory within the training period, the validation on the
new week from 15 to 21 October of the same year proves
the exact opposite. None of the tested trading systems
shows a net profit.
Four-week data truncated Training set: 1,179 samples
(September 17 to October 14, 2018), Buy 381 times, Zero
95 times, Sell 313 times, duration: 184 - 197 cycles, test
set: 28,758 data. Validation performed for a week from
15 to 21 October. Only one setting shows a net profit, the
number of transactions has increased almost everywhere.
See Table 8 for emergence of several categories:
1. improvement of net profit, increase of gross profit and
decrease of gross loss
2. improvement of net profit, improvement of gross
profit, but also increase of gross loss
3. a decrease in net profit, but at the same time there
was an increase in gross profit, which increase is a
percentage higher than the increase in gross loss
4. a decrease in net profit, but at the same time there was
an increase in gross profit, which increase is already
a percentage lower than the increase in gross loss
5. increase net loss, decrease gross profit and increase
gross loss</p>
        <p>Trading system Three falls into the best categories, i.e.
1st and 2nd, trading system Two then into the worst
categories, i.e. 4th and 5th. The course of validation of the
3KMN trading system and the amount of the balance on
the trading account can be seen in the figure 3.
Settings
4
33K
3M
2M
3N
2N
3KM
2KM
3KN
2KN
3MN
2MN
3KMN
2KMN
Five-week data truncated Training set: 1,386 samples
(September 10 to October 14, 2018), Buy 464 times, Zero
121 times, Sell 401 times, duration: 253 - 283 cycles, test
set: 35,951 data. Validation performed for a week from 15
to 21 October. As we can see in table 9, no setting shows
a net gain. There has been an increase in transactions
everywhere. Again, there was a division into five categories:
Settings
4
4
33K
3M
2M
3N
2N
3KM
2KM
3KN
2KN
3MN
2MN
3KMN
2KMN
1. improvement of net profit, increase of gross profit and
decrease of gross loss
2. improvement of net profit, improvement of gross
profit, but also increase of gross loss
3. a decrease in net profit, but at the same time there
was an increase in gross profit, which increase is a
percentage higher than the increase in gross loss
4. a decrease in net profit, but at the same time there was
an increase in gross profit, which increase is already
a percentage lower than the increase in gross loss
5. increase net loss, decrease gross profit and increase
gross loss</p>
        <p>The best and worst trading systems have been reversed,
with the Three no longer the best, but falling into the 4th
and 5th categories. In contrast, the trading system Two
shows the best results - it moved to the 1st and 2nd
category.</p>
        <p>Based on these results, we conclude that the adaptation
of neural networks did not generalize in such a way as to
create a self-sufficient business system. We will now test
this hypothesis on an eight-week data set.</p>
        <p>Eight-week data truncated Training set: 1,988 samples
(August 20 to October 14, 2018), Buy 751 times, Zero 185
times, Sell 652 times, duration: 750 - 903 cycles, test set:
57,538 data. Validation performed for a week from 15 to
21 October. As we can see in Table 10, all tested
trading systems show worse results with an eight-week set of
training data than with a five-week or four-week set. We
therefore confirmed our hypothesis that the neural network
did not generalize sufficiently.</p>
        <p>Settings
4
3
3K
3M
2M
3N
2N
3KM
2KM
3KN
2KN
3MN
2MN
3KMN
2KMN</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>The best setting for the trading system</title>
      <p>As part of the search for the ideal trading system, we found
only one that was able to generate a net profit even on
unadapted data. It was a 3KMN system with a four-week
truncated data set – graphs in figures 4 and 5. It reported a
net weekly profit of $ 6.70 for the new week. In contrast, it
generates a net profit of $ 1,660.50 on the learned dataset,
which is a weekly average of $ 415.12. The weekly
number of transactions is 218 in the first case and 216.75 in the
second.</p>
      <p>The second best system was 3MN also on the four-week
data set (graphs in figures 4 and 5), which generated a net
loss of $ -44.80 on the new week and then reported a net
gain of $ 1,724.80 on the learned data set, the weekly
average then $ 431.20. The weekly number of transactions
is 236 in the first case and 242.5 in the second.</p>
      <p>The third best trading system was the 3KMN variant on
the five-week dataset (graphs in figures 8 and 9), which
reported a net profit of $ -83.40 on the new week, with a
net profit of $ 1,910.80 and a weekly average of $ 382.16
on the adapted dataset. The weekly number of transactions
is 259 in the first case and 266.8 in the second.</p>
      <p>There is a clear difference between the application of
the trading system on adapted and non-adapted data. It is
obvious that the neural network could not be generalized
enough to be able to generate profit even on unknown data.
5</p>
    </sec>
    <sec id="sec-4">
      <title>Conclusion</title>
      <p>Several conclusions emerged from the search for the
optimal setting of the trading system. The first is the fact that
the neural network was able to adapt to both unabridged
and abbreviated data sets, and this did not have a
significant effect on trading in the currency market. On the
training dataset, the trading system worked relatively well.
Net profit for the best systems ranged from $ 382.16 to
$ 431.20 per week.</p>
      <p>Another conclusion can be made that the constant
expansion of the size of the time period for the training data
set is not the most suitable solution, because the two most
successful trading systems are from a four-week period,
one from a five-week period. The eight-week period did
not generate a single successful trading system, and even
resulted in worse than five and four weeks. We also
performed a test on a 2KMN trading system with nine bars in
the input layer, topology 2,124 – 420 – 15. When we
extended the training set to an entire calendar year, the result
was a net profit of $ 22.2 on unknown data.</p>
      <p>The neural network, although doing relatively well on
the trained data, was unable to perform well with the
untrained test set due to overfitting. Of all the settings and
trading systems tested, only one variant reported a net
profit on the new unlearned week, with this net weekly
gain being only $ 6.70. This indicates that raw trading
data series may not have enough regularities that could be
successfully learned by the network. It will be necessary
to optimize various types of input aggregated from the
input dataset, and to include external information possibly
influencing the market. It will be necessary to use a larger
training data set, which the computing power of the GPU
will allow.</p>
      <p>
        Another improvement will be the use of deep learning
methods [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ] with various types of layers suitable for time
series prediction. Therefore, in the next phase, the
application will be migrated from the C# programming
language to Python, and the Keras and Tensorflow libraries
will be used to find the optimal topology of the trading
system. We will, e.g., compare results of convolutional neural
networks and recurrent neural networks, including LSTM
or GRU networks, multimodal networks and fuzzy-neural
networks. The transition to this technology using GPU
will also make it possible to work with a larger amount
of data. We tested that switching to Keras libraries would
allow to work with a ten-fold larger data set, so the
adaptation set can include data from the entire calendar year.
      </p>
      <p>The complex modular system will be completed by
a separate group of fuzzy-neural networks, which will
form a set of rules, which will then be applied in
online trading in the currency market. By combining all
these separate modules, we will obtain an artificial
intelligence tool that will incorporate many possible approaches
to time series prediction.</p>
    </sec>
    <sec id="sec-5">
      <title>Acknowledgements</title>
      <p>This work was supported by the Ministry of
Education, Youth and Sports Of the Czech Republic from the
National Programme of Sustainability (NPU II) project
IT4Innovations Excellence in Science - LQ1602, and by
the Silesian University in Opava under the Student
Funding Scheme, project SGS/11/2019.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <surname>ABRAHAM</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>CHOWDHURY</surname>
            ,
            <given-names>M. U.</given-names>
          </string-name>
          <article-title>An Intelligent FOREX Monitoring System</article-title>
          .
          <source>In Proceedings of IEEE International Conference on Info-tech and Infonet</source>
          , Beijing, China, page
          <volume>523</volume>
          -
          <fpage>528</fpage>
          ,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>Accumulation</given-names>
            <surname>/Distribution</surname>
          </string-name>
          (A/D) [online].
          <source>Copyright c</source>
          <year>2009</year>
          - 2019
          <source>FXstreet.cz s.r.o. [cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://www.fxstreet.cz/accumulationdistribution-ad.html
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>CMF</given-names>
            <surname>- Chaikin Money</surname>
          </string-name>
          Flow [online]. Copyright c eTradink.
          <source>sk [cit. 17. 6</source>
          . 2019] https://www.etrading.sk/cz/technicka-analyza/116- indikatory/649-cmf
          <article-title>-chaikin-money-flow</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <article-title>[4] Discover the Advantages of the MT4 Moving Average Indicator [online]</article-title>
          .
          <source>[cit. 16. 6</source>
          .
          <year>2019</year>
          ]. https://admiralmarkets.com/education/articles/forexindicators/moving-average-indicator
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>Everything</given-names>
            <surname>You</surname>
          </string-name>
          <article-title>Need to Know About the Oscillator of Moving Average (OsMA Indicator)</article-title>
          [online].
          <source>[cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://admiralmarkets.com/education/articles/forexindicators/osma-indicator
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <article-title>[6] Find the Truth Behind the Trend with the MT4 Momentum Indicator [online]</article-title>
          .
          <source>[cit 17. 6</source>
          .
          <year>2019</year>
          ]. https://admiralmarkets.com/education/articles/forexindicators/momentum
          <article-title>-indicator-mt4-explained-in-detail</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <surname>Force</surname>
            <given-names>Index - FRC</given-names>
          </string-name>
          [online].
          <source>[cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://www.instaforex.eu/cz/forex_technical_indicators/frc
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>Forex</given-names>
            <surname>Trading Strategies With Envelopes Indicator</surname>
          </string-name>
          [online].
          <source>Copyright @ 2019 Dolphintrader.com. [cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://www.dolphintrader.
          <article-title>com/forex-trading-strategieswith-envelopes-indicator/</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <article-title>[9] Get a Feel for Market Momentum with the Awesome Oscillator Indicator [online]</article-title>
          .
          <source>[cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://admiralmarkets.com/education/articles/forexindicators/awesome-oscillator-indicator
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <article-title>Get Ahead of the Curve with the MT4 Commodity Channel Index Indicator [online]</article-title>
          .
          <source>[cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://admiralmarkets.com/education/articles/forexindicators/commodity-channel
          <string-name>
            <surname>-</surname>
          </string-name>
          index-indicator
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          [11]
          <string-name>
            <surname>GALESCHUK</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          <article-title>Neural networks performance in exchange rate prediction</article-title>
          .
          <source>Neurocomputing</source>
          ,
          <volume>172</volume>
          , pages
          <fpage>446</fpage>
          -
          <lpage>452</lpage>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          [12]
          <string-name>
            <surname>GOH</surname>
          </string-name>
          , A. T. C.
          <article-title>Back-propagation neural networks for modeling complex systems Artificial Intelligence in Engineering</article-title>
          , vol.
          <volume>9</volume>
          ,
          <issue>num</issue>
          . 3, pages
          <fpage>143</fpage>
          -
          <lpage>151</lpage>
          ,
          <year>1995</year>
          , issn 0954-
          <year>1810</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          [13]
          <string-name>
            <surname>GOODFELLOW</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          , BENGIO Y.,
          <article-title>COURVILLE A. Deep Learning</article-title>
          . MIT Press,
          <year>2016</year>
          . http://www.deeplearningbook.org
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          [14]
          <article-title>How to Use the Parabolic SAR Indicator to Trade the Trend [online]</article-title>
          .
          <source>[cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://admiralmarkets.com/education/articles/forexindicators/parabolic-sar-indicator
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          [15]
          <string-name>
            <surname>KIPRUTO</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          ,
          <article-title>MUNG'ATU</article-title>
          ,
          <string-name>
            <surname>J.</surname>
          </string-name>
          , ORWA,
          <string-name>
            <surname>G.</surname>
          </string-name>
          , GAITHIMBA,
          <string-name>
            <surname>N.</surname>
          </string-name>
          <article-title>Application of Artificial Neural Network (Ann)</article-title>
          . In Modeling Foreign Currency Exchange Rates.
          <source>International Journal of Scientific Research and Management</source>
          . vol
          <volume>6</volume>
          , issue 10, pages
          <fpage>111</fpage>
          -
          <lpage>123</lpage>
          ,
          <year>2018</year>
          . ISSN:
          <fpage>2321</fpage>
          -
          <lpage>3418</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          [16]
          <string-name>
            <surname>LAM</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <article-title>Neural network techniques for financial performance prediction: integrating fundamental and technical analysis</article-title>
          .
          <source>In Decision Support Systems</source>
          , vol.
          <volume>37</volume>
          ,
          <string-name>
            <surname>Issue</surname>
            <given-names>4</given-names>
          </string-name>
          , pages
          <fpage>567</fpage>
          -
          <lpage>581</lpage>
          ,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          [17]
          <string-name>
            <surname>LAVANYA</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>PARVEENTAJ</surname>
          </string-name>
          ,
          <string-name>
            <surname>M.</surname>
          </string-name>
          <article-title>Foreign Currency Exchange Rate (FOREX) using Neural Network</article-title>
          . In
          <source>International Journal of Science and Research (IJSR</source>
          <year>2013</year>
          )
          <article-title>ISSN</article-title>
          (Online):
          <fpage>2319</fpage>
          -
          <lpage>7064</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          [18]
          <string-name>
            <surname>The</surname>
            <given-names>MACD</given-names>
          </string-name>
          Indicator In Depth [online].
          <source>[cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://admiralmarkets.com/education/articles/forexindicators/macd
          <article-title>-indicator-in-depth</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          [19]
          <string-name>
            <surname>MANSOUR</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>AKAY</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <article-title>Predicting Exchange Rate by Using Time Series Multilayer Perceptron</article-title>
          .
          <source>In Science and engineering congress (IMSEC)</source>
          ,
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          [20]
          <string-name>
            <surname>POBUCKÝ</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          <article-title>Neuronový obchodní systém pracující v reálném cˇase</article-title>
          . Opava: Silesian University, The Institute of Computer Science,
          <source>Rigorous thesis</source>
          ,
          <year>2020</year>
          . 118 s.
        </mixed-citation>
      </ref>
      <ref id="ref21">
        <mixed-citation>
          [21]
          <article-title>Put the Pedal to the Metal With the Accelerator Oscillator [online]</article-title>
          .
          <source>[cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://admiralmarkets.com/education/articles/forexindicators/accelerator-oscillator
        </mixed-citation>
      </ref>
      <ref id="ref22">
        <mixed-citation>
          [22]
          <article-title>See Beneath the Surface of the Market With the Bears and Bulls Power Indicators [online]</article-title>
          .
          <source>[cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://admiralmarkets.com/education/articles/forexindicators/bears-and
          <article-title>-bulls-power-indicator</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref23">
        <mixed-citation>
          [23]
          <string-name>
            <surname>SEZER</surname>
            ,
            <given-names>O. B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>GUDELEK</surname>
            ,
            <given-names>M. U.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>OZBAYOGLU</surname>
            ,
            <given-names>A. M.</given-names>
          </string-name>
          <article-title>Financial Time Series Forecasting with Deep Learning : A Systematic Literature Review: 2005-2019</article-title>
          . In Applied Soft Computing, vol
          <volume>90</volume>
          ,
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref24">
        <mixed-citation>
          [24]
          <article-title>Track the Pulse of the Market with the Money Flow Index Indicator [online]</article-title>
          .
          <source>[cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://admiralmarkets.com/education/articles/forexindicators/money
          <article-title>-flow-index-indicator</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref25">
        <mixed-citation>
          [25]
          <article-title>Trading With the Cloud: Using the Ichimoku Kinko Hyo Indicator in MetaTrader 4</article-title>
          [online].
          <source>[cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://admiralmarkets.com/education/articles/forexindicators/ichimoku-kinko
          <string-name>
            <surname>-</surname>
          </string-name>
          hyo-indicator
        </mixed-citation>
      </ref>
      <ref id="ref26">
        <mixed-citation>
          [26]
          <string-name>
            <surname>Vidya - Variable Index</surname>
          </string-name>
          Dynamic Average [online]. Copyright c eTradink.
          <source>sk [cit. 16. 6</source>
          . 2019] https://etrading.sk/cz/technicka-analyza/116- indikatory/639-vidya
          <article-title>-variable-index-dynamic-average</article-title>
        </mixed-citation>
      </ref>
      <ref id="ref27">
        <mixed-citation>
          [27]
          <string-name>
            <surname>VUKOVIC</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>VYKLYUK</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          <article-title>Forex predicton with neural network: usd/eur currency pair</article-title>
          .
          <source>In Actual Problems of Economics</source>
          . vol
          <volume>10</volume>
          , pages
          <fpage>251</fpage>
          -
          <lpage>261</lpage>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref28">
        <mixed-citation>
          [28]
          <string-name>
            <surname>%R: Williams</surname>
          </string-name>
          Percent Range [online].
          <source>Copyright c</source>
          <year>2009</year>
          - 2019
          <source>FXstreet.cz s.r.o. [cit. 17. 6</source>
          .
          <year>2019</year>
          ]. https://www.fxstreet.cz
          <article-title>/r-williams-percent-range</article-title>
          .html
        </mixed-citation>
      </ref>
      <ref id="ref29">
        <mixed-citation>
          [29]
          <string-name>
            <surname>YONG</surname>
            ,
            <given-names>Y. L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>NGO</surname>
            ,
            <given-names>D. C. L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>LEE</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          <article-title>Technical Indicators for Forex Forecasting: A Preliminary Study</article-title>
          .
          <source>In Advances in Swarm and Computational Intelligence</source>
          , 6th International Conference,
          <source>ICSI, Lecture Notes in Computer Science book series (LNCS</source>
          , volume
          <volume>9142</volume>
          ), pages
          <fpage>87</fpage>
          -
          <lpage>97</lpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref30">
        <mixed-citation>
          [30]
          <string-name>
            <surname>ZHANG</surname>
            ,
            <given-names>X.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>TAN</surname>
            ,
            <given-names>Y.</given-names>
          </string-name>
          <article-title>Deep stock ranker: A LSTM neural network model for stock selection</article-title>
          .
          <source>In Data Mining and Big Data</source>
          , pages
          <fpage>614</fpage>
          -
          <lpage>623</lpage>
          . Springer International Publishing,
          <year>2018</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>