Preface....6
Why This Book?....6
Target Audience....7
Conventions Used in This Book....8
Using Code Examples....9
O’Reilly Online Learning....10
How to Contact Us....10
Acknowledgments....11
1. Importing and Processing Financial Data in Python....12
Installing the Environment....12
Creating the Importing Algorithm....16
Putting It All Together....23
Summary....25
2. Algorithmic Mindset and Functions....27
Coding the Primal Functions....28
The Function to Add Columns to an Array....28
The Function to Delete Columns from an Array....30
The Function to Add Rows to an Array....32
The Function to Remove Rows from an Array....32
The Function to Round Numbers....34
Coding Signals....36
Creating the Signal Charts....42
Coding Performance Evaluation Functions....50
The Hit Ratio....51
The Rate of Return....51
The Profit Factor....53
The Risk-Reward Ratio....53
The Number of Trades....56
Creating a Performance Evaluation Function....56
A Hypothetical Example: Appraising Performance....60
3. Introducing Technical Analysis....63
Charting Analysis....66
Indicator Analysis....78
Moving Averages....78
The Relative Strength Index....81
Pattern Recognition....85
Common Pitfalls of Technical Analysis....88
Wanting to Get Rich Quickly....88
Forcing the Patterns....88
Hindsight Bias, the Dream Smasher....89
Assuming That Past Events Have the Same Future Outcome....89
Making Things More Complicated Than They Need to Be....90
Technical Analysis Best Practices....90
Harness the Power of Different Time Frames....90
Use More Than One Strategy or Indicator....91
Choose the Right Type of Strategy for Current Market Conditions....91
Don’t Underestimate Default Parameters....92
4. Classic Trend-Following Patterns....93
The Marubozu Pattern....93
The Three Candles Pattern....101
The Tasuki Pattern....108
The Three Methods Pattern....116
The Hikkake Pattern....120
5. Modern Trend-Following Patterns....125
The Quintuplets Pattern....125
The Double Trouble Pattern....133
The Bottle Pattern....144
The Slingshot Pattern....149
The H Pattern....155
6. Classic Contrarian Patterns....161
The Doji Pattern....161
The Dragonfly Doji....163
The Gravestone Doji....164
The Flat Doji....164
The Double Doji....165
The Tri Star Doji....165
The Harami Pattern....170
The On Neck Pattern....179
The Tweezers Pattern....185
The Stick Sandwich Pattern....190
The Hammer Pattern....195
The Star Pattern....199
The Piercing Pattern....203
The Engulfing Pattern....209
The Abandoned Baby Pattern....213
The Spinning Top Pattern....217
The Inside Up/Down Pattern....221
The Tower Pattern....226
7. Modern Contrarian Patterns....231
The Doppelgänger Pattern....231
The Blockade Pattern....237
The Euphoria Pattern....241
The Barrier Pattern....247
The Mirror Pattern....252
The Shrinking Pattern....257
8. Advanced Candlestick-Charting Systems....261
Heikin-Ashi System....261
Detecting the Doji Pattern....263
Detecting the Tasuki Pattern....265
Detecting the Euphoria Pattern....268
Detecting the Double Trouble Pattern....269
K’s Candlesticks System....271
Detecting the Doji Pattern....272
Detecting the Tasuki Pattern....274
Detecting the Euphoria Pattern....275
Detecting the Double Trouble Pattern....276
9. Candlestick Patterns Exit Techniques....278
The Symmetrical Exit Technique....279
The Fixed Holding Period Exit Technique....282
The Variable Holding Period Exit Technique....283
The Hybrid Exit Technique....284
Pattern Invalidation....285
10. Candlestick-Based Trend-Following Strategies....288
Combining the Double Trouble Pattern with the RSI....288
Combining the Three Candles Pattern with Moving Averages....291
Combining the Bottle Pattern with the Stochastic Oscillator....295
Combining the Marubozu Pattern with K’s Volatility Bands....300
Combining the H Pattern with the Trend Intensity Index....308
11. Candlestick-Based Contrarian Strategies....313
Combining the Doji Pattern with the RSI....313
Combining the Engulfing Pattern with Bollinger Bands....316
Combining the Piercing Pattern with the Stochastic Oscillator....319
Combining the Euphoria Pattern with K’s Envelopes....321
Combining the Barrier Pattern with the RSI-ATR....325
12. Risk Management and Trading Psychology....330
Basics of Risk Management....330
Stops and Targets....330
Trailing Stops....331
Position Sizing....331
Economic Calendar....334
Behavioral Finance: The Power of Biases....335
Cognitive Biases....336
Emotional Biases....339
Trading Framework....340
Index....343
About the Author....378
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.