Market Price Signal Prediction Based On Deep Learning Algorithm

: Nowadays, many people are venturing into market trading and investment, thus producing many new traders and investors worldwide. The main goal is to gain profit and prevent loss. Most of them are researching global investment opportunities to learn about the market, especially to predict market prices in the future. However, it will become challenging as the financial indicators are very complicated, and it will require a lot of experience and knowledge. The price movement in the price chart also is hard to be predicted when using a fractal indicator. Recently, machine learning and deep learning are the methods for stock market prediction used widely and show the high accuracy of prediction. This paper proposed a deep learning algorithm, Convolutional Neural Network (CNN), to predict the market price signal prediction for daily timeframe charts. This paper aims to develop a market price signal predictor system using the proposed model of deep learning. This paper provided a few literature reviews that related to this research. The evaluation of the signal prediction accuracy using the proposed model is recorded.


Introduction
A stock market is an open market for the exchanging of organization stock at an agreed cost.It involves the investing between two investors, so it is also known as the Secondary Market [1].The stock market is significantly influencing the current economy.The performance of the stock market reflects the country's economy.If the stock market is good, the stock market's index value will increase, which is a good indicator that the country's economy is growing [2].The stock exchange is one of the important components of a stock market.A stock exchange is when traders and brokers are offered trading facilities by an organization to trade stocks [1].Exchanges are commonly classified as national, regional, and over-the-counter markets [3].
According to [2], many theories have been developed to uncover the great fortune in the stock market, and among the earlier theories for the stock market predicting are the Efficient Market Hypothesis (EMH) and Random walk theory.Efficient Market Hypothesis (EMH) states that a stock's market price collects all information about that stock at any point in time.In other words, the stock is being valued accurately until something changes [4].According to [2], Efficient Market Hypothesis (EMH) states that the market is efficient, and all of the information is being reflected fully in the price.According to [5], random walk theory cannot be predicted by past actions in which directions or future steps, and [2] also state that random walk theory, the stock market price fluctuates randomly, and there is no dependency and relationship in the fluctuation of prices.
[2] also state that many techniques have been discovered to overcome these traditional prediction theories, such as fundamental analysis and technical analysis.Fundamental analysis is a stock price technique based on economic factors and their histories, such as annual reports, accounting, cash flow statements, and sales reports.
Technical analysis is a time-series approach for predicting stock markets using charts as the primary tool based on historical data [6].

Related Works
Machine learning was one of the famous techniques for stock market prediction.There are various types of machine learning algorithms, such as support vector machines (SVM), artificial neural networks (ANN), decision trees, and data mining [7].Support vector machine (SVM) and artificial neural network (ANN) is the machine learning algorithm that has been used widely to predict the stock market price [8].[9] proposed ANN to predict one day ahead of the Nasdaq-100 index.Adobe, Apple, Cisco, Microsoft, Yahoo, and Oracle are six listed companies in the Nasdaq-100 index.The historical data of the companies were used to forecast the value of the index in this work.A scaled conjugate gradient algorithm was used to train the ANN.In this work, a dataset of 24-month starting from 22 March 1999 to 20 March 2001 was used.The result from ANN prediction in this work showed a good result which is 0.021 until 0.034, the value of root mean square error (RMSE) for the predicted stocks.
[10] proposed the echo state networks (ESN), the subclass of recurrent neural networks (RNN), to forecast the S&P 500 stock prices.This work used price, moving averages, and volume as features.The technique outperforms the Kalman Filter technique with a 0.0027 value of meagre test error.They tested the algorithm on 50 other stocks to generalize and confirm the result.They reported that the results performed better against state-of-the-art techniques.
Long Short-Term Memory (LSTM) networks have shown a lot of promises for time series prediction.[11] implemented three different recurrent neural networks (RNN) models: basic RNN, the LSTM, and the gated recurrent unit (GRU) to evaluate which variant of RNN performs better on Google stock price.The results showed that the LSTM performed better than others with a 72% accuracy on a five-day horizon.[12] forecast Nifty prices by applying the LSTM and with open-high-low-close (OHLC) features.The test data results in terms of daily percentage changes show that RMSE of 0.00859 has been achieved with the LSTM.
In summary, the market price can be predicted by using any method.Previous methods and techniques have shown that market price prediction is less effective, and sometimes the prediction failed.It was a risk that investors will take to follow the previous techniques.If they are lucky, they will get profits, but they will face the risk of loss if they are unlucky.Using deep learning algorithms, the market price signal prediction will be more accurate, and the risk of loss will be reduced.Supervised learning is one of the machine learning categories that can be implemented for stock market prediction as supervised learning lets the data be collected and produces a data output from previous data.The training process continues until a satisfying level of accuracy is achieved on the training data.

Technology Used
For our prediction system, we are implementing a Convolutional Neural Network (CNN) algorithm.This algorithm is applied in problems related to image and video object detection.CNN is known to have zoom-resistant angles and other spatial transformations.The architecture of CNN allows objects to be detected anywhere in the scene equally effectively.When implemented to trading, the CNN will improve the recognition of trading patterns on a price chart.

Proposed Architecture
Convolutional networks have two new layer types compared to the fully connected perceptron, the convolution layer or filter layer and the subsampling layer.These two layers are alternating to remove noises and select the main components in the data source while minimizing the data dimension.For decision making, this data then input into a fully connected perceptron.The CNN structure will be graphically illustrated in Figure 1.We may use a few groups of alternating convolution layers and subsampling layers.

Input Data Parameters
Data input should be determined as input into our neural network to evaluate the network operation.In this project, four standards indicators, Relative Strength Index (RSI), Commodity Channel Index (CCI), Average True Range (ATR), and Moving Average Convergence Divergence (MACD), will be used as indicator parameters with standard and default setting.All input parameters will be as shown in Table 1.

Convolutional Layer
The convolutional layer is responsible for object identification in the data source array.This layer performs sequential mathematical data convolution with a small pattern (filter) serving as the convolution kernel.Convolution is an operation of functional analysis toward the function of two (f and g) parameters, generating a third function which is the cross-correlation function f(x) and g(-x).With an inverse and moved copy of another function, the convolution operation can be defined as a similarity.In other words, the convolution layer finds a pattern element in the entire original sample.At each cycle or iteration, the template is shifted along with the initial data array with a given phase, which size can be from "1" up to the pattern size.If the offset phase size is less than the size of the pattern, this convolution is considered overlapping.
The convolution operation generates features that show the "similarity" in each iteration of the original data with the required pattern.Data normalization uses activation functions.The array size will become less than the original array. − The most important is that when designing a neural network, the patterns are not defined but are chosen in the learning process.

Subsampling Layer
The subsampling layer is used to minimize the volume of the feature array and to filter noise.The usage of this iteration assumes that the existence of similarities between the original data and the pattern is primary, whereas the exact coordinates of the function in the original data array are not so significant.This offers a solution to the problem of scaling since the distance of the desired objects is certain to be variable.At this point, the data are compacted in each "window" by holding the maximum or average value.So, for any "window" data, only one value is saved.The operations are carried out iteratively, and for each new iteration, the window is shifted by a given step.For each function array, data compaction is managed separately (Dlalisa et  A subsampling layer with a window and a step equal to 2 are often used.This causes the dimension of the function array to be halved.However, larger windows can be used while overlapped compaction iterations (when the step size is less than the window size) or not.
The outputs of the subsampling layer include smaller arrays depending on the complexity of the problems, it is possible to use one or more groups of the convolutional layer and subsample layer after the subsample layer.Their building concepts and features refer to the layer mentioned above.In general, the arrays obtained for all filters are collected in a single vector after one or more convolution and compaction groups and are fed into a multi-layer vision for the neural network to decide.

Findings
In this project, the expert advisor was launched on a candlestick chart of the MetaTrader 5 terminal for 100 epochs.The evaluation was conducted for every 10 epochs of training, with the duration and accuracy being recorded.Table 2 shows the summarization of 100 epochs, and Figure 2 shows the Graph of accuracy (%) vs. epoch result.From the result shown, the accuracy of prediction was increasing with the increasing of epoch.The total time taken to complete the 100 epochs of training is 2 hours 28 minutes 53 seconds, with the study period of 2 years.Even though the accuracy is relatively low, it can be said that the Convolutional Neural Network (CNN) algorithm has the potential to be used as a signal prediction.Simultaneously, the results also show that the CNN will need additional time to increase the accuracy and make the algorithm more effective.

Conclusion
As a project summarization, this project is about learning the type of algorithm to understand the ability of a certain algorithm for market price signal prediction.For this project, the signal prediction was implemented as an expert advisor to analyse any chart for trading purposes.In this project, the chosen algorithm, Convolutional Neural Network (CNN), had performed its best in getting the accuracy to be implemented in the chart analysis for price signal prediction in trading and investing.Even though most researchers recommend the CNN algorithm for recognition project, it can also be implemented for prediction.It was proven that CNN also has a potential in performing prediction activity.We can see a successful price signal prediction performed as an expert advisor in the chart from this project.The expert advisor succeeds in predicting the chart's signal, whether it is going to uptrend or downtrend movement but with low accuracy.To gain high accuracy, more time is needed to train the data.
Due to time constraints, the expert advisor developed only tested on MetaTrader 5 trading software for Windows version, which is not being tested for other platforms and operating systems.This project also required a connection with the Internet since the dataset trained is real-time.Another limitation is that the signal predicted becomes irregular after the training process for a certain number of epochs depends on the chart's time frame.After closing the trading platform window, the epochs will be reset and need to be train from beginning when reopening the platform again.Lastly, this project is only based on the technical analysis and does not include the fundamental analysis, so the predicted signal might not be very accurate because the chart's movement also depends on the fundamental analysis.Future work's main recommendation is to make the expert advisor available for all trading platforms and operating systems.Furthermore, this project also needs to be improved in terms of the analysis, which the fundamental analysis should be included to make the prediction more accurate.On top of that, the project also needs to enhance the time consuming for retraining the dataset, which it should just continue the training from the previous close or shut down.

Table 1 :
Input parameters