YOLO Object Recognition Algorithm and ‘‘Buy-Sell Decision’’ Model Over 2D Candlestick Charts

,


I. INTRODUCTION
Today, artificial intelligence implementations are employed quite commonly in the financial field, especially in the stock and market transactions with the advanced developments in technological areas. Moreover, these developments have led to the increase in the number of both the financial instruments (stock, ETF (Exchange Traded Funds), foreign currency, gold, oil etc.) and the investors. During the evaluation of savings, investors, whose main objective is to earn, have faced various investment options especially with the increasing financial instruments. Via these developments, the necessity to correctly analyze the financial market instruments to be The associate editor coordinating the review of this manuscript and approving it for publication was Tallha Akram . invested in has arisen. Therefore, in terms of the investors who act with the logic of earning by buying over a low price and selling over a high price, the analysis of the price changes in financial markets is an important topic of research [1].
Especially the prediction and classification models based on deep learning algorithms are seen to have been performing very well in the fields of image, video and audio processing over the recent years. [2]- [7]. However, the application of deep neural networks in financial prediction models is still limited. This results from the necessary to have and analyze the behavioral information of the factors, which might affect the investment element together with the past behaviors of the investment element in the decision-making stage.
Today, there are two main analysis methods known as financial analysis indicators in the analysis of time series data, which affect the buying-selling decisions of the financial market investors. These are basic analysis and technical analysis.
The models created with artificial neural networks, support vector machines, machine learning algorithms and hybrid solutions, which basic and technical analysis approaches are based on, are used in the analysis of the financial data. Recently, deep learning methods have also started to be used in the analysis of the financial data, although limited, with the development of deep learning algorithms, and quite successful results have been obtained. These studies are examined in the literature section. Some of these methods consist of multilayer artificial neural networks [8], [9], recurrent artificial neural networks, Long Short-Term Memory Networks [10], [11], restricted Boltzmann machine [12] and deep thinking networks, which are the mainly used deep learning algorithms.
The proposed model is based on the object recognition and classification algorithm in general. Because the model does not include numerical operations, it is quite different from the prediction models based on the especially CNN-based deep learning method, which had cited during the literature scan. It enables the identification of Buy and Sell points as objects for the investment tool using the charts. For the model, which we constructed based on the object recognition and classification algorithms, firstly, labels were created, and the system was treated using these labels. As a result, it was ensured that the buy and sell points were recognized by the model on the charts similar to the way an autonomous vehicle recognized the road lines, traffic signs and other vehicles or pedestrians; it was also ensured that this operation was detected using the visual materials and the decisions were made based on the visual materials as well. This model, which we have not encountered before during the literature scan, operates on the candlestick chart view of a time series unlike the other prediction models. Additionally, it is a completely objective study since the labeling process was carried out using the visual materials. The purpose of keeping the study distant from mathematical methods and numbers is the perspective that lies on the basis of the artificial intelligence system. Even though the finance sector is composed of time series, which we call the sequential numbers, they are interpreted through the charts that represent these series. Looking at these charts, the human eye can immediately visualize any analysis that it cannot make using numbers. Human intelligence can make better decisions by using graphic presentations, which it can interpret upon seeing, rather than the numbers. Therefore, when the finance sector, which is the framework of the article, is analyzed, all the formations, indicators and technical analysis studied in terms of trading decisions are carried out on the charts that are constructed entirely by numbers. However, it should be considered that all the decisions made over the charts were the analyses, which were obtained from numerical results using the algorithms and transferred to a visual.
Based on this approach, the numerical expressions were completely abandoned, and a deep learning-based based object recognition classification model, which made decisions solely through candlestick charts constructed by financial time series, was designed.
In this study, the ''Buy-Sell'' decision model, which will decide on the future trend direction of an investment element and make this decision for short-term trends, has been suggested. The aim was to enable this decision-making without the need for time series except for the 2D visual candlestick charts. The main objective of all the investors investing in the financial sector is to make profit by buying at a low price and selling at a higher price. This model, which was created in the light of this aim, is a simple but effective model that could also be used by individual investors as an additional investment analysis tool in the analysis on all investment tools using candlestick charts such as the stock exchange market, parity analysis, index analysis and share analysis of the other stock exchanges.
Consequently, the proposed model can make successful predictions on its own and the main purpose of using the model is to present a foresight strengthening the ''Buy-Sell'' decisions to be made in the decision-making process following the basic and technical analyses. The system conclusion can be demanded for the sake of the final decision for a stock, which has been basically and technically analyzed, and a portfolio can be created with an early demand on the system and then the execution of the basic and technical analyses for the stocks signaling 'buy'.
In this context, the literature information is stated for similar studies in the first chapter, detailed information is given about the proposed method in the second chapter, the details are put forward for the data set used in the study and the proposed model in the third chapter and the sample implementation outputs of the study are mentioned in the fourth chapter. In the last chapter, a general evaluation of the study was made.

II. RELATED WORK
There are various methods, which are employed to make predictions about future values and formulate policies by using the past data from the time series analyses. Each method has different advantages and disadvantages. In this context; Khoa et al. (2007) proposed neural network-based methods for stock price predictions. In their study, they used both the back-propagation neural networks and simply recurrent neural networks and concluded that the simply recurrent neural network was better due to its ''capturing capabilities'' [13].
In this paper, Chen et al. (2016) focused on the timeseries data processing and prediction in financial markets. The major contribution of this paper is to improve the algorithmic trading framework with the proposed planar feature representation methods and deep convolutional neural networks (CNN) [14].
In his study, Özçalıcı (2017) considered 12 technical indicators, which belonged to past price and volume information related to Goodyear, Amazon.com, Wal-Mart and SP500 index, as the input variable through the extreme learning machines (ELM) and artificial neural networks (ANN). As the output variable, they used the closing prices of the next day [15].
In their studies, Singh and Srivastava (2017) used deep learning methods for stock prediction and evaluated the performance of the method in Google stock price multimedia data (chart) obtained from NASDAQ [16].
In their study, Bao et al. (2017) presented a new deep learning framework in which wavelet transforms (WT), stacked autoencoders (SAE) and long short-term memory (LSTM) were combined for stock price prediction [17].
Huy et al. (2017) developed a new prediction model based on both online financial news and past stock price data to predict stock movements in advance [8]. Hu et al. (2017) proposed a novel investment decision strategy based on deep learning. Key idea is to endow an algorithmic strategy with the ability to make decisions with a similar kind of visual cues used by human traders. To this end we apply Convolutional Auto Encoder (CAE) to learn an asset representation based on visual inspection of the asset's trading history [18]. Chung and Shin (2018) aimed at developing a new stock market prediction model through a mixed approach including a long short-term memory network (LSTM) and genetic algorithm (GA) by using the available financial data [11].
Liv et al. (2018) used the Attention-Based Multi-Input LSTM method for stock price prediction [19].
In their study titled ''Deep Active Learning for Object Detection'', Roy et al. (2018) proposed the active learning approaches, which produced cutting-edge technological results in the object detection using only a part of the training images [20].
In their study, Roy et al. (2018) proposed a called the feature fusion long short-term memory-convolutional neural network (LSTM-CNN) model, that combines features learned from different representations of the same data, namely, stock time series and stock chart images, to predict stock prices [21].
In their study, Sezer and Özbayoğlu (2019) suggested a non-traditional approach for stock prediction using the convolutional neural network to determine the ''Buy'', ''Sell'' and ''Hold'' scenarios directly over 2-D stock bar chart views without presenting any additional time series related to the basic stock [22].
In their respective price predictions with Arima, LSTM and Hybrid models, Soy Temür et al. (2019) estimated the housing sales in Turkey for the future [23].

III. METHODOLOGY
The proposed model is based on the interaction between YOLO, which is a real-time object recognition algorithm, and the candlestick representation of the financial values suggested by the Japanese for the first time in the 16th century. YOLO is a deep learning-based algorithm used especially in autonomous systems and all image-related studies of today's popular technology [27]. In the study, annual candlestick charts of BIST-TUM stocks were utilized, and tests were also executed on BIST-TUM shares.
In this part of the study, two main topics forming the skeletal structure of the designed model signed are discussed. The first one is the prediction methods used in the financial field and information about the usage of the methods. The other topic are the basic principles of the object recognition model, which is implemented via deep learning methods which have become popular in the field of artificial intelligence recently.

1) BASIC ANALYSIS
Basic analysis is used to predict the estimated stock profit and risk. It is an analysis method that was developed by Graham and Dodd with regard to the evaluation of all kinds of information about the stock and the enterprise which it belongs to [24]. In short, it can be expressed as researching the value of an enterprise by making use of the information disclosed to the public [25].

2) TECHNICAL ANALYSIS
Technical analysis is described as the prediction methods for possible price movements in the future by investigating the past price movements in financial markets. This method appeared since news feeds were eventually reflected on prices. The most applied methods while employing technical analysis can be stated as follows [26].

a: INDICATORS
The markers of the technical analysis are called ''indicators''. They help investors by giving them a buy or sell signal related to the stocks. Price and volume data are utilized to calculate the indicators. Using them alone for buying and selling may not always produce accurate results. For this reason, it is not right to make a ''Buy-Sell'' decision through a single technical analysis method. On the other hand, using too many indicators can also lead to wrong buying and selling decisions at times. The names of the indicators used frequently by investors are given below [27].  Figure 1, an RSI indicator operation of a sample stock is exhibited. The RSI Indicator was published by J. Welles Wilder in 1978 and it is used to detect that the prices of the financial instrument are overbought and oversold [28]. The RSI gets a value between 0 and 100. Two boundary lines are drawn at levels 30 and 70. At these levels, the current movement is expected to change its direction.
• Above the level 70: Indicates the overbought zone of prices. At these levels, the current movement is expected to change its direction. As shown in the figure, there is a graphical activity that complies with the specified rule. This presents the indicator success described as an example.

b: FORMATIONS
In the analysis of the market, the shapes which give the investor an idea about the trend changes or continuation and the area of movement of the price are named as formation. The formations are divided into two types as trend reversal formations and trend continuation formations. For example, the shoulder head shoulder (shs) formation given in Figure 2 is the trend reversal formation indicating that a rising trend is coming to an end. It consists of 3 hills and the head is in the middle. After the left shoulder is formed, the rally starts again with the purchase coming from the neck level where the decrease in prices end, and the prices cross the left shoulder level. In this case, the emerging hill is named as head. Prices decrease again and return to the neck level. For the last time, an increase is observed in prices, and this increase is usually at or below the left shoulder. Here, the right shoulder is formed. The difference between head and neck is found, and the goal of the formation is determined by subtracting this difference from the neck level [29].

c: CANDLESTICK ANALYSIS
Another different prediction method which will be included in the technical analysis method as a class is candlestick formations. This first type of technical analysis is different from the technical analysis approaches suggested by Charles Dow, who was the leader of the modern technical analysis theories in 1900s, however, it is based on the similar principles [30]. Homma, a famous rice trader known in the Japanese city   Sakata, was the person who caused the candlesticks to be developed and turn into a significant technical analysis. It is a method used by the Japanese traders to predict the future prices by looking at the prices in rice trading contracts [31]. The fact that it has been used by more people over the years, studies have been conducted on it and there have been advancements in graphics technologies has helped it gain its current form. This chart type is similar to the bar chart given in Figure 3.
The presence of an opening value is a prerequisite for the creation of a candlestick chart. In addition to the opening price, the closing price, the highest and the lowest values within the day are also used to create a candlestick chart. The most distinct difference of the candlestick charts from the bar charts is that they have a body. As seen in Figure 4, the thick part of the candlestick shows the distance between the opening and closing values of the session. This distance has maximum and minimum limits in markets such as BIST. VOLUME 8, 2020 The green body candlestick shows that the closing price is higher than the opening price, that is, the demand is high; the red body candlestick indicates that supply is high, in other words, there is a session in which prices open higher but close lower [32]. The line representations at the ends of the bodies represent the shadow. The inner side of the candlestick can be black and white. This does not change meaningfully.
Because it has an opening and a closing limit, the body of the chart qualifies to be able to represent an object in the study. Moreover, the difference it displays in colors besides the directions indicates its advantage as an object when compared to the other charts. The fact that a colored body is visually more advantageous than the line supported the use of candlestick charts in the study.

3) CONCEPT OF TREND
Simply, the trend is the direction of the moving market. Trends appear at all times. They can be observed on monthly, weekly, daily and hourly charts. Trends can be observed in daily operations from 8-hour charts to 1-hour charts or from 1-hour charts to 5-minute charts [33]. Trends in short-term charts can be ignored in a position taken for a long term (for example, movements drawn for a 5-minute time frame), or on the contrary, trends in long-term charts can be ignored in a position taken for a short term. An investor should be able to identify the trend by making use of a time frame chart which is 4-6 times longer than the time frames he is used to employing in his analysis. For instance, if the analyst performs an analysis by using a 1-hour chart, he can determine the trend by using 4-hour charts or if he conducts an analysis by using a 4-hour chart, he can determine the trend by using a daily chart [34].
This section marked with a green directional arrow on the candlestick chart belonging to a stock given in Figure 5 clearly presents a certain upward trend in parallel with the green arrow direction. Similarly, a downward trend marked with a red directional arrow is seen following this upward trend in the same chart [35].

Dow Jones is an index traded on the New York Stock
Exchange and consists of the stocks of the world's 30 largest companies. Besides being the biggest index in the world, it is also one of the most popular indices. Developed by Charles Dow, who is known as the ancestor of the ''Modern Technical Analysis'', the DOW Theory refers not only to technical analysis and price movements but to also market philosophy [30]. According to the Dow theory, it means that prices are underestimated if the prices of an investment element seen in Figure 6 are in zone 1. The investors who cannot see the future think that the stock is on a horizontal course. For buying, they wait for the establishment of a decision in terms of basic or technical analysis.
The prices which slowly moved upwards over time reached the zone of attention and then switched to the zone 2. Investors who can buy from the zone 1 make a profit in this zone and trust the investment element, because prices have increased and even reached the peak. For investors, who believe that the price can increase more, zones 3 and 4, where they are situated, are among the risky zones. A profitable sale has been realized for the investors who can sell in zones 3 and 4. At this point, however, a threat has occurred for the investors who have not received a 'Sell' signal or have made a new purchase, and investors have taken more risks with a hope that prices will move upwards again at the end of the zone 4. Now, the prices that have reached the zone 5 are worrying, although the situation is not bad for investors who bought from zones 1 and 2 but did not sell, they have missed a good chance. On the other hand, investors who bought from the zones 3 and 4 made a loss. When all these circumstances   are considered, decisions to make the best profit with the recommendations of 'Buy' in the zone 1 and 'Sell' in the zones 3 or 4 are quite successful for an investor. In general, the purpose of the indicator and formation implementation operations in the technical analysis methods used today and financial markets are in this direction. Moreover, financial companies make great investments for this purpose, and investors spend quite many resources.
In Figure 7, small trends, secondary trends and main trends belonging to the time series of an investment instrument are seen. It can be interpreted for these trends that they prove the accuracy of the Dow Theory. However, here, the real purpose is not to detect the directions of these trends which are seen in the past just like a history commentator, but to make real-time predictions and develop a strategy to generate profits with the experience gained from the interpretations.
There are significant price levels which pause, stop and mostly return an investment instrument from its progress over a chart. If the human nature that enables the price movements strictly change the investment decisions at certain levels over the chart, price levels will definitely take it into account. The movement, which faces an important obstacle during its FIGURE 9. General diagram of YOLO Object detection [56].
progress in the historical time frame and does not go beyond a certain price level, stores this point in its memory as historical development and tends to act similarly when it meets the same price level again. The price position of the significant points, where the prices of the investment instrument will stop at while rising, on the horizontal plane is called resistance; the obstacle to be encountered while falling is called support [34].
The characteristic tendencies of the support and resistance levels related to the approaching price produce interesting positional opportunities for the investor. This is because the generally experienced behavioral mechanics of the price movement at these levels can put forward the opportunity to earn money with simple positions [37].
Consequently, a time series chart has trends. This situation means that the investment instrument will rise and fall at certain points unless the investment instrument is manipulated. It is thought that the collection of the information about the behaviors of an investment instrument and the interpretation of this information for the future after everything is over will contribute to the proposed strategy. Therefore, these circumstances have been turned into labels for the model in the study by benefiting from the representation of different characteristic price properties at the past resistance and support points of the investment instruments.

B. OBJECT DETECTION WITH DEEP LEARNING
Convolution Neural Networks (CNN) are deep, feed-forward artificial neural networks that have proven themselves in the fields of image recognition and image classification, which are widely used in analyzing visual images. They have proven to be quite successful in recognizing faces, objects and road signs, and make significant contribution to the development of robotic and autonomous systems [38]- [40]. The first CNN is the architecture called LeNet, which was presented by Yann LeCun in 1988 and continued to be improved until 1998 [41].
In the Large Scale Visual Recognition Competition (Ima-geNet) held in 2014, almost all of the teams which received the most successful rankings in the criteria of object classification and detection with millions of images and hundreds of object classes basically used the CNN algorithms [42]. In 2015, a multi-layer CNN showed its ability to capture faces in wide-angle ranges including reverse faces. This network was trained on a database containing 200.000 images with faces in various angles and directions and 20 million images without faces [43].
The CNN-based YOLO architecture, whose general diagram is presented in Figure 9, has been one of the most popular algorithms used in the field of object classification in recent years.
YOLO is a structure, which is faster and more successful in object recognition when compared to its competitors. [56].
Accuracy and sensitivity, which are the most important factors in object detention and prediction as in the autonomous vehicles, are not enough on their own. For a tool to adapt to the real-time environment, the model must be able to perform the object recognition in real time. An effective and fast object recognition algorithm is the key to the success of autonomous vehicles, augmented reality devices and other smart systems. At this point, YOLO is quite different from other traditional methods as it carries out bounding box coordinate estimations and class predictions simultaneously. Together as a model, YOLO and CNN realized effective and precise real-time object recognition successfully with high average sensitivity (mAP) [57].
YOLO can predict the class and coordinates of all the objects in the image at once by passing the image through the CNN structure at once instead of the zones determined by respective segmentation for object detection and then sending it to the previously written Region Proposal Network. For the fulfillment of this prediction, object detection is handled as a single regression problem. For this fulfillment, firstly, the input image is divided into SxS grids as seen in Figure 10. These grids can be 3 × 3, 5 × 5, 19 × 19 [48].
Following this process, after the input image passes through the neural network, the grid is itself responsible for finding whether there is an object in the area, if there is, whether it has a midpoint, its length and height at the  midpoint and which class it is from. The grid where the objects seen in the grids in the figure are located is responsible for their detection. For this, YOLO establishes a separate prediction vector in each grid. The representation of the grid which enables the realization of these operations is given in Figure 11. In each of these, Confidence score, b x , b y , b w , b h , Conditional class probability values are available [48].
Confidence score shows how confident the model is about whether there is an object in the valid grid (absolutely absent if 0 and absolutely present if 1). If it thinks that there is an object, it shows how confident it is about whether this object is really that object and about the presence of the object through the coordinates of the surrounding box. On the other hand, b x in equation 1 calculates the x coordinate of the object's midpoint, b y in equation 2 calculates the y coordinate of the object's midpoint, b w in equation 3 calculates the width of the object and b h in equation 4 calculates the height of the object. Conditional Class Probability calculates the prediction values as many as the number of the different classes in the model [58]. The network predicts 4 coordinates for each bounding box, t x , t y , t w , t h . If the cell is offset from the top left corner of the image b y (c x , c y ) and the bounding box prior has width and height p w , p h , then the predictions correspond to: When the algorithm is detecting the object, quite many unnecessary grids, even more than one grid for one object may emerge. These unnecessary boxes should be discarded by the algorithm. The algorithm performs this procedure thanks to the predictive parameters. This procedure is executed by the Non-maximum Suppression (NMS) algorithm, which is commonly used in Object Detection (OD). [59]. As observed in Figure 12, the algorithm enables the minimization of the extra grids.
For these procedures; • It discards all the grids whose confidence score is under a certain level (for example, those below 0.5).
• As long as grids remain, it selects the grid with the highest confidence score and presents it as output.
• It discards the selected grid and all other grids whose IoU (Intersection over Union) value is more than 0.5. YOLO terminates all these classification procedures with minimum errors. The functions calculating these errors can be reviewed under 3 main headings.
Loss of Classification: Refers to how wrong the predicted object is.
Loss of Location: Refers to how wrong the predicted box is.
Loss of Confidence:Refers to how wrong whether there is an object in the grid is.
NMS is integrated into OD algorithms to filter detection boxes. NMS makes selections based on the Intersection over Union (IoU) between detection boxes. IoU measures the ratio of the overlapped area over the union area between two boxes. NMS works in two steps: 1) For a given object category, all of the detected bounding boxes in this category are sorted based on their box confidence scores from high to low; 2) NMS selects the box which has the highest box confidence score as the detection result, and then it discards other candidate boxes whose IoU value with the selected box is beyond the threshold. VOLUME 8, 2020

Algorithm 1 Non-Maximum Suppression
Input: B, S, N t Initialisation: Then, within the remaining boxes, NMS repeats the above two steps until there is no remaining box in the candidate set. Suppose the initial detection boxes are B = b 1 , b 2 , . . . , b n , the corresponding box confidence scores are S = s 1 , s 2 , . . . , s n .
Given an NMS threshold N t , could write the NMS algorithm as Algorithm 1 [60]:

IV. DATA SET AND PROPOSED MODEL A. DATA COLLECTION
For the training and test operations of the proposed model, the 2D candlestick chart views of the price information belonging to the current stocks which are listed in BIST were used. For the creation of the candlestick charts, the financial data were provided by BIST and they were turned into the 2D candlestick chart view through the Python programming language [61]. The data set was formed by saving the visual 2D candlestick charts of the stocks from 2000-2018 annually in one line as stockname_month_year in an image format in the dimensions of 1800 × 650 without any index (BIST-30, BIST-50 etc.) discrimination except for the shares with speculative and manipulative charts. As some of the stocks included in the data set did not have a beginning in 2000, the chart image was saved as of the year when they started to be traded in BIST. For the study, a total of 550 2D candlestick charts were saved annually as given in Figures 13 and 14.
The data set and test charts consist of the candlestick charts generated by the end-of-day prices. As it is known, these charts can be obtained from the results of investment instruments such as the end of session or 1h, 30min. Here, the only criterion to be considered is that the number of the candlesticks need to be dropped to 180 days if the session chart view is used since a 360-day (±10%) candlestick chart is annually used in the model training. Again, the 180-day and session chart will display a chart containing 360 candlesticks in total. B. DATA PREPROCESSING object −class x −center y−center width height (5) According to the formula, the class value is a whole number between 0-∞. For a 2-object structure, the class values are determined as 0 and 1. Width and Height values are specified as the height and width values of the enclosed object, and the x-y-center values express the center of the boundaries of the object. These variables take values between 0.0 and 1.0. Accordingly, the ''.txt'' file content created for a labeled image is as shown in Figure 15.
The numerical values shown in the figure refer to the class of the labeled object and its location in the image. In addition, 4 data in the line outside the class in the ''.txt'' constitute the number of the coordinate values given in the formula 6.   During the data preprocessing stage, in the data set comprised of 550 annual charts in total, a total of 10009 labels were created including 5161 ''Buy'' signals and 4848 ''Sell'' signals.

C. PROPOSED MODEL
The proposed model is a ''Buy-Sell'' decision model supporting the buying and selling decisions provided by the technical and basic analysis techniques to the investors who will make a selection among the alternative financial market instruments. The flow diagram of the design is presented in Figure 16.
The preparation and labeling procedures of the data set in the first part (green zone) of the proposed model was carried out in the light of the Dow Theory. The other part of the model (blue zone) is constituted by an artificial intelligence-based object recognition/classification model of today's popular technology for object recognition.   The purpose of the proposed model is to enable the CNN to recognize the areas labeled for ''Buy-Sell'' signals in candlestick charts as objects. Therefore, a training was executed for introducing the labeled areas as objects to the network.

D. TRAINING METHODOLOGY
The training of the labeling for the proposed model was performed on the Nvidia RTX-2070 GPU in Windows using Tensorflow 1.13.1 [60] and Python 3.7 versions. For the backbone network, adopted the parameters pre-trained in DarkNet-53. Using a pre-training weight training network can greatly reduce training time and experimental resources and can converge faster. In fine-tuning, the initial learning rate is set to 1e − 3 and is divided by 1000 after every epoch. The network is trained with 50000 epochs in total. For the training, the YOLO Darknet-53 feature extraction architecture given in Figure 17 was used.
The network architecture used here is comprised of 1 × 1 and 3 × 3 successively connected layers. Each layer is trained with the same settings. This architecture was structured in a ''.cfg'' file and saved with the name ''articleyolov3.cfg'' for the training. Within the scope of this study, the class and filter values of the YOLO architecture were re-calculated and changed. The calculation of the filter value is as seen in the formula 6 [48]. filters = (classes + coords + 1) * number of mask (6)  In the formula, the class value refers to the number of objects to be introduced to the network. For instance, the number of classes is determined as 3 if a training will be conducted for the detection of animals such as cats, dogs and horses. In this study, the number of classes was defined as 2 as the aim was to detect two different qualities as ''Buy-Sell''.
The other coordinate value was determined as ''4'', which is stated as the numeric equivalence of the number of the coordinate data in the ''.txt'' file created during the data preprocessing stage.
Finally, number of masks refers to the mask representation in the architecture. The mask encodes the spatial layout of an input object. For this reason, contrary to class labels, it is pixel-to-pixel matching constricted as layers fully connected to each other and provided by convolutions [63]. This value is determined as 3 for Yolov3. Hence, the number of the filters to train a series of images containing 2 classes, the following calculation is performed: filters = (2 + 4 + 1) * 3 = 21. For each image, the intersection over union (IoU) between the bounding box of the detected object ground truth can be calculated as: where IoU is the intersection over union, Ao is thearea of overlap, and Au is the area of union.
When the IoU of the predicted bounding box and ground truth is greater than a certain threshold value (e.g., 0.5), it is considered as a true positive; otherwise, it is a false positive. A false negative is obtained by missing an object.

E. TEST AND RESULT
The price information of the investment instruments has no importance for the proposed model. The analysis is run only on candlestick charts. Besides, the training data set used in the model covers the years between 2000 and 2018 as previously mentioned, and test procedures were implemented for the stocks after 2018. Moreover, the coincidence of testing a stock used in the training is not possible since not the charts of all the stocks in BIST are used for training. In addition, as stated before, speculative and manipulative stocks are avoided for the implementation of the model.
For the model test, (dd.mm.yyyy) dated candlestick charts of the stocks traded in BIST were firstly examined in terms of technical and basic analyses. As a result of these analyses, 1-year chart images of the most appropriate stocks exemplified in Figure 18 were separately saved in the created test folder. VOLUME 8, 2020 FIGURE 21. Example of the stock chart whose module output is not a decision on the last candlestick chart. When all the stocks are reviewed, this number is very high. As previously mentioned, the ultimate aim of the model is to be a ''Buy-Sell'' decision model strengthening the decision on which stock with good technical analysis should be included in the portfolio. The saved chart views were applied to the test instrument given in Figure 19.
After the model implementation, the stocks producing the ''Buy'' signal on the last-day candlesticks in the chart given in Figure 20 were found to be appropriate for buying and included in the created investment portfolio.
It is observed that a certain number of ''Buy-Sell'' signals emerged on the chart outputs in the figure. From another perspective, this can be thought as the self-testing of the system. Here, the single and most important point to consider is the presence of the ''Buy'' signal produced by the model on the last-day candlesticks. This shows that the tested stock is appropriate for buying with its end-of-day price. As seen in Figure 21, many ''Buy-Sell'' outputs emerged on the model output, but no decision appeared for the last-day candlestick view. The related stocks are not dealt with for that day.
Following these test procedures, the price and date information of the stocks with the ''Buy'' signal and then the price and date information of the stocks with the ''Sell'' signal were saved in a table for assessing the loss-profit information. The ''Buy-Sell'' test procedure performed over the stocks, which were first, included in the portfolio is as given in Table 2.
In the table given, the test procedure was conducted as basket in the financial field (having more than one stock to minimize the loss). The creation of this table has been achieved with 7 different stocks.
The table also shows the percentage values of the produced signals. These values can be mentioned as the expression of the object detection in percentage as in YOLO. The most important purpose of placing these values is to prove that the developed model did not make a memorization. On the VOLUME 8, 2020  other hand, high percentage values point at a better decision; however, it has also been seen that stocks with low percentage signal value sometimes made higher profit. For this reason, no ranking has been set according to the percentage values. As observed in the table, the formation of ''Sell'' signals corresponds to different times. Strategically, there was a waiting time from the formation of the ''Buy'' signal until the formation of ''Sell'' signal of the last stock. When the test result of any stock in our portfolio appeared as ''Sell'' in the following days, the follow-up was ended upon the evaluation of the result. In this way, a group's maximum number of processes was determined. The ''Sell'' signal emerging for each stock and the price that appeared at the end of the day they the signal emerged were added into the table. The price difference by which the ''Buy'' and ''Sell'' signals are specified gives the profit-loss result. Again, the percentage calculation of this profit-loss value was carried out and added into the table. The % profit column seen in the table expresses the profit of the stock for each stock on a line basis. As a result, a process with 10.71% profit can be interpreted to have come true in maximum 28 days when the average percentage profit of the stocks was calculated for the first group.
Thus, in the 1-year process test executed, the procedure of 13-group basket formation was accomplished. After the ''Sell'' signal of the last stock of each group, the presence of the stocks giving the ''Buy'' signal for creating a new group the following day. When it comes to investment, it is possible to encounter the ''Buy'' signal every day in terms of the stock markets with an excessive number of stocks. Not to encounter it, the test was planned for the (t+1) following day. The summary table of the next 13 groups created is as stated in Table 3.
The table above was prepared not to discuss all the 112 transaction steps in Table 3 (the table above). This table  is a summary table used      number of staying in the portfolio and the profit of the portfolio are respectively expressed with the columns of maximum day count and periodic profit %. Principal column represents the total profitable amount obtained by calculating the periodic profit of a certain amount of cash following each basket formation. The profit percentage was determined for each period and this profit percentage was calculated as the return of the previous principal. Firstly, transactions were run assuming that the principal was $10000. In the calculation, the principal was equally divided into the number of stocks in the basket formation and the evaluation was made. Afterwards, the remaining principal together with the calculated profit or loss was again divided into the number of the baskets and distributed equally for each stock. Hence, in one distribution, the average profit of the basket affected the whole principal. Furthermore, it was also ensured that a high-loss stock transaction that may occur in the basket does not affect the whole principal. As mentioned in the table result lines, the success rate of the model is very high. It has been observed in the ''Buy-Sell'' results of the 376-day period that the model could make a profit by 102.68%. The evaluation of the table above in terms of results is presented in Table 4.
It is seen in the table that the principal reaches $20267 after these transactions performed with $10000, the beginning principal. The commission rates likely to emerge in the ''Buy-Sell'' cases are not included in this profit calculation. The calculation of 0.02×2% for each buy and sell can be included in the result as the highest valid commission rate. In terms of success, it can be said that a model, which produces quite successful results compared to several methods examined for financial prediction mentioned in the section of studies, has been designed. Moreover, as a general evaluation of the model, 11 periods out of 13 groups resulted in profit and only 2 periods resulted in loss. This points at a decision success of 84.6% on a group basis. On the other hand, the evaluation of the success of the model, apart from the evaluation of financial gain, is given in Table 5.
The success criterion of the proposed model can be evaluated in several ways. These criteria are described as top seller stocks, stocks sold with little profit, and stocks sold as stop-loss (stopping loss at the earliest). Forming a ''Sell'' signal according to any criterion we stated after the ''Buy'' signal given by the model can be considered as the success of the model. There is no day and price limitation for performing these transactions. The sale place of a stock we bought to measure the success of the model and its status after the sale were evaluated. The table shows the buying and selling prices of some stocks. A total of 4 columns were formed for this evaluation. When evaluated in terms of success, top sellers can be mentioned as the most successful group among these columns. Thus, the sold stocks constitute the stock group sold over the highest level to which the buying price could rise within the trend. These stocks are stated as ''1'' in the table. According to the table, the stock had a downward movement in following days of the sale. The those sold with little profit group, another evaluation criterion, is stated as the stock group that kept rising in the following days of the ''Sell'' signal produced by the model for the bought stock. Even if such a transaction is profitable by the investor, it is considered as ''more profitable''. The other group, which is the stop loss criterion, is used in all the instruments as a significant criterion to prevent the investors from making more loss in the financial field. The created model has obtained successful results in this matter as well. While all these were described, ''1'' cell information was considered for those who fulfilled the criteria and ''0'' for those who did not. The final group is those closing high after loss, which decreases the success of the model's and is an undesired situation. This group represents the partial failure of the model. All these expressions were evaluated for 112 ''Sell'' signals in total and their summary is given in Table 6. VOLUME 8, 2020 The table result evaluation was divided into two groups as successful and unsuccessful. According to the criteria clearly stated above, a total of 94 ''Sell'' decisions can be said to have been successful. This corresponds to about 84% of the total decision. However, 18 decisions, which constitute approximately 16%, were considered unsuccessful. On the other hand, although it is aimed to stay away from speculative purchases within the unsuccessful decisions, there have been situations of rapid drops and brought high losses in stocks. For this, an example is given in Figure 22.
These speculative movements are the behaviors which are almost impossible to predict not only for the model in this study but also for all the studied and developed models. Because these behaviors occurred after the inclusion of the model in the portfolio with the ''Buy'' signal, they were still evaluated.
In addition to these tests, there are technical analysis indicators that produced a buy-sell decision strategy for an investment tool, which we had mentioned in the introduction part. Moreover, these methods are offered for a fee on many web pages. In order to prove that the model created in the study is a decision support model, the results created by the indicators on different days were tested along with the model results.
The presentation of the test results is displayed in table 7 and  table 8.  In the table 7 and table 8 above, the stocks, which sent out Buy signals in the indicator evaluation results of 2 different days, were listed. These indicators, as mentioned in the introduction part, are mathematical-based financial technical analysis methods, which have been approved in the world literature. Stocks were sequenced according to the scoring obtained as a result of the 12-indicator method used in the technical analysis on BIST-100. These table data were obtained through a website. [64]. As displayed in Table 7, the indicators produced Buy signals for 43 stocks in total over the closing prices of 02.01.2020. This number is quite high. In Table 8, the number of stocks producing Buy signals was determined as 8 according to the evaluations on 06.01.2020. Particularly, on Table 7, it is not quite possible to invest in all stocks. Moreover, for stocks, on which indicators produced buy signals, it does not necessarily mean, ''these stocks are definitely the stocks to be invested in'' [65]. In the selection of the investment tool, it is not enough to use the indicators alone. Hence, varied technical analysis methods of the investment tools, the most recent news and information about the tools and supporting with the basic analysis methods would be more beneficial for concluding with sound results in terms of investment. At this point, a model was developed to guide investors as a result of certain technical analysis. As displayed in the last columns of the tables, the stocks that produced Buy signals as a result of the indicators were also tested with the developed model. As a result of test, 5 out of 43 stocks in table 7 produced Buy signals. Sample presentations of these signals are displayed in figure 27 and figure 23.
No responses were produced for other stocks. Also, in Table 8, the model, which produced a Buy signal for only one of the 8 stocks that received a Buy signal from the indicators, produced a Sell signal for one of them. Hence, the developed model facilitated the selection among several stocks that produced Buy signals as a result of the indicatorbased technical analysis. If it were to be used alone, it would be necessary to select among the 100 stocks in BIST-100 and 405 stocks in BIST-TUM. However, selection was facilitated by further reducing the number of stocks, which used to be 43 stocks that produced Buy signals in BIST-100, according to the indicators.
The signal accuracy was also examined in the stocks that produced Sell signals within the model and the results are displayed in table 9.
As it can be understood from Table 9, while the indicators produced the Buy signal, the Sell signal that was produced by the model was not a false decision. Following the sell signal, prices were lower or at the same level in the days following the buy signal. As a result, the developed model is a model that supports decisions. When making an investment, all date obtained from an investment tool should be analyzed and the decision of purchasing should be verified through more than a single technical analysis method regardless of the type of the technical analysis method.

V. CONCLUSION
As financial prediction is a nonlinear system that cannot be expressed mathematically, making price predictions and making profit as a result have always been an interesting research subject for both financiers and academics working in the field of artificial intelligence.
It is possible to the find various studies on time series predictions in the literature, particularly in the field of finance. However, in terms of individual investors, it is not possible to use most of the mathematical formulas developed especially in active markets. It would be more accurate to say that these methods are mostly used in the backgrounds of investment companies to support investors and that only certain experts were able to understand their results. On the other hand, there are many technical analysis methods, formations and indicator systems carried out on charts that were produced for financial markets. The main reason for this is that although investors wish to see the updated numerical information belonging to the investment tool, they analyze the future investment activities on the charts and make their decisions based on the charts.
At this point, it should be considered that each investment analysis tool does not compete for being better than the other, because each tool has different advantages compared to the other. Additionally, these analysis tools are globally approved methods, as mentioned in the article. The most important point here is to ensure that the investor makes the most profitable investment by taking advantage of all investment analysis tools.
That is, the main purpose of all investors investing in the financial field is to make a profit by buying at a low price and selling at a higher price. This model that was created in the light of this aim, is a simple but effective model, which could also be used by individual investors as an additional investment analysis tool in the analysis of all investment tools using candlestick charts such as the stock analysis of stock exchange market, parity, index and other stock exchanges As it is understood from the evaluation results, it is clearly seen that the ''Buy'' and ''Sell'' signals produced by the model are not coincidental since the model was successful by 80%. The reason why signals are not produced at some points on the charts depends on how the chart image is. As in YOLO, the change in the images changes the status of detectability. However, there were no interventions such as magnification, reduction or facilitation of detectability in the charts because it is planned to automatize the system in further studies. Again, the developed model only produces Buy and Sell signals for now. In future studies, it is planned to expand the model with the labeling that produces Hold signal for investors who have never invested and Keep signal for purchasing investors.