Convolutional Neural Network-based a novel Deep Trend Following Strategy for Stock Market Trading Jagdish Chakolea , Manish Kurhekara a Department of Computer Science and Engineering, Visvesvaraya National Institute of Technology, Nagpur, India Abstract Extracting or predicting future stock price trends from the current and historical stock trading activity is an open research problem. Convolution Neural Network (CNN) recently shown excellent performance to extract high-level features from raw data in many domains. In this research work, we trained CNN to extract future stock price trends. Trend Following is a trading strategy that does not require prior knowledge of the future stock price trend. In the Trend Following trading strategy, traders buy stock in an uptrend and sell the stock in a downtrend. Trend Following trading strategy is based on the current price trend and the assumption that the current price trend will continue further for some time, but if the current price trend does not proceed then this trading strategy fails to provide the profit. Our objective is to improve the Trend Following trading strategy by combining the advantages of both the CNN-based prediction and the Trend Following trading strategy. In this research work, we proposed a modified CNN-based Trend Following trading strategy named Deep Trend Following (DTF) in which trading decisions are based on the current and predicted future price trend of the stock. Our experimental results are twofold. Firstly our trained CNN-based classifier outperformed the baseline methods. Secondly, the DTF trading strategy outperformed three trading strategies viz the CNN-based, Buy-and-Hold, and the simple Trend Following trading strategies on the American and the Indian index stocks. Keywords Algorithmic Trading, Convolutional Neural Network, Trend Following Trading Strategy 1. Introduction fundamental analysis. The trader uses technical analysis to predict the short term trend of the stock. Technical Stock market trading is a fascinating domain in search analysis uses historical data to predict the short term of lucrative profit. The movement of the stock price is trend, and it uses moving averages and other indicators. non-linear, non-stationary, and noisy as the stock price As stock price depends on various uncertain events. is based on various factors, and most of these factors are Long term trend prediction using historical and current uncertain. Many factors can move the stock price up or stock market data is not reliable as the time window is down including demand-and-supply of stock, company’s long, so there is a high probability of occurrence of any management, competition from competitors, government such event. In the case of short term trend prediction policy, the policy of the central bank of the country, any as the time window is short probability of occurrence of news related to the company can influence the stock price. an uncertain event is low. So, in this research work, our As per the Efficient Market Hypothesis ([1]), the stock focus is on the short term trend prediction. market is efficient, and it reflects the effect of information Algorithm Trading (AT) is nowadays being used heav- on the stock price. ily in the stock market for trading. In AT, computer Traders and investors buy, sell, or hold (do nothing) programs take the trading decision and execute the trad- stocks for profit, but their objectives are different. The ing action, i.e. buying or selling of stock as per the logic perspective of the investor is long term based on the long written in the computer program. Basically AT is auto- term trend and the prospect of the company, having a mate the trading process. It can continuously track the stockholding period ranging from a year to a few years. stock price activity and can quickly respond to any op- In contrast, traders buy (sell) and sell (buy) the stock portunity in terms of the trading decision. AT is mostly based on the short term trend, having a stockholding used for two things, first to automate a predefined trading period of a few days, hours, minutes, or seconds. The strategy, and second is finding a trading strategy along investors predict the long term trend of stock based on with its automation. Trend Following (TF) is a trading strategy within traders MUFin21 (International Workshop on Modelling Uncertainty in the who buy stock in an uptrend and sell the shares in the Financial World) downtrend([2, 3]). So, it does not require prior knowl- Envelope-Open jagdish06@students.vnit.ac.in (J. Chakole); edge of the future stock price trend. Trend Following manishkurhekar@cse.vnit.ac.in (M. Kurhekar) trading strategy is based on the current price trend and Orcid 0000-0003-0242-7297 (J. Chakole); 0000-0002-6409-3280 (M. Kurhekar) the assumption that the current price trend will continue Β© 2020 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0). further for some time. It fails to provide profit if the cur- CEUR Workshop Proceedings http://ceur-ws.org ISSN 1613-0073 CEUR Workshop Proceedings (CEUR-WS.org) rent price trend does not continue after trading action authors used Deep Neural Network to predict the next is taken based on the current trend. The success of the one-minute return prediction and used this prediction for TF strategy is based on the behavior of the stock price trading strategy for high-frequency trading. Authors in trend after the trading action is taken. If we predict in ([7]) used CNN to predict the one-minute ahead trend of advance the future behavior of the stock price trend, then the cryptocurrency exchange rates. They experimented this TF strategy will be more profitable. In that case, the on the six popular cryptocurrencies. In ([8]), index stock TF strategy will take a trading decision based on current trend predicted using CNN. They also optimized the hy- and predicted future stock price trends. perparameters of the CNN model using a Genetic Al- Extracting or predicting future stock price trends from gorithm. In ([9]), the authors proposed an algorithmic the current and historical stock trading activity is an trading strategy using CNN. They converted the tech- open research problem for traders and researchers. Many nical indicator data into a 2-dimensional image to train researchers attempted to predict the future stock price the CNN model. In ([10]), authors extracted stock price trend based on historical stock market data. They used trend from limit order book data using a CNN. They various prediction methods, including machine learning used a Long Short Term Memory method to know past technics like SVM, Random Forest, ANN but input fea- time dependency in the data. In ([11]), the authors used tures selection is a critical task for the success of these thresholded ensemble CNN for financial data, and this methods. Convolution Neural Network (CNN) showed model outperformed the technical methods. the excellent performance to extract high-level features The remainder of the paper is organized as follows. from raw data in many domains, including computer Section 2 describes the methodology used in this work, vision. Recently some researchers used ([4, 5]) CNN to including Deep Learning and CNN. Section 3 explains predict the future stock price trend as CNN is capable of the proposed trading system. Section 4 is devoted to finding the patterns in the raw data. experimental results, including data representation and The prediction or classification of stock price or trend performance evaluation of the proposed trading system. using machine learning methods is looking promising Concluding remarks with suggestions for future research but is not always reliable. So, taking a trading decision are given in Section 5. based only on the prediction of future price trends is not a good strategy. The TF strategy based solely on the current stock price trend also does not look promising. 2. Methodology The combination of these two strategies will reduce the This section provides a concise presentation to Convolu- disadvantages of both approaches. Our objective is to tional neural networks. improve the TF trading strategy by combining the advan- tages of both, i.e. CNN-based future stock price trends prediction and TF trading strategy. In this research work, 2.1. Convolutional Neural Network we proposed a modified CNN-based TF trading strategy, The typical architecture of CNN consists of a series of and we name it as Deep Trend Following (DTF) in which layers, and these layers can classify as the Input layer, trading decisions will base on the current price trend and Convolutional layer, Pooling layer, Fully connected layer, CNN-based predicted future price trend of the stock. and Output layer as shown in Figure 1 ([12, 13]) ([14]). We experimented with the proposed DTF strategy on the American and the Indian index stocks. As we created the DTF strategy using a CNN-based binary classifier to predict the next session, 𝑑 + 1 close price trend and sim- ple Trend Following trading strategy. Our experimental results are twofold, firstly we evaluated the performance of our CNN-based classifier with the baseline method on the same American index stocks dataset used in the baseline paper ([4]) and the results reported in the Table 2 and Table 3. Secondly, we evaluated the performance of the proposed DTF strategy with the CNN-based, Buy- and-Hold, and simple Trend Following trading strategies using performance evaluation metrics mentioned in Sec- tion 4.4 on the American and the Indian index stocks and the results reported in Table 4. In ([4]), authors use CNN to predict the next-day stock price trend using features from diverse sources. They Figure 1: Convolutional Neural Network represented the input data in 2D and 3D forms. In ([6]), 2.2. Trend Following Strategy Trend Following is a stock trading strategy that takes 2.1.1. Convolutional layer trading decisions based on the current stock price trend. The first layer in a CNN is a convolutional layer, as shown It takes a trading decision whenever current stock price in Figure 1, this layer extracts features called a feature trend changes, i.e. from an uptrend to downtrend or map from the input data by performing the convolu- downtrend to uptrend for that it continuously observes tion operation using a filter. In this work, input data the current trend. In stock market trading buy first and represented as a two-dimensional array 𝐴(π‘š, 𝑛) having sell later is called a Long position. Sell first and buy then π‘š number of rows and 𝑛 number of columns. A two- is called a Short position. Traders take a long position dimensional filter 𝐹 (𝑝, π‘ž) having 𝑝 number of rows and whenever they think the stock price will increase and π‘ž number of columns used. The convolution operation take a short position whenever they feel the stock price performed on two functions so the input 𝐴 and filter 𝐹 will decrease. can be thought as functions, the convolution operation on these two functions performed as per the Equation 1 ([15]) to produce another function 𝐡 which is a 2-D fea- 3. Proposed Trading System ture map having π‘šβˆ’π‘ +1 rows and π‘›βˆ’π‘ž +1 columns. The Predicting the future stock price trend and optimal uti- values in the filter learned while training the network. lization of the prediction along with implicit provision π‘š/2 𝑛/2 for risk management is the fundamental idea of this work. 𝐡(𝑖, 𝑗) = 𝐴(𝑖, 𝑗)βŠ—πΉ (𝑝, π‘ž) = βˆ‘ βˆ‘ 𝐴(𝑖+𝑝, 𝑗+π‘ž)βˆ—πΉ (𝑝, π‘ž)In this section, we propose the complete end-to-end Al- 𝑝=βˆ’π‘š/2 π‘ž=βˆ’π‘›/2 gorithmic trading strategy using the Trend Following (1) strategy and CNN. Our proposed trading system will The activation function is applied to the output of work on single security (or stock) for simplicity and will the convolution operation as shown in Equation 2. The take only one trading decision, i.e. buy, sell, or hold (do nonlinear activation function commonly used is Relu nothing) a previous trading position on every trading 𝑓 (π‘Ž) = max(0, π‘Ž). session. We have included the transaction cost of 0.10% of the trading amount for buy or sell in our study. We π‘š/2 𝑛/2 have performed experimentation on the daily stock data 𝐡(𝑖, 𝑗) = 𝛿( βˆ‘ βˆ‘ 𝐴(𝑖 + 𝑝, 𝑗 + π‘ž) βˆ— 𝐹 (𝑝, π‘ž)) (2) having open, high, low, and close price information along 𝑝=βˆ’π‘š/2 π‘ž=βˆ’π‘›/2 with the volume of the trading. The proposed trading system is shown in Figure 2, 2.1.2. Pooling layer in which the CNN module is responsible for predicting The pooling layer reduces the dimensionality of the fea- future stock price trends. It has trained from historical ture map by subsampling of the data while retaining stock market data. It will predict the next trading session the useful features. It reduces the computational cost (𝑑 + 1) close price trend from live and historical stock and also it is a measure to avoid overfitting of the CNN market data. The technical analysis indicators module model. In pooling operation, pooling window used, the tells the current (𝑑) stock price trend at the closing time of values under the window reduced to a single value, which the current session 𝑑 from live and historical stock market reduces the size of the input to the next layer. The com- data. monly used pooling operation is the max pooling, in The Trend Following trading agent will take a trad- which among the values, the maximum value selected. ing decision at the open time of the next trading session 𝑑 + 1. It is based on the prediction of CNN about the 2.1.3. Fully Connected Layer stock close price trend of next trading session (𝑑 + 1) and current (𝑑) stock price trend provided by technical The convolution operation, activation function, and pool- analysis indicators as shown in the Algorithm 1. In the ing operation are responsible for extracting features from Algorithm 1, CR_trend denotes the current (𝑑) stock price the input. To map these extracted features in the pre- trend provided by the technical analysis indicators, and vious layers into the final output, at the end of CNN, NX_trend indicates the prediction of CNN about the next a fully connected network, i.e. multilayer perceptron trading session (𝑑 + 1) stock close price trend. We are tak- (MLP) is appended. It converts the last 2-D feature map ing a trading decision at the opening of the next trading to the 1-D feature vector. In a classification problem, a session 𝑑 + 1 instead of the close of the current trading single output selected from the feature vector based on session 𝑑 because non-trading period information also the probabilities of all the outputs using a probabilistic plays a significant role to decide the stock price trend. function. Softmax is the commonly used probabilistic function for this task. Figure 3: Input features in matrix form Figure 2: Proposed Trading System 4.1. Data Representation Algorithm 1 Deep Trend Following Our proposed Deep Trend Following trading strategy uses the stock price trend predicted by the two-dimensional if (CR_trend == Uptrend) AND (NX_trend == Uptrend) CNN, to make a trading decision. CNN predicts the next then session stock price trend based on the current and histori- if (CR_position == NIL) then cal stock trading data, so input data to CNN is represented Open a Long position in the two-dimensional matrix form, as shown in Figure else if (CR_position == Long) then 3. We have derived 𝑛 features from the stock trading Hold the previous Long position data, and these total 𝑛 features form the columns of the else if (CR_position == Short) then matrix. The entire π‘š rows of the matrix are the current Close the previous Short position and historical days, i.e. trading sessions. The optimal Open a new Long position value of π‘š is ten, i.e. ten recent days’ data to predict the end if next trading session close price selected by experimenta- else if (CR_trend == Downtrend) AND (NX_trend == tion on different values of π‘š. The features used and the Downtrend) then calculations are described in Table 5. if (CR_position == NIL) then Total features are thirty, which can group as technical Open a Short position indicators, simple moving averages, exponential moving else if (CR_position == Short) then averages, day of the week. Day of the week is a very Hold the previous Short position significant feature because the global stock markets cor- else if (CR_position == Long) then related up to a certain extend. The non-trading hours Close the previous Long position period is also a significant factor in the stock price trend. Open a new Short position The experimental data is divided into training and testing, end if as shown in Table 1. else if any previous position then Hold it if no previous position then do nothing end if The training data is very crucial for the performance of the machine learning model. We identified the outlier in our dataset based on the observation of the daily % 4. EXPERIMENTAL RESULTS changes in the close price, as shown in Figure 4. We removed the outlier using Z-statistics. This section describes the data representation to train the CNN model. The detail of the baseline algorithm to compare the performance of the proposed classifier. The experimental setup of the proposed DTF trading strategy, 4.2. Baseline algorithm also about performance evaluation metrics used. De- Our baseline algorithm is the one reported in ”Ehsan tail of the CNN-based, Buy-and-Hold, and simple Trend Hoseinzade and Saman Haratizadeh (2019)”. We com- Following trading strategies used to compare the perfor- pare the performance of the proposed method with the mance of the proposed DTF strategy and also discusses baseline algorithm ([4]). We have experimented with the the experimental results. proposed method with the same dataset mentioned in the baseline algorithm. Compared the results of the pro- posed method with the results reported in the baseline algorithm. Table 1 Experimental Data of the American index stocks DJIA, NASDAQ, S&P 500, RUSSEL and Indian index stock NIFTY Index Stock Time Total Span Training Span Testing Span Start 1990-01-02 1990-01-02 2018-07-10 NASDAQ End 2019-12-31 2018-07-09 2019-12-31 Start 1990-01-02 1990-01-02 2018-07-06 DJIA End 2019-12-31 2018-07-05 2019-12-31 Start 1990-01-02 1990-01-02 2018-07-09 S&P 500 End 2019-12-31 2018-07-06 2019-12-31 Start 1990-01-02 1990-01-02 2018-05-29 RUSSEL End 2019-12-31 2018-05-25 2019-12-31 Start 2000-01-03 2000-01-03 2018-01-03 NIFTY End 2019-12-31 2018-01-02 2019-12-31 the buy-and-hold, CNN-based trading strategy, and sim- ple Trend Following trading strategy. All four trading strategy experimented on DJIA, NASDAQ, and S&P 500 American index stocks; also on Indian index stock NIFTY as shown in Figure 5, Figure 6, Figure 7 and Figure 8 respectively. 4.4. Performance evaluation metrics for trading strategy We have used % Accumulated Return, % Maximum Draw- Figure 4: Outlier in the DJIA dataset down, % Average Daily Return, % Average Annual Return, Sharpe Ratio, Standard Deviation, Skewness, and Kur- tosis[3] to compare the proposed DTF trading strategy In the baseline algorithm, They predicted the next day with the CNN-based, simple Trend Following and buy- binary direction of the index stock using the CNN-based and-hold trading strategies. framework. They used data from a diverse set of variables. Derived 82 features from data to train the CNN model. 4.5. Trading Strategies They used the past 60 days’ data. So, their input matrix We compare the performance of our proposed DTF trad- dimension is 60X82. ing strategy with the Simple Trend Following, Buy-and- Hold, and CNN-based trading strategy in terms of % ac- 4.3. Experimental Setup cumulated return. In the CNN-based trading strategy Our experimentation grouped into two tasks. First, we buy action is taken when CNN predicts, the price will predicted the next day’s stock price trend at the close go up at the close of the next trading session 𝑑 + 1, and price of the next day trading session, this is a classifica- it will take sell action when CNN predicts the price will tion problem, as shown in the equation below. go down. Buy action suggestion ignored if an already long position is open similarly sell action ignored if an 1, if πΆπ‘™π‘œπ‘ π‘’_π‘ƒπ‘Ÿπ‘–π‘π‘’π‘‘+1 > πΆπ‘™π‘œπ‘ π‘’_π‘ƒπ‘Ÿπ‘–π‘π‘’π‘‘ already short position is open. π‘π‘™π‘Žπ‘ π‘  = { 0, else 4.6. Experimental Results We compare the classification results with the classifica- Experimentation in this work is grouped into two tasks. tion result of the baseline method and the other methods In the first task, we proposed CNN based binary classifier reported in the baseline paper, as shown in Table 2 and and compared the results of the classification with the Table 3 ([4]). classifiers in the baseline paper. In the second task, we Second, as per our proposed method, we created the introduced the DTF trading strategy using CNN based bi- DTF trading strategy using classification result of the nary classifier and simple Trend Following trading strat- proposed classifier and Trend Following trading strategy. egy. Also, compared the result of the proposed DTF We compared the result of the DTF trading strategy with Table 2 Average F-measure of all four trading strategy 1 2 3 4 5 6 Market PCA+ANN CNN-cor Technical 3D-CNNpred 2D-CNNpred DTF DJI 0.4283 0.39 0.415 0.4979 0.4975 0.53 NASDAQ 0.4136 0.3796 0.4199 0.4931 0.4944 0.55 S&P 500 0.4237 0.3928 0.4469 0.4837 0.4914 0.56 RUSSELL 0.4279 0.3924 0.4525 0.4846 0.5002 0.53 Table 3 Best F-measure of all four trading strategy 1 2 3 4 5 6 Market PCA+ANN CNN-cor Technical 3D-CNNpred 2D-CNNpred DTF DJI 0.5392 0.5253 0.5518 0.5612 0.5562 0.61 NASDAQ 0.5312 0.5498 0.5487 0.5576 0.5521 0.61 S&P 500 0.5408 0.5723 0.5627 0.5165 0.5532 0.58 RUSSELL 0.5438 0.5602 0.5665 0.5787 0.5463 0.58 trading strategy with the buy-and-hold, CNN-based, and 5.4. This comparison is shown in Table 4. The % Accu- simple Trend Following trading strategy. mulated return of the proposed DTF trading strategy In the first task, as mentioned in Section 5.3, we com- is considerably better than the other trading strategies pare the classification result of the proposed CNN-based mentioned in Table 4. The comparison of all four trading binary classifier with the baseline classifiers in terms of strategies including proposed DTF trading strategy in the macro-average and macro-best F-measure scores. We terms of % Accumulated return for index stocks DJIA, used the macro-average-F-measure comparison metric NASDAQ, S&P 500 and NIFTY is shown in Figure 5, Fig- instead of accuracy because the financial data has an ure 6, Figure 7 and Figure 8 respectively. Figure 9, summa- imbalanced class distribution [5]. The macro-average rizes the performance of these four trading strategies on F-measure score, and macro-best F-measure score of all the same index stocks in terms of % accumulated returns. methods, including the proposed classifier mentioned The maximum drawdown of the trading strategy rep- in Table 2, and Table 3 respectively. In both the Tables resents the historical risk associated with the trading column numbers 4, 5 are the two baseline classifiers. Col- strategy, so it should be minimum. The maximum draw- umn number 6 is the proposed classifier, and column down of the proposed DTF trading strategy is consid- numbers 1, 2, 3 are the classifiers reported in the baseline erably minimum than the maximum drawdown of the paper. Buy-and-Hold and CNN based trading strategies on all The proposed classifier outperformed the baseline clas- datasets. It is better than simple Trend Following trading sifiers and other classifiers reported in the baseline paper strategy on two datasets and approximately equal for the in terms of the average and best F-measure score. Our other two datasets. The proposed DTF method’s % Daily classifier outperformed the baseline classifier because a and % Annual Returns is better than all different trading deep learning method required extensive training data, strategies, as shown in Table 4. Similarly, the Sharpe and we used large training data compared to the baseline ratio of the trading strategy should be maximum, and method. Also, Their input matrix has 60 rows, i.e. 60 the Sharpe ratio of the proposed DTF method is better previous days, and we have used ten past days. Only than all other trading strategies, as shown in Table 4. recently trading days influence the stock price trend, and The skewness and kurtosis of the proposed DTF method they used too many last days’ data in the input matrix. on all datasets are reasonably acceptable. The volatility, We also used the feature to capture non-trading time i.e. standard deviation of the all four trading strategy, is information. approximately the same. In the second task, the performance of the proposed DTF trading strategy compared with the performance of the CNN-based, simple Trend Following, and buy-and- hold trading strategies on the American index stock DJIA, NASDAQ and S&P 500; the Indian index stock NIFTY us- ing performance evaluation metrics mentioned in Section Table 4 The performance comparison of the all four trading strategy on the experimental test dataset of four index stocks Index stock Performance evaluation metrics Proposed Buy-and- CNN Trend Fol- Model Hold lowing % Accumulated Return 26.88 15.70 -15.57 24.01 % Average Annual Return 18.56 10.84 -10.75 16.58 % Maximum Drawdown 14.10 17.54 17.31 14.12 S&P 500 Standard deviation 0.835 0.855 0.737 0.842 % Average Daily Return 0.074 0.043 -0.043 0.066 Sharpe Ratio 1.581 0.946 -1.159 1.426 Skewness -0.188 -0.882 -0.358 -0.241 Kurtosis 2.650 2.434 9.904 2.369 % Accumulated Return 31.10 16.37 5.19 28.11 % Average Annual Return 21.07 11.09 3.51 19.04 % Maximum Drawdown 14.28 16.33 12.67 14.18 DJIA Standard deviation 0.809 0.847 0.707 0.812 % Average Daily Return 0.084 0.044 0.014 0.076 Sharpe Ratio 1.825 0.975 0.458 1.669 Skewness -0.114 -0.802 0.713 -0.161 Kurtosis 2.636 2.180 3.966 2.469 % Accumulated Return 33.93 15.29 -11.67 32.96 % Average Annual Return 23.11 10.41 -7.94 22.45 % Maximum Drawdown 17.12 21.90 22.77 17.12 NASDAQ Standard deviation 1.107 1.143 0.994 1.113 % Average Daily Return 0.092 0.041 -0.031 0.089 Sharpe Ratio 1.487 0.754 -0.642 1.446 Skewness -0.296 -0.583 -0.493 -0.219 Kurtosis 2.707 2.357 6.092 2.604 % Accumulated Return 23.74 17.35 -5.41 12.29 % Average Annual Return 12.28 8.98 -2.80 6.36 % Maximum Drawdown 14.28 14.55 20.08 15.14 NIFTY Standard deviation 0.810 0.826 0.790 0.834 % Average Daily Return 0.049 0.035 -0.011 0.025 Sharpe Ratio 1.288 0.874 -0.149 0.725 Skewness 0.201 0.264 1.359 0.161 Kurtosis 1.982 1.860 15.23 1.804 Figure 5: The comparison of the performance of all four trad- Figure 6: The comparison of the performance of all four trad- ing strategy on the test data of DJIA index stock using % ing strategy on the test data of NASDAQ index stock using % accumulated return accumulated return Table 5 Description of features S.N. Feature Description Source/Formula 1. Close price Daily close price of the stock Yahoo Finance 2. Open price Daily open price of the stock Yahoo Finance 3. Week day Day of the week Datetime Library 4. RSI Relative Strength Index TA Library 5. R Williams Percent Range (%R) TALibrary 6. CCI Commodity Channel Index TA Library 7. RSI trend if RSI>70 then 2, if RSI<30 then 1 else 0, 8. R trend if R>-100 then 2, if R>100 then 1 else 0, 9. CCI if CCI<70 then 2, if CCI<30 then 1 else 0, πΆπ‘™π‘œπ‘ π‘’π‘‘ βˆ’ πΆπ‘™π‘œπ‘ π‘’π‘‘βˆ’1 10. MOM1 One day % return [( ) βˆ— 100] πΆπ‘™π‘œπ‘ π‘’π‘‘βˆ’1 11. MOM2 Two days % return formula is similar to S.N. 6 12. MOM3 Three days % return formula is similar to S.N. 6 𝑉 π‘œπ‘™π‘’π‘šπ‘’π‘‘ βˆ’ 𝑉 π‘œπ‘™π‘’π‘šπ‘’π‘‘βˆ’1 13. VC1 % change in volume compare to volume one day before [( ) βˆ— 100] 𝑉 π‘œπ‘™π‘’π‘šπ‘’π‘‘βˆ’1 14. VC2 % change in volume compare to volume two days before formula is similar to S.N. 9 15. VC3 % change in volume compare to volume three days before formula is similar to S.N. 9 𝐻 π‘–π‘”β„Žπ‘‘ βˆ’ 𝑂𝑝𝑒𝑛𝑑 16. OHC % change between open and high price [( ) βˆ— 100] 𝑂𝑝𝑒𝑛𝑑 𝑂𝑝𝑒𝑛𝑑 βˆ’ πΏπ‘œπ‘€π‘‘ 17. OLC % change between open and low price [( ) βˆ— 100] 𝑂𝑝𝑒𝑛𝑑 𝑂𝑝𝑒𝑛𝑑 βˆ’ πΆπ‘™π‘œπ‘ π‘’π‘‘ 18. OCC % change between open and close price [( ) βˆ— 100] 𝑂𝑝𝑒𝑛𝑑 𝐻 π‘–π‘”β„Žπ‘‘ βˆ’ πΏπ‘œπ‘€π‘‘ 19. LHC % change between low and high price [( ) βˆ— 100] πΏπ‘œπ‘€π‘‘ 1 𝑑 20. SMA5 Simple moving average n=5 days close price [ 𝑛 βˆ‘π‘–=π‘‘βˆ’π‘› πΆπ‘™π‘œπ‘ π‘’π‘– ] 21. SMA10 Simple moving average n=10 days close price formula is similar to S.N. 16 22. SMA15 Simple moving average n=15 days close price formula is similar to S.N. 16 23. SMA20 Simple moving average n=20 days close price formula is similar to S.N. 16 24. SMA25 Simple moving average n=25 days close price formula is similar to S.N. 16 25. EMA5 Exponential Moving Average n=5 days close price EMA 26. EMA10 Exponential Moving Average n=10 days close price EMA 27. EMA15 Exponential Moving Average n=15 days close price EMA 28. EMA20 Exponential Moving Average n=20 days close price EMA 29. EMA25 Exponential Moving Average n=25 days close price EMA 𝑂𝑝𝑒𝑛𝑑+1 βˆ’ πΆπ‘™π‘œπ‘ π‘’π‘‘ 30. NT Non trading period information [( ) βˆ— 100] πΆπ‘™π‘œπ‘ π‘’π‘‘ 5. Conclusion and future trend predicted by the CNN-based classifier. This combination reduces the risk based on the only pre- Owing to the noisy and non-stationary behavior of the diction. We experimented with the proposed DTF trading stock price trend, the trading strategy based only on the strategy on the American and the Indian index stocks and prediction is risky. The performance of the Trend Follow- compared the results with the CNN-Based, simple Trend ing trading strategy depends on the stock price trend after Following, and Buy-and-Hold trading strategy. The pro- trading action is taken but the Trend Following strategy posed DTF model outperformed the other three trading can not predict the future stock price trend. In this paper, strategies in terms of percentage Accumulated Return, we proposed a modified Trend Following trading strat- Maximum Drawdown, Average return, and the Sharpe egy named Deep Trend Following (DTF) trading strategy, ratio. which is a combination of CNN-based prediction with We also compared our CNN-based binary classifier Trend Following trading strategy. with the baseline CNN-based binary classifier, and it The main contribution of this research work is that it outperformed the baseline classifier in terms of macro- combines the CNN-based prediction with the Trend Fol- average and macro-best F-measure scores. It performed lowing strategy in which the Trend Following strategy better because we have considered the non-trading pe- will take a trading decision based on the current trend riod information, and we have taken more training data References [1] E. F. Fama, L. Fisher, M. C. Jensen, R. Roll, The adjustment of stock prices to new information, In- ternational economic review 10 (1969) 1–21. [2] S. Fong, Y.-W. Si, J. Tai, Trend following algorithms in automated derivatives market trading, Expert Systems with Applications 39 (2012) 11378–11390. [3] J. Chakole, M. Kurhekar, Trend following deep q- learning strategy for stock trading, Expert Systems (2019) e12514. Figure 7: The comparison of the performance of all four trad- [4] E. Hoseinzade, S. Haratizadeh, Cnnpred: Cnn-based ing strategy on the test data of S&P 500 index stock using % stock market prediction using a diverse set of vari- accumulated return ables, Expert Systems with Applications 129 (2019) 273–285. [5] H. Gunduz, Y. Yaslan, Z. Cataltepe, Intraday pre- diction of borsa istanbul using convolutional neu- ral networks and feature correlations, Knowledge- Based Systems 137 (2017) 138–148. [6] A. ArΓ©valo, J. NiΓ±o, G. HernΓ‘ndez, J. Sandoval, High-frequency trading strategy based on deep neu- ral networks, in: International conference on intel- ligent computing, Springer, 2016, pp. 424–436. [7] S. Alonso-Monsalve, A. L. SuΓ‘rez-Cetrulo, A. Cer- vantes, D. Quintana, Convolution on neural net- works for high-frequency trend prediction of cryp- Figure 8: The comparison of the performance of all four trad- tocurrency exchange rates using technical indica- ing strategy on the test data of NIFTY index stock using % tors, Expert Systems with Applications 149 (2020) accumulated return 113250. [8] H. Chung, K.-s. Shin, Genetic algorithm-optimized multi-channel convolutional neural network for stock market prediction, Neural Computing and Applications 32 (2020) 7897–7914. [9] O. B. Sezer, A. M. Ozbayoglu, Algorithmic financial trading with deep convolutional neural networks: Time series to image conversion approach, Applied Soft Computing 70 (2018) 525–538. [10] Z. Zhang, S. Zohren, S. Roberts, Deeplob: Deep con- volutional neural networks for limit order books, IEEE Transactions on Signal Processing 67 (2019) 3001–3012. Figure 9: Performance of all four trading strategy in terms of [11] S. Ghoshal, S. Roberts, Thresholded convnet en- % accumulated return of experimental test dataset of all four sembles: neural networks for technical forecasting, index stocks Neural Computing and Applications (2020) 1–14. [12] Y. LeCun, Y. Bengio, et al., Convolutional networks for images, speech, and time series, The handbook compare to the baseline classifier. We experimented of brain theory and neural networks 3361 (1995) with the proposed classifier and DTF trading strategy 1995. on daily stock market data, in the future its performance [13] Y. LeCun, L. Bottou, Y. Bengio, P. Haffner, Gradient- on the small frequency data such as hourly, 15-minutes, based learning applied to document recognition, 5-minute data should have been experimented with. We Proceedings of the IEEE 86 (1998) 2278–2324. have selected the proposed CNN architecture by exper- [14] M. D. Zeiler, R. Fergus, Visualizing and under- imenting with different architectures, need to choose standing convolutional networks, in: European the CNN architecture by the more robust method in the conference on computer vision, Springer, 2014, pp. future. 818–833. [15] G. S. Tandel, M. Biswas, O. G. Kakde, A. Tiwari, H. S. Suri, M. Turk, J. R. Laird, C. K. Asare, A. A. Ankrah, N. Khanna, et al., A review on a deep learning perspective in brain cancer classification, Cancers 11 (2019) 111.