DOI QR코드

DOI QR Code

Development of a Stock Trading System Using M & W Wave Patterns and Genetic Algorithms

M&W 파동 패턴과 유전자 알고리즘을 이용한 주식 매매 시스템 개발

  • 양훈석 (국민대학교 비즈니스IT전문대학원) ;
  • 김선웅 (국민대학교 비즈니스IT전문대학원) ;
  • 최흥식 (국민대학교 비즈니스IT전문대학원)
  • Received : 2018.11.13
  • Accepted : 2019.03.07
  • Published : 2019.03.31

Abstract

Investors prefer to look for trading points based on the graph shown in the chart rather than complex analysis, such as corporate intrinsic value analysis and technical auxiliary index analysis. However, the pattern analysis technique is difficult and computerized less than the needs of users. In recent years, there have been many cases of studying stock price patterns using various machine learning techniques including neural networks in the field of artificial intelligence(AI). In particular, the development of IT technology has made it easier to analyze a huge number of chart data to find patterns that can predict stock prices. Although short-term forecasting power of prices has increased in terms of performance so far, long-term forecasting power is limited and is used in short-term trading rather than long-term investment. Other studies have focused on mechanically and accurately identifying patterns that were not recognized by past technology, but it can be vulnerable in practical areas because it is a separate matter whether the patterns found are suitable for trading. When they find a meaningful pattern, they find a point that matches the pattern. They then measure their performance after n days, assuming that they have bought at that point in time. Since this approach is to calculate virtual revenues, there can be many disparities with reality. The existing research method tries to find a pattern with stock price prediction power, but this study proposes to define the patterns first and to trade when the pattern with high success probability appears. The M & W wave pattern published by Merrill(1980) is simple because we can distinguish it by five turning points. Despite the report that some patterns have price predictability, there were no performance reports used in the actual market. The simplicity of a pattern consisting of five turning points has the advantage of reducing the cost of increasing pattern recognition accuracy. In this study, 16 patterns of up conversion and 16 patterns of down conversion are reclassified into ten groups so that they can be easily implemented by the system. Only one pattern with high success rate per group is selected for trading. Patterns that had a high probability of success in the past are likely to succeed in the future. So we trade when such a pattern occurs. It is a real situation because it is measured assuming that both the buy and sell have been executed. We tested three ways to calculate the turning point. The first method, the minimum change rate zig-zag method, removes price movements below a certain percentage and calculates the vertex. In the second method, high-low line zig-zag, the high price that meets the n-day high price line is calculated at the peak price, and the low price that meets the n-day low price line is calculated at the valley price. In the third method, the swing wave method, the high price in the center higher than n high prices on the left and right is calculated as the peak price. If the central low price is lower than the n low price on the left and right, it is calculated as valley price. The swing wave method was superior to the other methods in the test results. It is interpreted that the transaction after checking the completion of the pattern is more effective than the transaction in the unfinished state of the pattern. Genetic algorithms(GA) were the most suitable solution, although it was virtually impossible to find patterns with high success rates because the number of cases was too large in this simulation. We also performed the simulation using the Walk-forward Analysis(WFA) method, which tests the test section and the application section separately. So we were able to respond appropriately to market changes. In this study, we optimize the stock portfolio because there is a risk of over-optimized if we implement the variable optimality for each individual stock. Therefore, we selected the number of constituent stocks as 20 to increase the effect of diversified investment while avoiding optimization. We tested the KOSPI market by dividing it into six categories. In the results, the portfolio of small cap stock was the most successful and the high vol stock portfolio was the second best. This shows that patterns need to have some price volatility in order for patterns to be shaped, but volatility is not the best.

투자자들은 기업의 내재가치 분석, 기술적 보조지표 분석 등 복잡한 분석보다 차트(chart)에 나타난 그래프(graph)의 모양으로 매매 시점을 찾는 직관적인 방법을 더 선호하는 편이다. 하지만 패턴(pattern) 분석 기법은 IT 구현의 난이도 때문에 사용자들의 요구에 비해 전산화가 덜 된 분야로 여겨진다. 최근에는 인공지능(artificial intelligence, AI) 분야에서 신경망을 비롯한 다양한 기계학습(machine learning) 기법을 사용하여 주가의 패턴을 연구하는 사례가 많아졌다. 특히 IT 기술의 발전으로 방대한 차트 데이터를 분석하여 주가 예측력이 높은 패턴을 발굴하는 것이 예전보다 쉬워졌다. 지금까지의 성과로 볼 때 가격의 단기 예측력은 높아졌지만, 장기 예측력은 한계가 있어서 장기 투자보다 단타 매매에서 활용되는 수준이다. 이외에 과거 기술력으로 인식하지 못했던 패턴을 기계적으로 정확하게 찾아내는 데 초점을 맞춘 연구도 있지만 찾아진 패턴이 매매에 적합한지 아닌지는 별개의 문제이기 때문에 실용적인 부분에서 취약할 수 있다. 본 연구는 주가 예측력이 있는 패턴을 찾으려는 기존 연구 방법과 달리 패턴들을 먼저 정의해 놓고 확률기반으로 선택해서 매매하는 방법을 제안한다. 5개의 전환점으로 정의한 Merrill(1980)의 M&W 파동 패턴은 32가지의 패턴으로 시장 국면 대부분을 설명할 수 있다. 전환점만으로 패턴을 분류하기 때문에 패턴 인식의 정확도를 높이기 위해 드는 비용을 줄일 수 있다. 32개 패턴으로 만들 수 있는 조합의 수는 전수 테스트가 불가능한 수준이다. 그래서 최적화 문제와 관련한 연구들에서 가장 많이 사용되고 있는 인공지능 알고리즘(algorithm) 중 하나인 유전자 알고리즘(genetic algorithm, GA)을 이용하였다. 그리고 미래의 주가가 과거를 반영한다 해도 같게 움직이지 않기 때문에 전진 분석(walk-forward analysis, WFA)방법을 적용하여 과최적화(overfitting)의 실수를 줄이도록 하였다. 20종목씩 6개의 포트폴리오(portfolio)를 구성하여 테스트해 본 결과에 따르면 패턴 매매에서 가격 변동성이 어느 정도 수반되어야 하며 패턴이 진행 중일 때보다 패턴이 완성된 후에 진입, 청산하는 것이 효과적임을 확인하였다.

Keywords

JJSHBB_2019_v25n1_63_f0001.png 이미지

Chart Patterns

JJSHBB_2019_v25n1_63_f0002.png 이미지

M and W Patterns by Merrill

JJSHBB_2019_v25n1_63_f0003.png 이미지

Walk-Forward Analysis

JJSHBB_2019_v25n1_63_f0004.png 이미지

Simulator Configuration Diagram

JJSHBB_2019_v25n1_63_f0005.png 이미지

Zig-Zag Calculation

JJSHBB_2019_v25n1_63_f0006.png 이미지

4-point patterns

JJSHBB_2019_v25n1_63_f0007.png 이미지

New Numbered M&W Patterns

JJSHBB_2019_v25n1_63_f0008.png 이미지

Trading using M&W wave patterns

JJSHBB_2019_v25n1_63_f0009.png 이미지

Multi Point Crossover

JJSHBB_2019_v25n1_63_f0010.png 이미지

decimal calculation example

JJSHBB_2019_v25n1_63_f0011.png 이미지

OOS Accumulated Profits

JJSHBB_2019_v25n1_63_f0012.png 이미지

Back-test using genetic algorithm

JJSHBB_2019_v25n1_63_f0013.png 이미지

Compare Return Curves

Walk Forward Analysis Test Case

JJSHBB_2019_v25n1_63_t0001.png 이미지

Simulation Report

JJSHBB_2019_v25n1_63_t0002.png 이미지

Final Result

JJSHBB_2019_v25n1_63_t0003.png 이미지

References

  1. Baek, J. W. and S. Z. Cho, ""Left Shoulder" Detection in Korea Composite Stock Price Index Using an Auto - Associative Neural Network and Sign Variables," Proc. of the KISS conference, Vol.27, No.2II(2000), 320-322.
  2. Bao, D. and Z. Yang, "Intelligent Stock Trading System by Turning Point Confirming and Probabilistic Reasoning," Expert Systems with Applications, Vol.34, No.1(2008), 620-627. https://doi.org/10.1016/j.eswa.2006.09.043
  3. Bulkowski, T. N., Getting Started in Chart Patterns, Wiley, New Jersey, 2006.
  4. Cao, L. J. and F. E. H. Tay, "Support Vector Machine with Adaptive Parameters in Financial Time Series Forecasting," IEEE Transaction on Neural Networks, Vol.14, No.6(2003), 1506-1518. https://doi.org/10.1109/TNN.2003.820556
  5. Fama, E. F., "Efficient capital markets: A review of theory and empirical work," Journal of Finance, Vol.25, No.2(1970), 383-417. https://doi.org/10.1111/j.1540-6261.1970.tb00518.x
  6. Han, H., Let's find out by pattern and trading with indices, Saenghwaljihyesa, 2000.
  7. Harris, S. J., TradeStation made easy! : using EasyLanguage to build profits with the world's most popular trading software, Wiley, New Jersey, 2011.
  8. Hill, A., Using the ZigZag Feature for Elliott Wave Counts, StockCharts, 2010. Available at http://stockcharts.com/articles/mailbag/2010/11/using-the-zigzag-feature-for-elliott-wave-counts.html (accessed 20 May, 2018).
  9. Kamijo, K. and T. Tanigawa, "Stock Price Pattern Recognition-a Recurrent Neural Network Approach-," International Joint Conference on Neural Networks, (1990), 215-221.
  10. Kim, J. H., Description of the chart, Iremedia, 2013.
  11. Kim, M. J., "Optimization of Ensemble of SVMs Using Genetic Algorithms," Proc. of the KASBA conference, (2009), 1-14.
  12. Kim, S. W. and H. Ahn, "Development of an Intelligent Trading System Using Support Vector Machines and Genetic Algorithms," Journal of Intelligence and Information Systems, Vol.16, No.1(2010), 71-92.
  13. Kim, W. J., Real Stock Chart Analysis, Joheunttang, 2016.
  14. Lee, J. and C. G. Han, "Forecasting System of KOSPI 200 using Patterns," Proc. of the KISS conference, Vol.30, No.2I(2003), 508-510.
  15. Lee, J. S. and H. Ahn, "A Study on the Prediction Model of Stock Price Index Trend based on GA-MSVM that Simultaneously Optimizes Feature and Instance Selection," Journal of Intelligence and Information Systems, Vol.23, No.4(2017), 147-168. https://doi.org/10.13088/JIIS.2017.23.4.147
  16. Lee, J. W., "A Stock Trading System based on Moving Average Patterns and Turning Point Matrix," Journal of KIISE : Computing Practices and Letters, Vol.18, No.7(2012), 528-532.
  17. Lee, J. W., "A Stock Trading System based on Supervised Learning of Highly Volatile Stock Price Patterns," Journal of KIISE : Computing Practices and Letters, Vol.19, No.1(2013), 23-29.
  18. Lee, J. W. and J. O, "Integrated Multiple Simulation for Optimizing Performance of Stock Trading Systems based on Neural Networks," Journal B of KIPS, Vol.14, No.2 (2007), 127-134.
  19. Lee, S. Y., et al., 7th Sense, System Trading with CybosTrader, Daishin Economic Research Institute, 2004.
  20. Leigh, W., N. Modani, R. Purvis and T. Roberts, "Stock Market Trading Rule Discovery Using Technical Charting Heuristics," Expert Systems with Applications, Vol.23, No.2(2002), 155-159. https://doi.org/10.1016/S0957-4174(02)00034-9
  21. Levy, R. A., "The Predictive Significance of Five-Point Chart Patterns," Journal of Business, Vol.44, No.3(1971), 316-323. https://doi.org/10.1086/295382
  22. Liu, J. N. K. and R. W. M. Kwong, "Automatic Extraction and Identification of Chart Patterns towards Financial Forecast," Applied Soft Computing Journal, Vol.7, No.4(2007), 1197-1208. https://doi.org/10.1016/j.asoc.2006.01.007
  23. Merrill, A. A., "M&W WAVE PATTERNS," Market Technicians Association (MTA) Journal, (1980), 43-54.
  24. Merrill, A. A., "M and W WAVES - MORE DATA." Market Technicians Association (MTA) Journal, (1984), 23-29.
  25. Mitchell, M., An Introduction to Genetic Algorithms, The MIT Press, Massachusetts, 1996.
  26. Pardo, R., The Design, Testing, and Optimization of Trading Systems, Wiley, New Jersey, 1992.
  27. Pardo, R., The Evaluation and Optimization of Trading Strategies, Wiley, New Jersey, 2008.
  28. Ryu, J., H. J. Shin, M. H. Kim and J. Baek, "Pattern Analysis of Stock Prices Using Machine Learning and Data Visualization," Journal of Information Technology and Architecture, Vol.14, No.2(2017), 189-197.
  29. Shiller, R. J., "The Use of Volatility Measures in Assessing Market Efficiency," The Journal Of Finance, Vol.36, No.2(1981), 291-304. https://doi.org/10.1111/j.1540-6261.1981.tb00441.x
  30. Yoon, J. S., Follow chart analysis, Gilbert, 2017.
  31. Zbikowski, K., "Using Volume Weighted Support Vector Machines with Walk Forward Testing and Feature Selection for the Purpose of Creating Stock Trading Strategy," Expert Systems with Applications, Vol.42, No.4 (2015), 1797-1805. https://doi.org/10.1016/j.eswa.2014.10.001