Is candlestick pattern effective in Bursa Malaysia?
7 minutes read (About 980 words)
If you have been investing or trading stocks you must have come across about Japanese Candlestick Pattern. How effective are them? Can we use them reliably in investing or trading? Let’s find out.
I assume that you already knew the anatomy of a candlestick so I will skip the explanation part.
There are dozens of candlestick pattern out there, be it bullish or bearish ones, what we wanted to know is that can we used them reliably in our investing and trading activities.
Methodology - Skip this part if you’re not into tech
It is possible to handcode a program to identify every pattern but that will be a lot of workload. Fortunately, there is a python library called TA-Lib, which included the identification of candlestick pattern given price data. In this study, 10 years worth of daily price data (Open, Low, High, Close) was scraped online and saved into a .csv file.
I have written a piece of code that will iterate over the price data to find candlestick pattern. Comment below if you wanted a copy of the code and data.
Loading the patterns
We need pandas module for data processing, and talib for it’s fast and ready-made candle recognition capability. After that, we need to make a list of every pattern that we wanted to backtest.
pandas as pd
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
import talib import os pd.set_option('expand_frame_repr', False)
Candlestick analysis are mostly used by short term traders, so the days I wanted to backtest are in short term as well.
1 2 3 4 5 6 7 8 9 10
days = [1,5,10,30]
path = os.getcwd() print('current working directory:',path) stock_code_list =  for root, dirs, files in os.walk(path): if files: for f in files: if '.csv' in f: stock_code_list.append(f.split('.csv'))
The performance of each candlestick is measured by how likely it will go up in (1,5,10,30) days. A win rate of 0.7 means that in 7 out of 10 times the price will go up after the pattern appeared.
Here’s the entire backtesting results!
Very surprisingly some bullish pattern has very low win rate, my thinking is that when a pattern is too widely known and used, the edge of the pattern diminishes as everyone knows the information making it useless. Besides, the findings also showed very little pattern with winrate more than 50% (I thought I will found my golden formula here :disappointed: ). However there is some relatively high winrate patterns with winrate over 0.45. Perhaps with enough risk management techniques you might be able to construct a consistently profitable strategy.
Of course there are something this study misses, for example, some candlestick pattern are only effective while they are on top of the trend etc. Nevertheless this brings me a general view of the effectiveness of candlestick pattern.
I am wondering combined with other technical indicators will the winrate be higher? Also, the low winrate doesn’t mean that it is worthless. A 20% winrate indicats there it is 80% likely that the price will drop tomorrow. How about using this as a indicator for shorting of stocks? Well, I leave this to you guys to figure out. Let me know what you think in the comments.
This study is purely for discovery and fun. Please be responsible of your own money and trade at your own risk.