Deep Learning and Technical Analysis in Cryptocurrency Market
Deep Learning and Technical Analysis in Cryptocurrency Market
CRYPTOCURRENCY MARKET
Stéphane Goutteb , Hoang-Viet Lea,b,* , Fei Liuc and Hans-Jörg von Mettenheimc,a,d
a
Keynum Investments, France
b
Université Paris Saclay, UMI SOURCE, IRD, UVSQ, France
c
IPAG Business School, France
d
Oxford-Man Institute of Quantitative Finance, United Kingdom
Abstract
A large number of modern practices in financial forecasting rely on technical analysis, which
involves several heuristics techniques of price charts visual pattern recognition as well as other
technical indicators. In this study, we aim to investigate the potential use of those technical infor-
mation (candlestick information as well as technical indicators) as inputs for machine learning
models, especially the state-of-the-art deep learning algorithms, to generate trading signals. To
properly address this problem, empirical research is conducted which applies several machine
learning methods to 5 years of Bitcoin hourly data from 2017 to 2022. From the result of our
study, we confirm the potential of trading strategies using machine learning approaches. We also
find that among several machine learning models, deep learning models, specifically the recurrent
neural networks, tend to outperform the others in time-series prediction.
Keywords: Bitcoin, Technical Analysis, Machine Learning, Deep Learning, Convolutional Neu-
ral Networks, Recurrent Neural Network
Even since the success of Google’s AlphaGo against the Go World Champion in 2016, the keywords
AI (Artificial Intelligence), machine learning, and deep learning have become the buzzwords that
keep being mentioned in almost every industry. As a matter of fact, machine learning has already
been slowly yet steadily transforming your everyday activities.
The finance industry, as expected, is one of the pioneers to incorporate AI technologies into its
ecosystems. In recent years, more and more studies have been published that were based on the
application of machine learning models on forecasting time series and many of them point out the
relatively better performances of newer machine learning models compared to classical time series
forecasting techniques[9; 4; 11]. Additionally, the widespread and easy-to-access automated elec-
tronic trading systems coupled with increasing demand for better alpha keeps forcing trading prac-
titioners and researchers to put more effort into searching for better and more sophisticated models.
Not until recently, the technique of deep learning (DL), a subset of machine learning which involves
the application of neural networks, started to emerge as one of the best performing techniques within
the field of machine learning in a vast majority of implementation areas. It is no exception in the case
of financial time series forecasting as a growing number of deep-learning-based models of predic-
tion have been introduced in several conferences and journals in recent years. Gu et al. (2020) used
neural networks to forecast stock prices from the US market to find out their superiority over other
models such as generalized linear models, principal components regressions, and regression trees[6].
Zhang et al. (2021) utilize the recurrent neural networks, specifically the long short-term memory
(LSTM) networks, to predict stock trends report significant positive returns[12]. The work of Bianchi
et al. (2021), on the other hand, focus on forecasting bond excess returns and also report significant
economic gains[3]. Some other studies target other financial assets such as cryptocurrencies and also
often point out the edge of the neural networks model on forecasting future price movements (Anghel,
2020[1]).
In this paper, we tried to put into practice those state-of-the-art deep learning models along with
other popular machine learning models to see how well they perform in finding trading signals using
the same inputs that was used in traditional technical analysis. While most of the other researches
on this topic focus on the traditional stock markets, this paper choose the cryptocurrency market,
specifically the Bitcoin market, as the target of research.
As every transaction is recorded in this table, the total number of transactions is provided during
our chosen period from the end of 2017 until August 2022 is upto a few billions. This is an enormous
amount of data and is required to be processed for further analysis.
After the resampling procedure, the length of our dataset is reduced to only 43,463 data points.
For the purpose of training our machine learning models, the data will be divided into 3 parts: training
set, validation set, test set with the proportion of 50%, 25%, and 25% respectively.
Source:[10]
The specific formulas to transform the price variables into a candlestick are as follows:
(
W hite if Close − Open > 0
Color = (1)
Black if Close − Open < 0
Finally for the CNN, instead of the recurrent layers like LSTM or GRU, two convolutional layers
are added along with two max-pooling layers and 0.5 dropouts each. Each of the convolutional layers
has 8 neurons, similar to the recurrent neural network architecture.
All of the neural network models are training in 500 training epochs with batch size equaling to
1024. Early stopping and model checkpoints based on the validation loss are also used to prevent
overfitting so that we can get the best performing model on the validation set.
where Ri is the return of every time step, and Si is the binary signal generated by the model at each
specific time step.
Using this total return as a metric, however, does not incorporate the transaction cost and therefore
the higher return may come from many small trades instead of the quality of every single trade (again
recall versus precision). As a result, in this study, we will primarily use the metrics of average return
to reflect the quality of the signal instead.
T otal Return
Average Return = PN (6)
i=1 Si
In combination with the primary two dimensions of long and short strategy, in the end, each type
of machine learning models are fitted 8 different times as the combination of the 3 dimensions. In the
end, we have in total 56 different models and all of their result are shown in Table 7 and Table 8.
The two tables show the list of all models with their performance metrics calculated on the val-
idation and the test set. The order of how they are listed is based on their precision on the test set,
from the highest to the lowest. From just a quick view of the two tables, we can see that most of the
top models are deep learning models with the exception of the LightGBM in shorting strategy. Addi-
tionally, all of the machine learning models overall outperform almost all of the candlestick patterns
in both precision and average return, given the same range of recall. Given the fact that the market
is quite bearish in the test set and the shorting is generally more difficult in practice, we believe the
performance for the long-only strategy is more reliabe compared to the short-only strategy
The best performing model here in both validation and test set is the GRU long-only model which
is trained on the extended candle dataset with 58.36% precision and the average return of 0.04%. The
performance of this strategy is shown in figure 2 and 3 where it is compared with the buy-and-hold
strategy of Bitcoin for reference.
From the two figures, we can see the model outperformed the benchmark and there are way less
downtrends and drawdowns during the both period. The cumulative return of the strategy also increase
steadily and does not come from only a few single trades or some specific period.
10
Table 10. Comparison between the raw dataset and extended dataset
Validation Test
Feature
Precision Recall Avg return Precision Recall Avg return
extended 56.75% 14.05% 0.049% 56.12% 14.13% 0.009%
raw 56.78% 11.86% 0.045% 56.10% 11.90% 0.008%
The addition of 12 new technical indicators almost does not substantially increase the performance
of all machine learning models, at least in the quality of the signals. The inclusion of those indicators
only led to an increase of measly 0.02% in precision for the test set. However, those indicators surely
do increase the numbers of signals with more than 2% improvement in recall in both dataset.
From the table, it is easy to observe that the recurrent neural networks (GRU and LSTM) are
better in both precision and average return for this specific classification task with the exception of
the LightGBM. They are ranked from the highest to the lowest in the precision calculated on the test
set. Among them, the GRU model is better in almost every metrics compared to other models. For
the LightGBM models, they come second but only perform well for the short-only strategy in the
bearish market. Their long-only versions are quite worse compared to the other. As a result, we do
not value their performance that high. The LSTM model comes third but with the best performance
11
4 C ONCLUSION
Our analysis has pointed out that it is not inconceivable that the Bitcoin price history might contain
some predictive information. That information can even be enhanced through the use of several
popular technical indicators so that they can be exploited by quantitative methods to create a profitable
trading strategy. Our detailed results show that our prediction models using the machine learning
approach trained on the Binance cryptocurrency exchange can create the profits that are better than
the classic Buy-and-Hold strategy and provide much better precision than random guesses.
Our study has shown how several popular machine learning methods such as neural networks,
decision trees, and logistic regression performed on Bitcoin price trend prediction. The results turned
out that the neural networks did the best compared to other models, especially in the case of fewer
features. However, among several neural network architectures, the state-of-the-art CNNs did not
outperform other architectures with comparable complexity as we expected [5]. The recurrent neural
network, on the other hand, shows superior performance with the GRU architectures and, to a lesser
extent, the LSTM architectures. Between the two, the GRU performed better than LSTM. However,
due to the limited sample size, we can not arbitrarily conclude that the GRU is better than the LSTM.
12
A NGHEL , D.-G. A reality check on trading rule performance in the cryptocurrency market: Machine
learning vs. technical analysis. Finance Research Letters 39 (2021), 101655.
BASAK , S., K AR , S., S AHA , S., K HAIDEM , L., AND D EY, S. R. Predicting the direction of stock
market prices using tree-based classifiers. The North American Journal of Economics and Finance
47 (2019), 552–567.
B IANCHI , D., B ÜCHNER , M., AND TAMONI , A. Bond risk premiums with machine learning. The
Review of Financial Studies 34, 2 (2021), 1046–1089.
C OSENZA , D. N., KORHONEN , L., M ALTAMO , M., PACKALEN , P., S TRUNK , J. L., N ÆSSET, E.,
G OBAKKEN , T., S OARES , P., AND T OM É , M. Comparison of linear regression, k-nearest neighbour
and random forest methods in airborne laser-scanning-based prediction of growing stock. Forestry:
An International Journal of Forest Research 94, 2 (2021), 311–323.
G HOSHAL , S., AND ROBERTS , S. Thresholded convnet ensembles: neural networks for technical
forecasting. Neural Computing and Applications (04 2020).
G U , S., K ELLY, B., AND X IU , D. Empirical asset pricing via machine learning. The Review of
Financial Studies 33, 5 (2020), 2223–2273.
N OBRE , J., AND N EVES , R. F. Combining principal component analysis, discrete wavelet transform
and xgboost to trade in the financial markets. Expert Systems with Applications 125 (2019), 181–194.
RODRIGUEZ , P. N., AND RODRIGUEZ , A. Predicting stock market indices movements. WIT Trans-
actions on Modelling and Simulation 38 (2004).
WANG , Z., AND OATES , T. Encoding time series as images for visual inspection and classification
using tiled convolutional neural networks.
Y UN , K. K., YOON , S. W., AND W ON , D. Prediction of stock price direction using a hybrid ga-
xgboost algorithm with a three-stage feature engineering process. Expert Systems with Applications
186 (2021), 115716.
Z HANG , Y., C HU , G., AND S HEN , D. The role of investor attention in predicting stock prices: The
long short-term memory networks perspective. Finance Research Letters 38 (2021), 101484.
Z OLOTAREVA , E. Aiding long-term investment decisions with xgboost machine learning model. In
International Conference on Artificial Intelligence and Soft Computing (2021), Springer, pp. 414–
427.
13