Design And Implementation Of Candlestick Chart Retrieval .

2y ago
112 Views
9 Downloads
767.61 KB
7 Pages
Last View : 6d ago
Last Download : 3m ago
Upload by : Milena Petrie
Transcription

ALLDATA 2018 : The Fourth International Conference on Big Data, Small Data, Linked Data and Open DataDesign and Implementation of Candlestick Chart Retrieval Algorithmfor Predicting Stock Price TrendYoshihisa UdagawaComputer Science Department, Faculty of Engineering,Tokyo Polytechnic UniversityAtsugi-city, Kanagawa, Japane-mail: udagawa@cs.t-kougei.ac.jpAbstract—Advances in data mining techniques are now makingit possible to analyze a large amount of stock data forpredicting future price trends. The candlestick charting is oneof the most popular techniques used to predict short-termstock price trends, i.e., bullish, bearish, continuation. While thecharting technique is popular among traders and has longhistory, there is still no consistent conclusion for thepredictability of the technique. The trend of stock prices oftencontinues after intervals of several days because stock pricestend to fluctuate according to announcements of importanteconomic indicators, economic and political news, etc. To copewith this kind of stock price characteristics, this paper focuseson a dynamic programming algorithm for retrieving similarnumerical sequences. To be specific, the well-known LongestCommon Subsequence (LCS) algorithm is revised to retrievenumerical sequences that partially match. The proposedalgorithm also handles a relative position among a stock price,5-day moving average, and 25-day moving average to take intoaccount where the price occurs in price zones. Experimentalresults on the daily data of the Nikkei stock average show thatthe proposed algorithm is effective to forecast short-termtrends of stock prices.Keywords— Stock price prediction; Technical analysis;Candlestick charts; Longest common subsequence algorithm fornumbers; Multi numerical attributes; Nikkei stock average.I.INTRODUCTIONStock market prediction techniques play a crucial role tobring more people into market and encourage markets as awhole. Fundamental analysis and technical analysis are twopopular approaches to successful stock trading [1].Fundamental analysis combines economic, industry, andcompany analysis to derive a stock’s current fair value andforecast future value. Traders apply this approach over a longperiod of time, e.g., months, quarters. Because of thisanalyzing processes, most investors believe that fundamentalanalysis is mainly suitable for long-term prediction.Technical analysis is a study of market action, primarilythrough the use of charts for the purpose of forecasting futureprice trends [2]. Technical analysis is based on the followingthree premises:1. Market action discounts everything: a stock’s pricereflects all relevant information such as economic,fundamental and news events,Copyright (c) IARIA, 2018.ISBN: 978-1-61208-631-62. Prices move in trends: prices trend keep directionally, i.e.,up, down, or sideways, for a certain period,3. History repeats itself: the repetitive nature of pricemovements is mainly attributed to market emotions likefear or excitement that often repeat themselves.One of the important types of technical analysis iscandlestick chart patterns [2]. The candlestick chart patternsprovide short-term predictions for traders to make buy or selldecisions. While most of techniques use statistics of stockprices, the candlestick charting technique focuses on patternsamong several days of candlesticks formulated by opening,high, low, and closing prices within a specific time frame,such as minute, hour, day or week. Dozens of candlestickchart patterns are identified to be signals of bullish/bearishreversals and continuations. These patterns consist of asingle candlestick or a combination of multiple candlesticks.In fact, the technique acts as a leading indicator with itscapability to provide trading signals earlier than othertechnical indicators based on statistics. It is also used bysome real time technical service providers [3] to providequick signals for market’s sentiments.The candlestick charting technique probably begansometime after 1850 [2]. Despite of its long history andpopularity, mixed results are obtained in the studies oncandlestick charting. Negative conclusions to thepredictability of candlesticks are reported [4]-[6], whilepositive evidences are provided for several candlestick chartpatterns in experiments using the U.S. and the Asian stockmarkets [7]-[10].It is also pointed out that candlestick chart patternrecognition is subjective [2][7][11]. The candlestick chartpatterns are often qualitatively described using words andillustrations. The studies [6][7] adopt definitions using aseries of inequalities with different parameters that specifycandlestick patterns. Numerical definitions of candlestickpatterns are still controversial issues.In addition, they don’t occur in time series in a strict sensebecause stock price fluctuation continues after intervals ofseveral days depending on announcements of importanteconomic indicators, economic and political news, etc.Because of these characteristics, the candlestick chartpatterns are deemed to bring controversial results onpredictability regarding future market trends even sort-termprediction.19

ALLDATA 2018 : The Fourth International Conference on Big Data, Small Data, Linked Data and Open DataThe aim of the study is to estimate the predictability ofcandlestick patterns for future stock price trends. Theproposed algorithm is applied to the daily Nikkei stockaverage (Nikkei 225) in the experiments. Daily historicalstock prices are used because we plan to relate chart patternsto economic and political news in the future study.The contributions of this paper are as follows:(I) The Longest Common Substring (LCS) algorithm [12],which is a kind of dynamic programming algorithms, isimproved to cope with candlestick patterns containingseveral intervals,(II) The proposed model utilizes tolerances for multipleattributes that specify candlestick charts, so it canretrieve similar candlestick charts in terms of upper andlower tolerance bounds,(III) The proposed model uses relative position among astock price, 5-day moving average, and 25-day movingaverage to decide whether the price occurs in high orlow price zones,(IV) The proposed model uses slopes of the movingaverages to identify their trends,(V) The proposed model devises a graphical representationto make evaluation of the retrieval results easy to depictthe predictability for short-term trends.The remainder of the paper is organized as follows.Section II gives backgrounds of the candlestick chart.Section III describes a model for retrieving similarcandlestick charts. An augmented dynamic programingtechnique is used to implement the proposed model. SectionVI presents experimental results on both the uptrend anddowntrend of stock prices. Section V gives some of the mostrelated work. Section VI concludes the paper with our plansfor future work.II.CANDLESTICK CHART AND PATTERNSThis section introduces the formation of a candlestick.Candlestick patterns are a combination of one or morecandlesticks [2]. Samples of well-known candlestick chartpatterns are shown. Because the candlestick patterns aredescribed in natural language and illustrations, there arecriticisms on their use for trend prediction by a computer.A. Formation of CandlestickA daily candlestick line is formed with the market’sopening, high, low, and closing prices of a specific tradingday. Figure 1 represents the image of a typical candlestick.The candlestick has a wide part, which is called the “realbody” representing the range between the opening andclosing prices of that day’s trading.If the closing price is above the opening price, then awhite candlestick with black border is drawn to represent abullish candlestick. If the opening price is above the closingprice, then a filled candlestick is drawn. Normally, blackcolor is used for filling the candle to represent a bearishcandlestick.The thin lines above and below the body represent thehigh/low ranges. These lines and are called “shadows” andalso referred to as “wicks” and “tails.” The high is markedCopyright (c) IARIA, 2018.ISBN: 978-1-61208-631-6by the top of the upper shadow and the low by the bottom ofthe lower shadow.Figure 1. Candlestick formationB. Samples of Candlestick PatternsDozens of candlestick patterns are identified and becomepopular among stock traders [2][3]. These patterns havecolorful names like morning star, evening star, three whitesoldiers, and three black crows.Figure 2 shows the morning star pattern which isconsidered as a major reversal signal when it appears in alow price zone or at a bottom. It consists of three candles,i.e., one short-bodied candle (black or white) between apreceding long black candle and a succeeding long whiteone. The pattern shows that the selling pressure that wasthere the day before is now subsiding. The third whitecandle overlaps with the body of the black candle showing astart of a bullish reversal. The larger the white and blackcandle, and the higher the white candle moves, the larger thepotential reversal. The opposite version of the morning starpattern is known as the evening star pattern which is areversal signal when it appears in a high price zone or at theend of an uptrend.Figure 2. Morning star patternFigure 3 shows the three white soldiers pattern which isinterpreted as a strong indication of a bullish market reversalwhen it appears in a low price zone. It consists of three longwhite candles that close progressively higher on eachsubsequent trading day. Each candle opens higher than theprevious opening price and closes near the high price of theday, showing a steady advance of buying pressure. Theopposite of the three white soldiers pattern is known as thethree black crows pattern which is interpreted as a bearishsignal of market trend.20

ALLDATA 2018 : The Fourth International Conference on Big Data, Small Data, Linked Data and Open DataThe proposed model is unique because it uses two movingaverages and their slopes, while the previous studies [4]-[12]do not deal with them. Relative position among a stock price,5-day moving average, and 25-day moving average issignificant to identify the zone where the candlestick patternunder consideration occurs, which is vital information forapplying the candlestick pattern. The slopes of the movingaverages are also important to identify their trends, e.g., anuptrend, a downtrend or a sideway (flat).Figure 3. Three white soldiers patternC. Criticism of Candlestick PatternsThe major criticism of the candlestick chart patterns isthat the patterns are qualitatively described with words, suchas “long/short candlesticks,” “higher/lower trading,”“strong/weak signal,” supported by some illustrations [2].What percentage of price change does “long/short” mean?Without modeling the candlestick patterns in a way that acomputer can process and performing experimentscomprehensively, arguments on the effectiveness of chartpatterns would not come to an end.Since it is highly possible that the existence andpredictability of candlestick patterns depends on stockmarkets, this study focuses on the Nikkei stock average(Nikkei 225) as the first stage of study. This paper proposesa model for retrieving similar candlestick charts based on adata mining algorithm using dynamic programing techniqueto handle candlestick patterns including several intervalsthat suggest unpredictable price trends.III.PROPOSED MODEL FOR RETRIEVINGCANDLESTICK PATTERNSThis section describes a model for retrieving similarcandlestick charts. A dynamic programing technique is usedto implement the proposed model.A. Parameters Featuring Candlestick PatternsAs a preliminary stage of study, experiments only using theclosing prices and the length of real bodies are conducted.The experiments simply correspond to the conditions of thecandlestick chart patterns [2]. The results are discouraging.Although mined stock price sequences are similar before thespecified period of the reference date, trends of thesequences after the reference date are seemed to be random.Analyses of the results show that the randomness occurs dueto the relative position among the stock price, the 5-daymoving averages, and the 25-day moving averages.Based on the results of the preliminary experiments, wepropose the model for retrieving similar candlestick charts.Figure 4 depicts the model that consists of the six parametersas follows:(1) Change of prices w.r.t previous closing price,(2) Length of candlestick body,(3) Difference from 5-day moving average,(4) Difference from 25-day moving average,(5) Slope of 5-day moving average,(6) Slope of 25-day moving average.Copyright (c) IARIA, 2018.ISBN: 978-1-61208-631-6Figure 4. Candlestick pattern retrieval modelB. nLCS: LCS for Numerical SubsequencesAnother issue of retrieving candlestick chart patterns isthat stock prices can move continued after a few days ofintervals because stock prices can vary according toimportant economic indicators, political news and actions,etc. The detection of similar candlestick chart patterns isessentially the detection of a set of numerical sequences thatpartially match the numerical sequences corresponding to achart pattern under consideration.The Longest Common Subsequence (LCS) algorithm isoriginally developed for character strings [12]. Finding theLCS between two strings is described as follows. Given twostrings, find the longest character subsequence that presentsin both of them. Characters of the subsequence appear in thesame relative order, but not necessarily contiguous. Figure 5depicts the LCS of the two strings “246612” and “3651.”Since elements of sequences are interpreted as characters thatrequire an exact match, the LCS is “61.”Figure 5. The LCS of two character sequences,“246612” and “3651”It is rather easy to improve the LCS algorithm to dealwith numerical sequences (nLCS) by interpreting eachelement as a number and using a tolerance given by a user. Ifthe difference of two numbers is not greater than the giventolerance, then the two numbers are regarded as the same.For example, let the tolerance be set to one, and the twonumber sequences be “246612” and “3651.” The nLCS are“2661” and “3651” as shown in Figure 6.21

ALLDATA 2018 : The Fourth International Conference on Big Data, Small Data, Linked Data and Open DataFigure 6. The nLCS of the two number sequences“246612” and “3651” for the tolerance of oneThe LCS and nLCS are formally defined as follows.LCS algorithm: Let the input sequences be X[1 m] oflength m and Y[1 n] of length n. Let D[i, j] denote thelength of the longest common subsequence of X[i] and Y[j]for 0 i m and 0 j n.A) If either sequence or both sequences are empty, then theLCS is empty, i.e., D[i, 0] 0 and D[0, j] 0.B) If X[i] and Y[j] match (X[i] Y[j]), then the LCS isbecome longer than the previous sequences by one, i.e.,D[i, j] D[i 1, j 1] 1.C) If X[i] and Y[j] do not match (X[i] Y[j]), then the LCSis the maximum of the previous sequences, i.e.,max(D[i 1, j], D[i, j 1]).The value of D[m, n] is the LCS of the sequences X[1 m] and Y[1 n]. The actual LCS sequence can be extractedby following the matrix D[i, j].nLCS algorithm: The nLCS algorithm is derived from theLCS algorithm by replacing the match condition (X[i] Y[j]) with ((X[i] Y[j]) diff) where diff is a tolerancegiven by a user.C. nLCSm: LCS for Subsequences with Multi NumericalAttributesThe idea of deriving the nLCS from the LCS can befurther extend to the multi numerical attributes to obtain thenLCS for subsequences with multi numerical attributes(nLCSm).nLCSm algorithm: Let p (1 p) denote the number ofnumerical attributes. Let Cq (1 q p) denote the matchconditions for the qth numerical attribute. The nLCSm isderived by replacing the match condition of the nLCS, i.e.,((X[i] Y[j]) diff), with (C1 . Cq . Cp).D. nLCSm and candlestick pattern retrievalGiven the candlestick pattern model with six parametersas depicted in Figure 4, the nLCSm algorithm can be appliedto implementing the model by assigning match conditions C1to C6 for each candlestick as follows.C1: if a difference between closing price change of a givencandlestick and that of a candidate candlestick is withinthe change tolerance (change tol), then C1 is true.C2: if a difference between body length of a givencandlestick and that of a candidate candlestick is withinthe body tolerance (body tol), then C2 is true.C3: if a difference between a closing price and a 5-daymoving average is within the tolerance (av5diff tol), thenC3 is true.C4: if a difference between a closing price and a 25-daymoving average is within the tolerance (av25diff tol),then C4 is true.C5: if a slope of a 5-day moving average is within the giventolerance (slope5 tol), then C5 is true.Copyright (c) IARIA, 2018.ISBN: 978-1-61208-631-6C6: if a slope of a 25-day moving average is within the giventolerance (slope25 tol), then C6 is true.The 5-day moving average is calculated by the latest fivedays’ closing prices. Because these prices are just a sampleof larger population of closing prices, the sample standarddeviation or Bessel's correction [2] is adopted as a measureof threshold to decide whether a given 5-day movingaverage is within an expected distribution.The tolerance of 5-day moving average av5diff tol isstatistically dependent on the change tolerance change tol.In the proposed retrieval model, av5diff tol and av25diff tolare calculated by the following formulas as defaultsaccording to the definition of the sample standard deviation.av5diff tol change tol / SQRT(4) change tol / 2(1)av25diff tol change tol / SQRT(24) change tol / 4.899(2)Thus, there are essentially four independent parameters inthe proposed model, which still causes difficulties in settingparameters. Assuming that each parameter has 5 ranges ofvalues representing, for instance, very high, high, the samelevel, low, and very low. The candlestick patterns of onecandlestick have 5 to the power 4, i.e., 5 4 625 cases ofparameters. The patterns composed of two candlesticks have5 (4*2) 625*625 390,625 cases. The patterns of treecandlesticks have 244,140,625 cases. These cases mean verywide varieties of candlestick charts leading difficulties evenin setting parameters for retrieving a specific candlestickchart pattern.IV.EXPERIMENTAL RESULTSThe predictabilities of the morning star pattern and theevening star pattern are evaluated through experiments. Theexperiments are conducted on the daily historical stockprices of Nikkei stock average (Nikkei 225) of 2,420business days from Jan. 4, 2008 to Nov. 15, 2017.A. Data ConversionThe stock prices are converted to the ratio of closingprices to reduce the effects of highness or lowness of thestock prices. The formula below is used for calculating theratio of prices in a percentage.Ri (CPi – CP i 1)*100 / CP i (1 i n)(3)CPi indicates the closing price of the i-th business date.CP1 means the closing price of the current date. R1 is theratio of the closing price of the current date CP1 and thedifference between CP1 and CP2, i.e., the closing price of thedate before the current date. The similar calculations areperformed to opening, high, and low prices. In addition, the5-day and 25 day moving averages, and their slopes arecalculated before the experiments. The number of data valid,i.e., n in effect is 2,396 ( 2,420 24) because the 25-dayaverages can’t be calculated to the last 24 days.22

ALLDATA 2018 : The Fourth International Conference on Big Data, Small Data, Linked Data and Open DataB. Experiments on Morning Star PatternFigure 7 shows the candlestick chart of the Nikkei 225 inwhich a strong uptrend starts on Sept. 11, 2017. Thecandlesticks ending on Sept. 11, 2017 form a morning starpattern. The first experiment is performed on the threecandlesticks surrounded by a dotted rectangle in Figure 7.Figure 9 shows overlapped closing prices whose businessdates are listed in Table I for graphically representing thefuture stock trend. All refe

predictability of candlesticks are reported [4]-[6], while positive evidences are provided for several candlestick chart patterns in experiments using the U.S. and the Asian stock 7]-[10]. d out that candlestick chart pattern [2 ][7][11 . The candlestick chart p

Related Documents:

Candlestick chart is a kind of a bar chart defined by opening, closing, high, and low prices. If the opening price is lower than the closing price, a hollow candlestick is drawn indicating uptrend (Bullish). In the other case, a filled candlestick is drawn showing downtrend (Bearish). (A) Bullish candlestick (B) Bearish candlestick

Bullish Candlestick Patterns Free PDF Download[/caption] Bullish Candlestick Patterns Free PDF Download Candlestick patterns are one of the most important tools in a trader's toolbox. They can be used to identify potential reversals, continuations, and breakout opportunities. There are many different candlestick patterns, but some are .

Forex indicators and the way they should be traded when spotted on the chart. WHAT ARE FOREX CANDLESTICK PATTERNS? Forex candlestick patterns are special on-chart formations created by one, or a few, Japanese candlesticks. There are many different candlestick pattern indicators known in Forex, and each of them has a specific meaning and .

Candlesticks have precise definitions and fixed time intervals which gives approaches based on candlesticks an advantage for research. They are easier to understand, analyze and work with [7]. Figur 1: Candlestick illustration [8] 2.4 Candlestick Patterns A candlestick represents

A VERY BRIEF INTRODUCTION TO CANDLESTICK PATTERNS 4 The single candlestick is composed of three elements: upper shadow (jap.uwakage), lower shadow (jap.shitakage) and body (jap. jittai).The candlestick body is determined by the opening and closing prices, represented by a rectangle.

A Bearish Haramiis a two candle Reversal candlestick pattern that occurs in up-trending market. This pattern consists of a small body contained within a prior relatively long body. Harami is old Japanese word for pregnant. The long green candlestick is the mother and the small candlestick is the baby. Figure below displays the pattern:

A candlestick chart pattern in which a large candlestick is followed by a smaller candlestick whose body is located within the vertical range of the larger body . In terms of candlestick colors, the bullish harami is a downtrend of negative-colored (RED) candlesticks engulfing a small positiv

gangguan kesehatan mata tertinggi disebabkan responden suka bermain komputer, laptop, handphone, tablet, atau iPad yaitu sebanyak 29 orang (97%) dan terendah responden memiliki penyakit mata selain mata minus yaitu Strabismus sebanyak 1 orang (11%) dan Astigmatisme sebanyak 8 orang (89%). Grafik 1. Hasil keseluruhan responden Berdasarkan grafik 1, menunjukkan responden yang menggunakan .