Finding and Back-Testing Candlestick Patterns with Python
Sofien Kaabar

#Python
#Financial
#Pattern_Recognition
#OHLC
Candlesticks have become a key component of platforms and charting programs for financial trading. With these charts, traders can learn underlying patterns for interpreting price action history and forecasts. This A-Z guide shows portfolio managers, quants, strategists, and analysts how to use Python to recognize, scan, trade, and back-test the profitability of candlestick patterns.
Financial author, trading consultant, and institutional market strategist Sofien Kaabar shows you how to create a candlestick scanner and indicator so you can compare the profitability of these patterns. With this hands-on book, you'll also explore a new type of charting system similar to candlesticks, as well as new patterns that have never been presented before.
With this book, you will:
Table of Contents
Chapter 1. Importing and Processing Financial Data in Python
Chapter 2. Algorithmic Mindset and Functions
Chapter 3. Introducing Technical Analysis
Chapter 4. Classic Trend-Following Patterns
Chapter 5. Modern Trend-Following Patterns
Chapter 6. Classic Contrarian Patterns
Chapter 7. Modern Contrarian Patterns
Chapter 8. Advanced Candlestick-Charting Systems
Chapter 9. Candlestick Patterns Exit Techniques
Chapter 10. Candlestick-Based Trend-Following Strategies Chapter 11. Candlestick-Based Contrarian Strategies
Chapter 12. Risk Management and Trading Psychology
'Finding patterns is the essence of wisdom.' -- Dennis Prager
With technological progress and the decentralization of financial information, coding and automated research have become integral parts of the trading world. Anyone who masters the art of trading and coding has a tremendous edge in the markets.
Trading techniques are numerous, and they can be based on many tools and concepts. For example, fundamental traders rely on economic and political analyses to derive a long-term view on different assets, while technical traders rely on more quantitative measures and a few psychological concepts to forecast the next likely moves of the markets.
Therefore, we can say that on a high level there exist two types of analyses, fundamental and technical. This book will present in detail a field in technical analysis called candlestick pattern recognition.
Why This Book?
I have spent my career researching trading strategies, patterns, and anything related to the financial world. I have developed a special passion for patterns, and specifically candlestick patterns, due to their widespread adoption but also their interesting performance results. Moreover, throughout the years, I have discovered a few candlestick patterns that I believe can at least rival the classical patterns. This brings us to the purpose of writing the book: I am aiming to present the totality of candlestick patterns, including my personal ones, and how to code a system that back-tests them across a wide variety of markets.
Machines can perform pattern recognition and detection better than humans because of their objectivity. Therefore, I have dedicated the first chapters of the book to creating the structure of a candlestick pattern recognition algorithm before moving on to dig deep into patterns and strategies in the later chapters. This means that the first skill you will learn is how to automate the data import process in Python.
There are many classical candlestick patterns, and it is everyone’s duty to test them to see whether they actually are predictive. After all, if we use these patterns to forecast the markets, we should have objective results that prove they are indeed value-adders. We will get such results and interpret them, just as I do with the candlestick patterns that I have discovered over the years. We will also see the advantages and limitations of every pattern.
When we do find the good patterns that help with the predictive task, you should insert them in the overall trading framework, which includes other tools and a risk management system. You will learn how to code technical indicators and combine them with candlestick patterns to create trading signals. Finally, you will back-test these signals, and you will be able to optimize the parameters so that you get a good full-scale pattern recognition strategy.
Hence, the utility of this book is to show you how to automate your research by letting the algorithms you create evaluate the different candlestick patterns. Finally, you will learn how to determine your strategy, which will use the patterns and combine with other technical indicators.
Target Audience
This book is suited to aspiring students, academics, curious minds, and finance practitioners who are interested in candlestick pattern recognition and its applications in finance. You will benefit from this book if you are interested not only in using Python but also in developing strategies and technical indicators.
The book assumes you have basic background knowledge in both Python programming (professional Python users will find the code very straightforward) and financial trading. I take a clear and simple approach that focuses on the key concepts so that you understand the purpose of every idea.









