Effective Trading in Financial Markets Using Technical Analysis
Effective Trading in Financial Markets Using Technical Analysis
This book provides a comprehensive guide to effective trading in the financial markets
through the application of technical analysis through the following:
The book will be essential for scholars and researchers of finance, economics and management
studies, as well as professional traders and dealers in financial institutions (including banks)
and corporates, fund managers, investors, and anyone interested in financial markets.
Smita Roy Trivedi is Assistant Professor, International Banking and Finance Group at the
National Institute of Bank Management, Pune, India. She has been engaged in teaching,
training, and research in international banking, technical analysis, and algorithmic trading.
Her publications include the book Financial Economy: Evolutions at the Edge of Crises
(co-authored with Sutanu Bhattacharya, 2018). Her research has been published in Empirical
Economics, Economic Papers, and Asia-Pacific Financial Markets.
Ashish H. Kyal is Founder of Waves Strategy Advisors, based in Mumbai, India, a Chartered
Market Technician (CMT) and member of CMT-USA. He has worked with leading invest-
ment banks such as Lehman Brothers and Nomura Holdings. His articles have appeared in
newsletters of CMT-USA, International Federation of Technical Analysts (IFTA-London)
Reuters, and Bloomberg and a research paper in the Journal of the Society of Technical Analysts.
He is a frequent speaker on CNBC TV18, ET NOW, Bloomberg Quint, Rajya Sabha TV,
and National Institute of Bank Management.
‘Investors ignore technical analysis near the end of bull markets, when buy and hold
is in vogue. Today the approach is at a nadir of interest, just when people need it
most. Get ahead of the next rush to understand and apply technical analysis. In
their comprehensive overview, Roy Trivedi and Kyal first introduce you to the key
terms of financial markets and then elucidate all established aspects of the technical
analysis field. If you start with this book, you will have a foundation for deciding
the next step to take in expanding your knowledge.’
– Robert R. Prechter, Elliott Wave theorist, author and
co-author of 14 books, including Elliott Wave Principle,
and Conquer the Crash (New York Times best seller, 2002)
‘There are lots of books about technical analysis available, but almost all of them are
written by practitioners. Thus, a collaboration of academic and practitioner, as seen
in this book, is rare but welcome. The lacking interest of academics in technical
analysis is driven by the wide acceptance of the efficient market hypothesis. It seems
very intuitive that financial market actors trade on the information available to
them and that this leads to adjusted prices. Any other behavior would be irrational.
Moreover, such behavior would be punished by future price developments of
financial prices so that these markets reinforce rational behavior.
Seen from this perspective, the price of a financial asset depends on its future returns,
discounted by interest rates and considering its riskiness. The role of fundamental anal-
ysis is then trying to learn about these determinants. In this world, there is no role for
technical analysis. What should we learn from looking backwards if the price is only
determined by future developments? At least this is the world of finance as it should
be in principle. In reality, however, we know that markets are imperfect. This book
rightly discusses in its Chapter 1, imperfections which may “justify” the use of techni-
cal analysis. Overall, there are good theoretical and empirical reasons why technical
analysis can be a useful tool to forecast financial market developments (e.g., Hsu et al.,
2016). However, as is true for fundamental analysis, the use of an analytical tool – and
technical analysis is such a tool – requires expertise. This book provides some academic
background in the beginning and then introduces and explains the main concepts of
technical analysis. The presentation is clear and applied, providing many examples and
also links to programming. Thus, I highly welcome this book which contributes to
compile and spread expertise on technical analysis in financial markets.’
– Lukas Menkhoff, head of department, International Economics,
DIW Berlin (the German Institute for Economic Research)
‘Those who dismiss technical analysis as unscientific have to confront the long and
consistently profitable track records of legendary traders such as Linda Raschke.
Whether you are studying technical analysis as a skeptic or a believer, Roy Trivedi
and Kyal’s book will serve as a comprehensive guide. The chapter on algorithmic
trading is particularly helpful to those who plan to implement technical analysis in
an automated program.’
– Ernest P. Chan, author of Quantitative Trading, Algorithmic Trading:
Winning Strategies and Their Rationale and Machine Trading:
Deploying Computer Algorithms to Conquer the Markets
‘In the last four decades, “Technical Analysis” (TA) has become an important tool
in the hands of analysts, researchers and practitioners in any financial /commodity
markets. While fundamental analysis continues to be the mainstay of traditional
market analysts, advent of technology has made the role of TA as important as that
of fundamental analysis, if not more.
Given this trend, I feel that the book on TA by Smita and Ashish will be a very
handy guide to any intending market specialist. The USP of this book is that it
helps the reader in climbing up the learning curve on the subject in a smooth glide
path but at the same time, without compromising on the thoroughness. Start-
ing from the basic principles, the book traverses through a large canvas which
includes study of patterns (reversal and continuation), candlesticks, moving aver-
ages, momentum, volume, and volatility indicators and finally concludes with a
glimpse of algorithmic trading. The authors employ a very simple and lucid style
to explain even difficult concepts with appropriate illustrations. I am sure the book
will evoke an enthusiastic response from the readers.’
– G. Mahalingam, whole time member, Securities and
Exchange Board of India, and former executive director,
Reserve Bank of India
‘Smita and Ashish have put together a comprehensive piece of work on how to
effectively use technical analysis (TA) in today’s financial markets. The book is
thoroughly researched, and a lot of references and credits are made to academic
studies and well-respected technical analyses by authors throughout. They start with
laying out the groundwork and foundations of financial markets and trading (infra)
structure, especially in India, before even touching on analyses techniques which
give the reader a solid foundation for understanding the TA concepts further on.
The main part of the book on TA, covers the most important and popular
approaches in the field. Starting with various charting formats, then moving on to
more subjective analyses tools like trends, price patters, indicators and even Elliott
Wave, to finish with more quantitative tools and rules-based trading using tools like
Excel and Python.
Although the majority of examples and explanations are geared towards the
Indian markets, the language of technical analysis is universal. I recommend this
book for every aspiring Technical Analyst who wants to get a solid understand-
ing of the general TA framework and the various technical analysis tools that the
authors discuss.’
– Julius de Kempenaer, senior technical analyst at Stockcharts.com,
director of RRG Research, and the creator of Relative
Rotation Graphs(R)
EFFECTIVE TRADING IN
FINANCIAL MARKETS
USING TECHNICAL
ANALYSIS
2.3.4 Candlesticks 23
2.3.5 Heinken Ashi candlestick 23
2.4 Dow Theory and its application 26
2.4.1 Basic tenets of technical analysis 26
2.4.2 Main criticisms of Dow Theory 28
2.5 Trend analysis 29
2.5.1 Definition of trend 29
2.5.2 Drawing trend lines 29
2.5.3 Support and resistance 32
2.5.4 Potential support and resistance patterns 32
2.6 Use of trend analysis in trading 34
2.6.1 Fan principle 34
2.6.2 Channel line 35
2.6.3 Retracements 37
2.6.4 Case studies 39
2.7 Key takeaways 42
11 Conclusion 246
References254
Index260
FIGURES
5.3 AMA and EMA on the Euro. Created with Eikon, Refinitiv 101
5.4 Moving average as support and resistance. Created with Eikon,
Refinitiv104
5.5 Comparing AMA, centred moving average, and EMA. Created
with Eikon, Refinitiv 104
5.6 Double crossover on the State Bank of India (30-minute chart).
Created with Eikon, Refinitiv 107
5.7 Sideways movement and moving averages. Created
with Eikon, Refinitiv 107
5.8 Triple crossover. Created with Eikon, Refinitiv 108
5.9 Using moving averages: EUR/USD (daily chart). Created with
Eikon, Refinitiv 110
5.10 Gold futures in INR (daily chart). Created with Amibroker 111
6.1 Movement of prices reflected by moving average and momentum 116
6.2 Moving average and momentum on the GBP (daily chart).
Created with Eikon, Refinitiv 117
6.3 RSI: negative divergence. Created with Eikon, Refinitiv 121
6.4 RSI: positive divergence. Created with Eikon, Refinitiv 121
6.5 MACD. Created with Eikon, Refinitiv 123
6.6 MACD with MACD forest. Created with Eikon, Refinitiv 124
6.7 %D and %K line on EUR chart. Created with Eikon, Refinitiv 125
6.8 SBI combined analysis. Created with Amibroker 127
6.9 Nifty 50 index (monthly chart). Created with Eikon, Refinitiv 129
6.10 Nifty daily chart analysis (May–July 2019). Created with Eikon,
Refinitiv129
6.11 Nifty 50 Index (weekly chart). Created with Amibroker 130
6.12 Nifty daily chart analysis (July 2019–April 2020). Created with
Amibroker131
6.13 Nifty 50 Index (hourly chart). Created with Amibroker 132
7.1 Moving average envelopes. Created with Eikon, Refinitiv 137
7.2 Bollinger Bands (EUR hourly chart). Created with
Eikon, Refinitiv 139
7.3 Bollinger Bands overbought and oversold levels
(EUR hourly chart). Created with Eikon, Refinitiv 140
7.4 Bollinger Bands (Nifty daily chart). Created with Amibroker 141
7.5 ATR (EUR hourly chart). Created with Eikon, Refinitiv 142
7.6 Volume and volume ROC on SBI (daily chart). Created with
Eikon, Refinitiv 144
7.7 Chaikin Money Flow Index on SBI (daily chart). Created with
Eikon, Refinitiv 145
7.8 Reliance industries (daily chart). Created with Amibroker 146
7.9 Nifty 50 (daily chart). Created with Amibroker 148
8.1 The basic pattern 152
8.2a Wave 2 completely retraced wave 1: not allowed 153
xvi Figures
8.2b Wave 3 is the shortest among impulse waves: not allowed 153
8.2c Wave 4 enters the territory of wave 1: not allowed 154
8.3 Degrees of waves 155
8.4 Wave 3 extended and subdivided 156
8.5 Impulse pattern (Nifty hourly chart). Created with Amibroker 156
8.6 Ending diagonal pattern 157
8.7 Ending diagonal pattern (Nifty daily chart). Created
with Amibroker 158
8.8 Fifth failure pattern 159
8.9 Fifth failure pattern (Maruti weekly chart). Created
with Amibroker 160
8.10 Zigzag pattern 161
8.11 Zigzag pattern (Nifty daily chart). Created with Amibroker 162
8.12 Double zigzag pattern 163
8.13 Triple zigzag pattern 163
8.14a Flat pattern correcting up move 164
8.14b Flat pattern correcting down move 165
8.15a Irregular flat correcting up move 166
8.15b Irregular flat correcting down move 166
8.16 Running flat correction 167
8.17a Double flat correction 168
8.17b Double flat correction 168
8.17c Triple flat correction 169
8.18 Double zigzag correction (EUR/USD weekly chart). Created
with Amibroker 169
8.19 Triangular pattern 170
8.20a Triangular pattern with an irregular wave B 171
8.20b Irregular triangle pattern in a bear market 172
8.21 Triangle pattern (ICICI Bank weekly chart). Created
with Amibroker 172
8.22a Bow-Tie Diametric pattern in a bear market 173
8.22b Diamond-shaped Diametric pattern in a bull market 174
8.23 Bow-Tie Diametric pattern (Facebook daily chart). Created
with Amibroker 174
8.24 Alternation between wave 2 and wave 4 175
8.25a Double combination pattern 176
8.25b Double combination pattern 176
8.26a Triple combination pattern 177
8.26b Triple combination pattern 177
8.26c Triple combination pattern 178
8.27 Triple zigzag pattern (Nifty daily chart). Created with Amibroker 178
8.28 Channels (Maruti weekly chart). Created with Amibroker 181
8.29 Application of an Elliott wave (DJIA weekly chart). Created
with Amibroker 181
Figures xvii
8.30 Impulse pattern (DJIA weekly chart). Created with Amibroker 182
9.1 Characteristic of cycles 187
9.2 Nested cycles 190
9.3 Time cycles (Nifty daily chart). Created with Amibroker 191
9.4 Cyclicality (DJIA weekly chart). Created with Amibroker 192
9.5 Cyclicality with momentum indicator (DJIA weekly chart).
Created with Amibroker 193
9.6 Detrending using a ratio of price to a 39-month centred
moving average (DJIA monthly chart). Created with Amibroker 194
9.7 39-week centred moving average with 20% envelope (Alcoa
weekly chart). Created with Amibroker 195
9.8 109-day time cycle with a 55-day envelope and detrended
oscillator (Nifty daily chart). Created with Amibroker 196
9.9 86-week time cycle and an Elliott Wave pattern (USD/INR
weekly chart). Created with Amibroker 197
9.10 164-week time cycle and Elliott Wave pattern (Berger Paints
weekly chart). Created with Amibroker 198
9.11 Time cycles and Elliott Waves (USD/INR weekly chart).
Created with Amibroker 199
9.12 Time cycles and Elliott Waves (Nifty daily chart). Created
with Amibroker 201
10.1 Accessing data from Eikon: flow chart 221
10.2 Downloading Python from Anaconda: flow chart 222
10.3 Python output (INR open prices) 236
10.4 Python output (HDFC adjusted close and open prices) 238
10.5 Python output (HDFC adjusted close, EMA 30, EMA 40) 239
10.6 Python output (HDFC adjusted close, EMA 30, EMA 40
using loc) 240
11.1 Global indices at a glance, 2009–2020 (monthly chart).
Created with Amibroker 247
11.2 Crude oil (monthly chart). Created with Eikon, Refinitiv 247
11.3 EUR/USD (monthly chart). Created with Eikon, Refinitiv 248
11.4 The DJIA and the Nifty 50 (daily chart). Created with Amibroker 249
11.5 The DJIA (daily chart) technical outlook before the crash
of October 1987. Created with Amibroker 250
11.6 DJIA (daily chart) technical outlook before the crash of
February 2020. Created with Amibroker 251
11.7 Relative performance of US sectors during 2008 fall. Created
with Amibroker 252
11.8 Relative performance of Indian sectors during 2020 fall.
Created with Amibroker 252
TABLES
It is but human nature to look for patterns. From the movement of the earth to
the starry patterns in the sky, from the waves in the sea to the cycles of life, it is the
quest for pattern, rhythm, and cycles which distinguishes the human relationship
with nature. Is it surprising then that we look for such patterns in our economies
and financial markets? The existence of patterns or the lack thereof (a random
walk, perhaps?) form the core of our analysis of financial markets. Technical analysis
is a quest for such patterns, patterns in the past which would allow us to look into
the future with more certainty. To predict the future movement of the markets, we
look into the canvas of the past for hidden designs. Not surprisingly, Charles Dow,
whose writings lie at the genesis of technical analysis, compared trends of varying
time frames to the tides, waves, and ripples of the sea (Dow and Sether 2009). In
financial markets, it is the existence of these patterns that brings in a structure for
trading decisions. In this book, we take you on a journey to identify those struc-
tures, enabled by the myriad approaches to technical analysis.
Globally, financial markets have faced sharp movements and seemingly unpre-
dictable turns in the last few years. The last 10 years have seen an economic down-
turn, a trade war, and, finally, a pandemic play out in the financial markets. It is
useful to tell ourselves the power of patterns remains undiminished even amongst
the seeming chaos. If you look at the Dow Jones Industrial Average (DJIA) from
the 1987 crash and the chart of the Nifty Index for 2020 so far, the precipitous fall
remains uncannily similar (for relevant charts, see the Conclusion of this book).
Technical analysis in this scenario can give the much-needed tools to traders for
navigating the labyrinth of the volatile financial markets.
That said, there are several books available on technical analysis. From tomes
that every technical analyst has grown up reading, such as John Murphy, Martin
Pring, Robert Prechter, to newer books by Kirkpatrick and Dahlquist, Ernest P
Chan (on algorithmic trading), this book stands on the solid foundation laid by
Preface xxi
other technical analysts. The book owes to the academic research on technical
analysis by economists such as Lukas Menkhoff, Mark P. Taylor, Christopher J.
Neely, George E. Pinches, and Peter Saacke.
Why then this volume? First, this book brings forth a juxtaposition of the aca-
demic and practitioner perspectives on technical analysis. We have combined in
this book a focus on the conceptual clarity associated with each technical approach,
case studies which underline the practical application of these technical analysis
concepts, and snippets of academic research that put the technical analysis approach
in a bigger perspective.
Second, there is always more to say on technical analysis than is available. Each
day brings in newer applications and case studies and a better understanding of what
works in the markets. With the present global pandemic, we have put together
cases from different asset classes and markets demonstrating the purposeful applica-
tion of technical tools.
Third, in our role as teachers, we have felt a need for a structured approach to
learning technical analysis covering each important domain including the backtest-
ing of the technical analysis strategies. This book has a rounded approach to learn-
ing technical analysis to keep up with the changing skill sets required.
We have underlined the practical application by using as many cases as possible
and relating them with the overall context of the market. We showcased trend fol-
lowing methods that traders can adopt to ride the trend, using simple but effective
methods. Last but not least, we have combined advanced methods like the Elliott
Wave with time cycles and other technical indicators in an easy, understandable,
and systematic fashion along with a few trade set-ups.
covers in detail the analysis of trend through the definition of trend lines, the draw-
ing of trend lines, and the identification of support and resistance patterns. Focused
case studies on recent market movement are brought in to underline the applica-
tion of trend analysis.
Chapter 3 takes up classical technical analysis which stems from the broad
notion underlying Dow Theory. The classical patterns embody the essentials of
technical analysis, with a belief that patterns are repetitive and can be used to pre-
dict the future price movement. The visual patterns are formations appearing on
the charts, which can help us to predict a reversal or a continuation in the trend.
Price forecasting requires a careful understanding of the prior movement and the
reason behind the formation of the pattern to be able to predict future prices cor-
rectly. The chapter considers in detail the important reversal and continuation pat-
terns with recent case studies.
Candlesticks, traditionally used by traders of the East, go back a long way in his-
tory, to the legendary Munehisa Homma, who used the candlesticks for trading in
the Japanese rice market during the late 18th century. With their introduction to
the Western world, the popularity of the candlestick patterns has immensely grown.
What lies behind the popularity of candlesticks is that it brings in the simplicity of
the patterns with a rich understanding of market psychology. In Chapter 4, we
consider in detail the concept of candlesticks and reversal and continuation pat-
terns. The patterns are supplemented by case studies to explain how candlesticks
patterns can be traded effectively.
Prices demonstrate a tendency to move towards the mean values historically
so that mean reversion is one of the commonly observed phenomena of financial
markets. If prices do indeed tend to move towards the mean, it is important to
understand how this can be used to generate effective trading signals. Chapter 5
details the concept of ‘mean’ or ‘average’ and its use in trading. Moving averages are
frequently used to understand the general trend in the market and act as dynamic
support and resistant to the price movement. The chapter discusses in detail the
various kinds of moving averages and their use in trading. The chapter takes up
the crossover methodology for generating trade signals, discussing the Double and
Triple Crossover strategies as well as the use of moving averages of different time
frames with recent case studies.
This chapter takes up momentum indicators and stochastics, one of the most
popular technical analysis indicators. If moving average shows the direction of the
trend, Momentum gives the strength of the trend. Chapter 6 begins with a dis-
cussion of the concept of Momentum and how it shows the strength in the trend,
by considering a simple momentum indicator: the Rate of Change (ROC). The
chapter then takes up two of the most popular momentum-based indicators: the
Relative Strength Index (RSI) and the Moving Average Convergence Divergence
(MACD). Stochastics which use the position of price in a range to generate trad-
ing signals are discussed next. Stochastics show whether prices are in the upper or
lower end of the trading range and are therefore much suited for swing recognition
and reversal confirmations. Chapter 6 puts together in the last section detailed cases
Preface xxiii
studies on recent market movement to show how the various momentum indica-
tors can be used effectively for trading.
Chapter 7 takes up the volatility indicators most popularly used by traders,
namely Bollinger Bands and the average true range (ATR). Furthermore, the
understanding of volatility is combined with the knowledge of how to use volume
for trading, as there is strong support to the link between volume and volatility.
Chapter 7 takes up two important volumes-based indicators, the volume oscillator
and the Chaikin Money Flow Index, which can help us refine the trading deci-
sions. Chapter 7 ends with recent case studies showing the effective use of volatility
indicators for trading.
Chapter 8 takes up one of the most intriguing technical analysis approaches,
the Elliott Wave theory, which uses the concept of the fractal nature to form an
in-depth understanding of the trend in a market over a long period. Developed by
Ralph Nelson Elliott in the 1930s, in an Elliott Wave, the smallest of the waves
combine together to form higher-degree wave patterns which, in turn, combine
to make a much higher-degree wave construction. This leads to high forecasting
ability of Elliott Wave Theory stretching years ahead. Chapter 8 starts with the
concepts and principles of Elliott Wave Theory. The understanding of impulse and
corrective waves is taken up next, supplemented with cases with detailed analysis
of the patterns. Detailed case studies are used for showing the application of Elliot
Wave techniques.
Chapter 9 gives comprehensive coverage of time cycles and their effective use
for trading. The cycle periodicity can change requiring a trader to keep tweak-
ing the cycle length from time to time to keep it in sync with changing market
dynamics. There are recurring cycles in financial markets, and by identifying the
cyclicality, one can forecast the possible tops or bottoms and accordingly take trad-
ing positions. In this chapter, the foundation is laid with an in-depth understanding
of the concept of time cycles: the characteristic of cycles, left and right translation,
principles of cycles, and detecting the cycle. Chapter 9 then takes up the combin-
ing of time cycles with Elliott Wave Principles, with pertinent case studies, which
correctly used, can be one of the most effective tools for a trader.
The effectiveness of trading on the basis of visual analysis is reduced to the
extent emotions impacts the trader. Algorithmic trading refers to the automation
of the trading process, whereby the generation of buy or sell signals and the execu-
tion of such signals as trades happen on the basis of programmed instructions or
algorithms. It is not surprising therefore that popularity of algorithmic trading has
grown in recent years amongst not only institutional but also retail traders. While
algorithmic trading may be based on either fundamental or technical analysis or
both, the chapter focuses on trading algorithms based on technical analysis, given
the purview of the book. First, a detailed look at the basic concepts behind algo-
rithmic trading is taken up. Chapter 10 then takes up backtesting of trading strate-
gies with Microsoft Excel and Python, two software tools which rank high in terms
of utility and simplicity. For each, the basics of the software are taken up first with
examples, before moving on to the backtesting of trading strategies. The chapter is
xxiv Preface
supplemented with a number of rich eResources which have been crafted keeping
in view the reader who may not have prior knowledge of the two software tools,
Excel and Python.
How best to progress on the journey of learning the technical trading tools? For
the novice trader or new student of technical analysis, we recommend a sequential
read of the chapters. The order of the chapters has been decided by keeping in
mind the escalation of the level of difficulty and time required to master that par-
ticular technical analysis approach. As you learn the concepts in each chapter, we
suggest continued practice on live charts for a thorough understanding.
For the trader experienced in technical trading, we suggest reading Chapters 1
and 2 first for an understanding of the fundamentals of technical analysis. This will
help in getting the maximum out of the book as basic concepts have been clari-
fied in these two chapters to set a strong foundation to the rest of the book. The
remaining chapters in the book can be read standalone as each technical indicator
or approach can be a journey in itself. That said, Chapter 10 (on backtesting and
the introduction to algorithmic trading) requires a knowledge of technical analysis
indicators, so covering Chapters 5, 6, and 7 are prerequisites to its understanding.
Although the book has used a large number of charts for concepts and cases,
charts being the mainstay of technical trading, there are always more resources that
we would want to share with our readers. An understanding of Chapter 10 requires
readers to go through the Excel and Python notebook files which have been used
as examples, included in the eResource on this book’s page on the Routledge
website: www.routledge.com/9780367313555.
An understanding of technical analysis is a continuous process, a journey along
which each application teaches something anew. The process of writing the book
has been elating for us as we appreciated time and again the technical skills required
for recognizing patterns and trends in the market. We hope you find the journey
through the book as exciting!
ACKNOWLEDGEMENTS
Our book stands on the foundation of a rich literature on technical analysis: aca-
demic research, books and articles. We stand in deep appreciation to the legacy of
such work which have shaped our own conception of technical analysis. We find
it extremely encouraging to have received feedback and support from stalwarts in
the field of technical analysis.
We thank Robert R. Prechter (Elliott Wave theorist and author of Elliott Wave
Principle, and Conquer the Crash) for his uncanny observation and guidance espe-
cially for shaping up the Elliott Wave chapter and his minute observations on the
charts. We are touched by his modesty and eagerness to share his knowledge. His
hand-holding during the phase of the book is inspirational for us and vindicates the
fact that we are on correct path and importance of technical analysis is only going
to increase in an impulsive third wave for decades to come!
We thank Lukas Menkhoff (professor and head of department, International
Economics, DIW Berlin, the German Institute for Economic Research) for his
valuable guidance on research directions in technical analysis and his kind support
for the book. His research on technical analysis has remained core to shaping our
understanding of the deeper roots of technical trading profitability as well as helped
to put technical analysis in the bigger perspective of financial market research.
We thank G. Mahalingam (whole time member, Securities and Exchange Board
of India, and former executive director, Reserve Bank of India) for his support and
encouragement for the book. His views and analysis of market events have always
helped to appreciate the underlying currents that shape financial markets. His guid-
ance and mentorship are deeply appreciated.
We thank Ernest P. Chan (author of Quantitative Trading, Algorithmic Trading:
Winning Strategies and Their Rationale and Machine Trading: Deploying Computer
Algorithms to Conquer the Markets) for his encouraging comments on the book.
The future of trading is closely linked to its automation through algorithmic
xxvi Acknowledgements
trading, and his books have guided our perception of application of technical
trading in this field.
We thank Mark Galasiewski (chief equity analyst for Asia and Emerging Markets,
Elliott Wave International), Kamlesh Jain (founder, Innovation India In and The
Attention Institute), Julius de Kempenaer (senior technical analyst at Stockcharts.
com, director of RRG Research, and creator of Relative Rotation Graphs(R)) for
their valuable feedback and review about the book.
A big thank-you to the editorial team of Routledge. Thanks to Shoma
Choudhury for her support and guidance throughout the revision and restruc-
turing of the book. Thanks to Rimina Mohapatra for her patience and prompt
response to our many queries and her constant support through the revision pro-
cess. Thanks to Brinda Sen and Anvitaa Bajaj for their support and cooperation.
Charts in the book have been made using charting tools of Eikon, Refinitiv and
Amibroker: comments on the chart represents the authors’ views. We thank the
anonymous referee(s) for the constructive suggestions which helped immensely
in strengthening the manuscript. Errors, if any, are ours.
Ashish H. Kyal
I would like to thank CMT Association as had it not been for them, I would not
have been known in the field of technical analysis. My special thanks to Bob Pre-
chter, whose work has continued to inspire me even now. His perception about
the social causality called socionomics, with a very different way of looking at
cause and effect in financial world, has always intrigued me. Martin Pring, Ralph
Acampora, and Walter Murphy had been instrumental for shaping up my technical
analysis career by acting as guides and mentors at every aspect. I would not have
the knowledge or understanding about financial markets without learning from
Martin’s books. How can I not thank Mark Galasiewski who has again been a
mentor to me, a guide, and, above that, a friend during difficult market situations.
I would like to thank my students, my mentees and subscribers for believing
in me and my work during various phases of market and trusting my ability with
complete faith and acceptance, especially during times like this of pandemic when
the volatility is at historical levels. They have been inspirational for me to keep
going and exploring various aspect of technical analysis.
I would like to bow towards my Guru – Sadhguru Jaggi Vasudev – who has
been a guiding force that has raised my capability to manage multiple facets of
life during the demanding situations without losing the balance. It is rightly said
that without the blessings and grace of my parents we cannot exist. My father –
Harishanker Kyal – has been an epitome of inspiration who has taught me to
never give up and to always keep moving forward irrespective of the situations.
Words cannot describe the compassion and care of a mother – Kiran – who always
pushed me towards being a better human being above everything else. This book
would not have been possible without the support and understanding of my wife –
Munmun, and I would not have seen myself growing in this field if she would not
have been with me when I was too engrossed in technical analysis over anything
else. I worked relentlessly to make this book happen, but without the support of
my entire family, it would not have been possible. I would like to thank my brother,
Somesh, and sister-in-law, Neeta, who have always inspired and pushed me towards
my goals and exploring my full potential. My children – Jash and Pratyush and my
nieces Pritika and Aarna – have taught me how to be joyful while working which
is very important to create anything with best quality.
1
INTRODUCTION TO TECHNICAL
ANALYSIS
approach, the analysis of price and volume data involves visualization on charts
and/or calculation of various statistical measures of the data. At the core of tech-
nical analysis is the idea that the market movement of an asset in the future is
predictable on the basis of the past, and price (and volume) data alone suffice for
such prediction. Fundamental analysis of assets, on the contrary, would juggle with
several variables for predicting prices. The focus on price (and volume) frees us
from the cacophony of other variables, undoubtedly, adding to the popularity of
technical analysis.
Placing a successful trade requires an understanding of where prices are heading.
Trading effectively is all about forecasting correctly the future price movement.
A trader will buy the security, the price of which is expected to move up and sell
the one, whose price is expected to fall. Similarly, traders in the foreign exchange
market will buy the currency expected to appreciate and sell the one expected to
depreciate.
Traders commonly use fundamental analysis or technical analysis or a combina-
tion of both to forecast the future market movements. Fundamental analysis is a
systemic study of the factors that can impact the price of an asset to predict the
future price of the asset. Investment or trading in an asset class requires a knowl-
edge of the economic factors that move the asset. For equities, the valuation will
majorly depend on company-specific factors, most importantly the financials of the
company and macroeconomic factors that impact the specific industry. For curren-
cies, a host of macroeconomic factors (economic and non-economic) impact the
appreciation or depreciation of the currency. The factors impacting the assets are
frequently modelled and used to forecast future prices. Contrasted with this, tech-
nical analysis is the methodological study of charts and price movement to forecast
prices in any market. It considers market action as reflected in chart patterns and
predicts the future movement of prices based on a specific assumption regarding the
previous patterns. The most important assumption underlying such a prediction is
that the chart patterns seen are repetitive in nature and therefore they can be used
to successfully predict the future movement.
Thus, while fundamental analysis delves into why the market moved the way it
did, technical analysis is unconcerned about the causes of market movement. Fun-
damental analyses of markets thus look at the reasons why the markets have moved.
For example, fundamental analysis of foreign exchange markets considers all the
factors that can impact exchange rate determination while that for equity markets
looks at the macroeconomic variables and company-specific factors relevant to that
stock. This is in contrast to technical analysis which is not concerned about why
markets have moved in the way they have. Technical analysis asks, ‘If markets have
moved as can be seen from the charts, can we predict the way it will move in the
future?’
In this chapter, we present a comprehensive view of the technical analysis para-
digm. We will look at the evidence on the use of technical analysis by profession-
als and research on the profitability of technical analysis. The empirical evidence
on technical analysis lends support to the widespread use of technical analysis by
Introduction to technical analysis 3
professionals. With this we also place technical analysis in the context of the Effi-
cient Market Hypothesis (EMH). To aid our understanding of technical analysis,
and its effective use, we wrap up this chapter with a discussion on the financial
market infrastructure required for trading.
majority of them use technical analysis but that at a forecasting horizon of weeks,
technical analysis is also the most important form of analysis and considered more
important than fundamental analysis.
Technical analysis seems to largely dominate over fundamental analysis in shorter
trading horizons (Allen and Taylor, 1990; Cheung and Chinn, 2001; Gehrig and
Menkhoff, 2006; Menkhoff, 2010). Gehrig and Menkhoff (2006) show that charts
are used for shorter-term forecasting horizons while flows dominate at the shortest
term and fundamentals at a longer horizon. Cheung and Wong (2000), in a survey
covering the forex market in Hong Kong, Tokyo, and Singapore, report 40% of the
respondents saying that technical trading is the major factor determining exchange
rates in the medium run. This study contends that short-run exchange rate dynam-
ics depend on a host of non-fundamental forces in addition to technical trading
(bandwagon effects, overreaction to news, and excessive speculation).
Traders hardly neglect the fundamental factors even when following technicals
staunchly. In fact, technical and fundamental analysis may be more complementary
than initially thought (Cheung et al., 2004; Cheung and Wong, 2000; Gehrig and
Menkhoff, 2006). Cheung et al. (2004), covering the UK-based dealers, iterated
that there was little evidence of a systematic difference of opinion between chartists
and fundamentalists. Gehrig and Menkhoff (2006) point out that professionals rely
on both fundamental and technical analysis, in addition to flow analysis. Cheung
and Wong (2000) argue for combining fundamentals and non-fundamentals in a
unified model for both short-run and long-run exchange rate dynamics. In the
present global economic system with integration in financial markets, news events
often have a destabilizing impact on the financial markets. An awareness of what
goes on behind the chart movement is crucial even when trading on the basis of
technicals alone. While fundamentals and technicals have different approaches to
understanding market movement, for the trader, the use of both is concerned with
how to predict future prices.
1997). Shleifer and Vishny (Ibid) point out that as arbitrage requires capital, it entails
risk. With arbitrage being conducted by specialized professionals with resources of
outside investors (referred to as ‘performance-based arbitrage’), it would be difficult
to take ‘extreme’ positions which lead to a situation of ‘limited arbitrage’. With
prices swaying away from fundamental value, technical analysis is better placed to
understand market movement.
In the context of technical analysis profitability, the role of central bank interven-
tions also needs to be considered. Central banks frequently intervene in forex markets
to curb volatility (Roy Trivedi, 2019), and a host of studies show that the presence
of intervention is strongly associated with profits from technical analysis indicators
(Silber, 1994; Szakmary and Mathur, 1997; Neely, 1998; Roy Trivedi, 2020a). The
analysis of Bundesbank interventions with high-frequency data (Frenkel and Stadt-
mann, 2004) and daily data (Neely and Weller, 2001) shows technical trading rules
are most profitable on the day before interventions take place. Neely (Ibid) points out
that official interventions are usually during periods of sharp market movement, that
is when markets are trending, which also makes technical analysis profitable. Again,
central bank intervention may increase market volatility in shorter horizons (Roy
Trivedi, 2019), and the presence of market volatility may, in turn, contribute to the
creation of trends. Central bank intervention in that case would introduce noticeable
trends into the exchange rate movement, making it possible for market participants
to gain from trading (LeBaron, 1999; Saacke, 2002; Roy Trivedi, Ibid).
The discussion of the profitability of technical analysis in the presence of central
bank intervention helps to underline an important aspect of technical analysis. The
success of technical analysis indicators in this environment comes from the ability
to effectively use trend creation. As Menkhoff (2010) points out, economic pro-
cesses need time to unfold and technical analysis may be a ‘proper instrument’ to
anticipate price development in the sense of Hellwig (1982).
Prechter (2016)4 opines that technical analysis essentially rejects the idea of mar-
ket shocks and reaction to news as determining the movement of the market. In
fact, for technical analysts, the ideas of shocks and discounting and over- or under-
reaction to news are intimately related to the impact-and-response view of market
pricing embraced by the random walk theorists and practitioners of fundamental
analysis (Prechter, 2016). Prechter challenges each one of those concepts and argues
that stock market fluctuations express changes in social mood, which is active and
internally regulated rather than reactive to external forces. According to him, the
socionomic theory offers the only internally and externally consistent basis for the
technical analysis profession: if markets were priced rationally on external factors,
technical analysis would be impossible; if markets are priced non-rationally accord-
ing to patterned waves of social mood, technical analysis – which investigates senti-
ment, momentum, volume, and price behaviour – is valid analysis (Prechter, 2016).
Thus, technical analysis profitability, backed as it is by evidence, has links to
the essentials underlying technical analysis paradigms – the ability to gauge market
sentiments and social moods. The understanding of trend generation that tech-
nical analysis brings is indeed a hallmark of technical trading. As we discuss in
Introduction to technical analysis 7
later chapters, trend generation and reversal are central to most technical analysis
approaches. Effective trading indeed starts from understanding the trend, which
shall remain the focus through the rest of the book.
Money markets: These markets are for the short-term debt securities with
maturity of a year or less. The assets traded in this market include Treasury
bills, commercial papers, and certificates of deposits. They embody liquidity
with both low risk and return.
Capital markets: Markets for securities with maturity of more than one year is
called capital markets. Capital markets include markets for long-term debt
securities and stocks.
Long-term debt securities (bonds) are issued by both governments and corporates.
Investors in bonds get coupon payments (interest income) at regular intervals and
principal at maturity. The secondary market for debt securities gives liquidity to
the owners of these securities as the assets can be bought and sold any time before
maturity. Debt instruments characterize low risk and return.
Stocks represent equity ownership in companies that issue stocks or shares via
the primary market. Equity owners get a part of profits as dividends but are ranked
below debt holders for residual claims. This means that if for some reason the
company goes out of business, debt holders would be paid first and then equity
holders would have claims to the residual assets. Equity holders have a claim on a
company’s assets but only when the other liabilities of the company are paid for.
Equity holders nevertheless are looking for a maximization of shareholder wealth
and therefore expect management to work towards that goal. Voting rights are
Introduction to technical analysis 9
given to the owners of common shares and provide shareholders with the opportu-
nity to participate in major corporate governance decisions such as the election of
the company’s board of directors. The secondary market provides an opportunity
for equity holders to trade their stocks, leading to capital gains (or losses) (Box 1.1).
Foreign exchange market: This is the market for the purchase and sale of cur-
rencies. It is one of the most vibrant financial markets, with a huge turnover and
liquidity. While all commodities are bought and sold with money as the numer-
aire, for the currency market one currency is used to value the other. Forex mar-
kets cater to the end users who need foreign currency for business (exporters and
importers), travel, education, or investment. Additionally, currencies are traded by
both institutional and retail entities to make profits from the appreciation or depre-
ciation of the currencies. The main participants in the foreign exchange market are
retail clients (end users), commercial banks (who take buy/sell orders from their
retail clients and buy/sell currencies on their own accounts, known as proprietary
trading), foreign exchange brokers (who help dealers to find counterparties, lower-
ing transaction costs), and, finally, the central bank (which maintains the exchange
rate regime of the country, as also acts as the custodian of the foreign exchange
reserves) (Box 1.2).
Every forex transaction involves a currency pair, and the forex price (or
exchange rate) is the price of one currency in terms of the other. Of the two
10 Introduction to technical analysis
currencies in the pair, one is called the base currency and the other, the quot-
ing currency. The base currency is the currency that is priced and quoting
currency is the currency that prices the base currency, thus acting as money.
Thus, a currency quote is essentially the price of the base currency in units of
quoting currency.
In the book, we will refer to all currencies by their International Organiza-
tion for Standardization (ISO) codes. USD (United States dollar) is the ISO
code for the currency of the United States. The ISO codes of currencies featur-
ing in this book appear in the list of abbreviations. Conventionally, in writ-
ing a currency pair, the base currency is always written first. Thus, GBP/USD
means GBP (Great Britain pound) is the base currency and USD is the quoting
currency.
Commodity markets: Commodity markets are for the purchase and sale of
homogeneous primary commodities as opposed to manufactured products, includ-
ing precious metals (gold, silver), natural resources (oil, gas, metals or minerals),
animal products, and so on. Commodities can be traded directly or indirectly
(through the derivative markets). While investments in commodity markets is done
to diversify the portfolio, the evidence on commodity exposures increasing portfo-
lio returns is mixed (Baker et al., 2018).
Derivative markets: The markets for derivatives involve contractual agreements
which derive their value from an underlying. Financial assets that have been used as
an underlying include equities or equity index, fixed-income instruments, foreign
currencies, commodities, credit events, and other derivative securities. The value
of the derivative contract is derived from the corresponding equity prices, inter-
est rates, exchange rates, commodity prices, and the probabilities of certain credit
events (Bank of International Settlements, 2012).
In this book, we discuss technical analysis with examples from the equity and
foreign exchange markets only. While technical analysis is equally applicable to
bond, commodity, and derivatives markets, the unique features of these markets
require a separate study for the application of technical analysis in these markets
which is beyond the scope of this book.
1.5.3 Infrastructure of trading
While the primary market for financial assets leads to the creation of financial
assets, the secondary market facilitates buyers and sellers to trade in such assets.
Secondary markets therefore provide liquidity and enable price discovery. The
infrastructure of the market allows trading to happen. While the infrastructure of
different financial markets differs, the underlying structure common to all financial
markets is discussed here.
Introduction to technical analysis 11
1.5.3.1 Intermediaries
Exchanges
Historically, exchanges were physical places (floor or pit) where traders met to
arrange their trades. With the development of communication and technology, the
need for a physical place to conduct and arrange for trades is redundant. Advances
in communication and technology have allowed exchanges to completely automate
their trading systems (Harris, 2002). Exchanges, like brokers, arrange trades based
on the orders’ brokers and dealers submit to them. However, exchanges, unlike
brokers, regulate the behaviour of members in relation to the trades conducted in
their exchange (Fuhrmann and Lamba, 2011).
Clearing-houses
Clearing-houses arrange for final settlement of trades for their members, facilitat-
ing the process of transferring money from the buyer to the seller while transferring
12 Introduction to technical analysis
securities from the seller to the buyer. For the smooth operation of the clearing
process, members need to have adequate capital. Margins and limits are imposed
by the clearing-houses on the aggregate net (buy minus sell) quantities that their
members can settle. Non-member brokers and dealers must arrange to have a
clearing-house member settle their trades (Fuhrmann and Lamba, 2011).
Strong settlement systems in financial markets address counterparty risk and
ensure liquidity because it enhances the number of counterparties with whom a
trader can safely arrange a trade. Clearing and settlement systems follow a hierarchy,
of which, at the first tier, brokers and dealers guarantee settlement of the trades for
their retail and institutional customers. The clearing-house members guarantee set-
tlement of the trades of their customers at the second tier. At the third and topmost
tier, clearing-houses guarantee settlement of all trades presented to them by their
members, even when a clearing-house member fails to settle a trade. In the case of
a failure on part of a clearing-house member, the clearing-house settles the trade
using its own capital (Fuhrmann and Lamba, 2011).
In the clearing and settlement process, two more entities play a vital role: clear-
ing banks, responsible for making funds available for net payment obligation credit/
debit, and depositories, responsible for making securities available for net security
obligation credit/debit. Depositories hold securities on behalf of their clients in
electronic or dematerialized form, just as a bank holds cash for the customer as a
deposit. Dematerialization of securities helps to address risks arising from the theft,
loss, or mutilation of physical certificates.
1.5.3.2 Positions
A position in an asset is the quantity of a financial instrument owned or owed by an
entity. Long positions are assets owned by an entity while short positions represent
assets which are sold, even though they are not owned. Long positions are profit-
able when there is an increase in price. Short positions are profitable when there is
a decrease in the prices of the assets as short sellers can then repurchase the assets
at lower prices.
It is important to note here that for long positions, the profits are unlimited,
while losses are limited. For a short position, the losses are unlimited while profits
are limited. For example, let us suppose you have bought a security for Rs 100
(long position) and hope to gain from its price rise. The price can go up to any
level, so theoretically your profits are unlimited, while the minimum it can fall to is
zero, in which case, the loss would be 100%. In case, you have sold a security you
did not have at Rs 100 (short position), you expect its price to fall. If it falls to zero,
the profits would be 100%, but again, it can rise up to any level in which case you
would face unlimited losses.
1.5.3.3 Orders
Orders are instructions used by the buyers and sellers to communicate with the
brokers, exchanges, and dealers for transacting traders. To trade, we must specify
Introduction to technical analysis 13
the financial instrument that we want to trade, the amount we want to trade, and
the position to be taken. These instructions are classified into execution instruc-
tions, validity instructions, and clearing instructions (Fuhrmann and Lamba, 2011).
Execution instructions specify to the broker or dealer or exchange ‘how to fill the
order’, validity instructions specify to the broker or dealer or exchange ‘when the
order may be filled’, and clearing instructions indicate the specifications on the ‘final
settlement of the trade’ (Fuhrmann and Lamba, Ibid).
Execution instructions
Market orders tell the broker or exchange to obtain the best price immediately
available when filling the order. While filling market orders, the broker or exchange
will try to get the best price immediately available. This means that the actual trans-
acted price may not be the same that the trader was looking for while putting the
trade, especially for a fast-moving market. For a volatile market, this means that the
buy (sell) price may be higher (lower) than expected.
Limit orders also give the same instruction but with stipulations. In the case of
a buy-limit order, the stipulation is to not accept a price higher than the specified
limit price. In the case of a sell-limit order, the stipulation is not to accept a price
lower than a specified limit price when selling. Limit orders therefore may not
get executed if prices move quickly in the opposite direction to that expected by
trader.
Limit orders are said to be aggressively priced if they are given closer to the
market price (and therefore likely to trade) and less aggressively if priced otherwise.
The highest bid in the market is the best bid, and the lowest ask in the market is
the best offer. The difference between the bid and the offer is the market bid–ask
spread (Box 1.3). An increase in the bid–ask spread is taken as an indicator of
increased volatility in the financial markets (Fleming and Remolona, 1999).
Validity instructions
Validity instructions indicate when an order may be filled. A day order is valid for
the trading day on which it is submitted and expires if not filled by end of trading
day. Good-till-cancelled orders are valid till cancelled by the trader. Immediate-
or-cancel orders (or ‘fill-or-kill’ orders) are good only for immediate execution by
the broker or exchange; otherwise, they are cancelled immediately. Good-on-close
orders become valid at the close of trading.
Stop orders are validity instructions which become effective when the price
reaches a certain threshold. The buy-stop order becomes activated when the price
rises above a certain threshold, and a sell-stop order becomes activated when the
price falls below a threshold. Traders frequently use stop orders to contain their
losses, hence the name ‘stop-loss’ order. For example, let us suppose a trader has
taken a long position at Rs 100 and expect prices to rise. If the market moves in
the other direction, she may want to quit the position and minimize the loss. In
this case, she will put a stop-loss sell order at, say, 98. If the price starts to fall, the
moment it falls below 98, the order to sell becomes valid and is executed at the best
possible price. Similarly, if the trader has short sold at Rs 100, she may want to put
a buy-order stop loss at 110, which implies that if the price goes above 110, the buy
order would be immediately executed at the best possible price.
Stop-loss orders may be market or limit orders. For a stop-loss market order,
once the stop condition is valid, the broker should try to get the best possible price
Introduction to technical analysis 15
Clearing instructions
Clearing instructions guide on the final clearing and settlement of trades, including
indicating which entity is responsible for clearing and settling the trade. The clear-
ing function decides what members are due to deliver and what members are due
to receive on the settlement date. Settlement is a two-way process which involves
a transfer of funds and securities on the settlement date. The entity responsible for
clearance is the customer’s broker in the case of retail trades and a custodian or another
broker in the case of institutional trades (Fuhrmann and Lamba, Ibid, NSE, 2020).
In this chapter, we have presented a snippet view of the financial markets, focus-
ing on the structure of financial markets which enable the trading process. We have
discussed the academic viewpoint on technical analysis profitability and what can
explain technical analysis being an effective tool for the trading process. The idea
of trend generation as central to technical analysis is carried forward in the next
chapter. The success of technical analysis indicators, we recognize, comes from the
ability to reflect the sentiment in the market and thereby recognize trend creation.
The basic premise of technical analysis is that market move in trends which can
be recognized through suitable indicators and utilized for trading. Throughout the
remainder of the book, we will see that the different technical analysis approaches
presented give differing thought processes for understanding this basic tenet of
trend generation in the market. Chapter 2 takes up the building blocks of technical
analysis, its basic assumptions, and, finally, trend analysis, the cornerstone of techni-
cal analysis theory.
1.6 Key takeaways
1 Financial markets allow the smooth flow of financial capital between those
who save and those who need finance.
2 Money markets are for the short-term debt securities with maturity of a year
or less.
3 Capital markets are for securities with maturity of more than one year.
4 A foreign exchange market is a market for the purchase and sale of currencies,
with one currency being priced in terms on another.
16 Introduction to technical analysis
5 Commodity markets are the markets for the purchase and sale of homogenous
primary commodities as opposed to manufactured products.
6 Derivative markets are for contractual agreements which derive their value
from an underlying (a stock, bond, currency, and commodity).
7 Financial intermediaries mobilize savings, reduce the cost of external finance
to firms, lower information costs, and provide liquidity in the economy.
8 The primary market for the financial assets leads to the creation of these assets,
while the secondary market help buyers and sellers to trade in these financial
assets.
9 The infrastructure of financial markets includes the intermediaries (who facili-
tate the trading, clearing, and settlement of securities), positions (which reflect
the quantity of financial instrument owned or owed by an entity), and orders
(which represents communications between traders and intermediaries).
10 Traders commonly use fundamental analysis and/or technical analysis to fore-
cast the future market movement.
11 Technical analysis is the methodological study of charts and price movement
to forecast prices.
12 Empirical studies have confirmed that technical analysis is an important tool
for market practitioners, enabling effective trading decisions.
Notes
1 The title of the book by Mohamed A. El-Erian (2016) on the global financial system and
the role of the central banks is also a fitting adage for the fascination of our times with
trading and use of technical analysis in the financial markets
2 ‘Jobbing’ refers to the use of continuous buy and sell orders by traders in order to make
substantial profits in ‘small increments’ (Cheung and Chinn, 2001).
3 We are grateful to Dr. Lukas Menkhoff for his viewpoints which form the basis of the
arguments presented in this section.
4 We are grateful to Robert Prechter for his inputs on why technical analysis is better
placed to gauge market sentiments.
5 See Perez (2002) and Roy Trivedi and Bhattacharya (2018) for a discussion on the demar-
cation between production and financial capital and its implications.
2
BASIC PRINCIPLES OF TECHNICAL
ANALYSIS
The public, as a whole, buys at the wrong time and sells at the wrong time.
– Charles Dow1
2.1 Introduction
In the previous chapter, we have looked at the infrastructure of trading in the finan-
cial markets and differentiated between fundamental and technical analysis as the
two different approaches to trading. In this chapter, we take up the building blocks
of technical analysis, the essential foundation on which the different approaches of
technical analysis rests. Technical analysis is essentially the study of charts to forecast
future movements in financial markets. A host of different approaches, however, is
included in the broad gamut of knowledge loosely defined as technical analysis. In
the rest of the book, we cover these different approaches, but underlying each of
these approaches are the following basic tents:
Second, prices move in trends. Technical analysis aims to understand the past
price movement and forecast the future price movement on the basis of
such understanding, and therefore, it is very important to be able to locate
patterns in the past price movement. Unless a technical analyst believes that
trend is generated in the market and reversed at some point, forecasting is not
possible. A trend can be of three types: upwards, downwards, or sideways,
reflecting how prices move in the market. Technical analysts believe that a
trend in motion is likely to continue till it gives specific signals of reversal.
This helps them analyse the past movement and spot the signs of reversal.
Indeed, trend reversal and identification form the basis of all approaches of
technical analysis. And a trader who can understand the reversal before oth-
ers in the market is also likely to be generating the maximum profits from
technical analysis strategies.
Third, history repeats itself. As discussed earlier, identifying the past movement
and trying to understand the trend reversal on the basis of the past trends is
the central notion in technical analysis. The next thing to consider is, How
will the analyst know when the trend is going to reverse? Such an exercise is
futile unless we make some definite assumptions about the past patterns noted
in the market. Technical analysts believe that chart patterns are repeated and
hence can be predicted. It is on the basis of studying past patterns that the
forecasting of future price movement is done in technical analysis. So then,
technical analysis can be defined as the forecasting of future price movement
on the basis of past patterns, which are assumed to be repetitive.
The chart movements reflect what John Murphy (1999) called market action:
mostly price and volume. As analysts believe, anything that can affect the price
and volume in any market is reflected in the charts. Therefore, the first building
block of technical analysis is the chart construction. Technical analysis uses time
series charts which plots the price against the time variable pertaining to different
horizons. On the X (horizontal) axis, time is plotted while on the Y (vertical) axis
prices are plotted. We are thus interested in seeing how the price of an asset has
moved over time.
FIGURE 2.2 GBP/USD movement, 2019 (daily chart). Created with Eikon, Refinitiv
yearly frame for the GBP/USD pair. We see that from 2009, GBP/USD (or ‘cable’
as it is known as) has registered a sideways movement followed by a downtrend
from 2015 onwards. From 2019 onwards, on the monthly chart, there is a clear
downtrend. Looking at the currency pair on a more granular level (Figure 2.2), we
see the chart movement on a daily frame from 2019 onwards. We see in greater
20 Basic principles of technical analysis
detail how the movement has been for GBP/USD from 2019. The beginning of
2019 is marked by a small sideways move till April, after which cable registers a
downtrend for a few months up to July. Thereafter, we see it moves upwards till
December 2019.
The preceding analysis means that in describing a price movement, we must
always refer to the time frame in which the price movement has taken place. We
can say that for 2019, on the monthly chart, GBP/USD registered a downtrend
and that on the daily chart, the price movement was sideways till April 2019, fol-
lowed by a downtrend and, finally, a uptrend for the latter half of the year.
2.3 Types of charts
Chart construction is the basis of technical analysis, and the choice of the right
chart is crucial for any technical analysis indicator. We now consider the important
types of charts used by technical analysts.
2.3.1 Bar chart
It is one of the most widely used charts in technical analysis with the four data
points provided: high, low, open, and close for a particular time frame. Therefore,
in a daily bar chart, any bar will show the day open, the high reached during the
day, the low reached during the day, and the day close. As seen in Figure 2.3, if the
tick to the right is higher than that to the left, prices have moved up and the bar is
shown as blue or white. If on the other hand, if the tick to the left is higher than
the tick to the right, prices have moved down and the bar is shown as red or black.2
Figure 2.3 shows the construction of bars (for increase and decrease in prices).
2.3.2 Line chart
A line chart plots prices, commonly the closing prices with reference to time. It
gives an idea of the general movement in the market. Figure 2.4 shows the line
chart of GBP for the daily time frame from 2019.
Date Prices
69.00
68.95
68.90
68.85
68.80 X
68.75 . O X
68.70 O X X
68.65 O X O X
68.60 O X O X
68.55 O X O X
68.50 O
Source: Author.
69.00
68.95
68.90
68.85
68.80 X
68.75 . O X
68.70 O X X
68.65 O X X O X
68.60 O O X X O X X
68.55 O X O X O O
68.50 O
Source: Author.
price point 68.65 is ignored as it represents a move of less than 0.1 points. The
next price point is 68.50, which is shown with two Os in the boxes till 68.50. The
next price point 68.60 is reflected in the X moving up till 68.60 and so on. Each
time the price changes in the other direction, a fresh column of X or O is cre-
ated. Each column thus represents a trend, with the size of the column reflecting
the strength of the trend. Table 2.3 shows if the reversal is taken as 1 so that every
move of 0.05 or more points is noted, the point and figure chart would have more
columns of O and X.
Basic principles of technical analysis 23
2.3.4 Candlesticks
Candlesticks reflect the Japanese bar charting technique and are similar to a bar
construct discussed in section 2.3.1. Like the bar, the candle records four important
data that technical analysis traders are seeking: open, high, close, and low. On the
candlestick chart, the open and close are reflected by the body of the candle. The
high and low for the day are reflected by the shadows or the wicks of the candle.
Let us look at Figure 2.5 to understand the candlestick technique. The shaded por-
tion shows the body of the candle with the upper and lower lines. If the close is on
the higher side as compared to the open, the shaded area is shown in white, repre-
senting a bull candle. If the close is on the lower side as compared to the open, the
shaded area is shown as black, representing a bear candle. The wicks of the candle
show the high and low as shown in Figure 2.5.
C D E F G H I J K
24 Basic principles of technical analysis
1 Timestamp Trade Open Trade High Trade Low Trade Close HA open HA close HA high HA low
2 12/10/19 317 323 312 313
3 12/11/19 311 316 308 313 =AVERAGE(D2,G2) =AVERAGE(D3:G3) =MAX(H3,I3,E3) =MIN(H3,I3,F3)
4 12/12/19 314 323 314 322 =AVERAGE(H3,I3) =AVERAGE(D4:G4) =MAX(H4,I4,E4) =MIN(H4,I4,F4)
5 12/13/19 325 333 325 333 =AVERAGE(H4,I4) =AVERAGE(D5:G5) =MAX(H5,I5,E5) =MIN(H5,I5,F5)
Data Source: Thomson Reuters Eikon; author’s calculations.
Basic principles of technical analysis 25
The preceding formula tells us that each price in the HA candlestick is a derived
one. The open of the HA candlestick is the average of the open price and close
price of the previous period HA, implying that it reflects the average range the
price has taken the previous period. The close of the HA is the average of the entire
price movement during the period.
Thus, for a daily time frame, the HA close would be greater than the HA open
(resulting in an HA bull candle) only when the average for the day exceeds yester-
day’s (open and close) average, that is when prices, on average, have been rising.
Similarly, an HA bear candle shows that prices, on average, are falling. Thus, the
HA candlesticks can help identify the general market movement and can aid in
trend analysis. Thus, bull and bear HA candles by themselves represent the trend.
The calculation of HA values is shown in Table 2.4.
Again, if the HA high is equal to the HA open, there will be bear candles with
no upper shadows, and if the HA low is equal to the HA open, there will be bull
candles with no lower shadows. In the first case, it shows that the previous period’s
average is equal to the high of this period with a trend downward. The high of this
period has not been able to breach the average of prices in the previous period,
suggesting strong bearish pressures. In the latter case, the opposite happens: as
the open is the lowest point, it shows the average of previous period prices is this
period’s low along with an uptrend. Every price in the current period is greater
than the average price of the previous period, including the low, suggesting strong
bullish pressures. Thus, HA candlesticks show two things: they, first, clearly define
the trend and, second, suggest the strength in the market in upward or downward
directions.
We can use HA candlesticks to understand the trend better. Let’s take the exam-
ple of the daily GBP/USD movement in 2018–2019. As we can see in Figure 2.6,
FIGURE 2.7 Heiken Ashi candlesticks chart of GBP/USD. Created with Eikon, Refinitiv
stepped in first, trend-following investors now step in, buying rapidly so that prices
advance very fast. This phase is also characterized by increasingly bullish percep-
tions in the market. The general expectation is that this bullish run will continue
for some time. Again, here the informed investors would start to be cautious about
the euphoria surrounding the bull run. In the next and final phase of the uptrend,
the distribution phase, the informed or astute investors, recognizing that the trend
is over, start selling before everyone else in the market. This marks the completion
of the uptrend and a reversal of the market movement either towards a sideways
trend or a downtrend.
the signal for a reversal may be given too late when the trend is already in motion.
As John Murphy (1999) points out, it may be important to remember here that
Dow intended to capture the large middle portion of important market moves.
2.5 Trend analysis
2.5.1 Definition of trend
Understanding of trend is the very basis of technical analysis. Most of the tools
used in technical analysis (starting with support and resistance levels and moving
to the various statistical indicators that form the basis of modern technical analy-
sis) depend on the understanding of trend lines. The technical analyst is keen on
understanding the trend or making a move in the direction of the trend. As most
traders point out, the trend is your friend, and so a proper understanding of the
trend is essential to be able to trade large moves in the market.
A trend, as defined by John Murphy (1999), is the direction of the market or
the way it moves. Pring (2014) defines it as a straight line connecting either a series
of ascending bottoms and or descending peaks. Since markets do not move in a
straight line but are characterized by a series of zigzag movements, trends are rep-
resented by the general direction of the peaks and troughs.
In the words of Murphy (Ibid), it is the direction of the peaks and troughs that
constitutes the market trend. An uptrend would then be defined as a series of suc-
cessively higher peaks and troughs, while a downtrend is a series of declining peaks
and troughs. Horizontally moving peaks and troughs identify the sideways trend.
The sideways movement of the market is sometimes the most neglected part
of market movement. However, more than one third of the times markets tend to
move sideways or over a range. This is, in fact, the trickiest part of market move-
ment as not only is it difficult to put in trades in sideways moving markets but also
to understand when a reversal towards an uptrend or downtrend is going to occur.
on the basis of one point only. The rule of thumb here is that two points are needed
for drawing the trend line and one more point is needed for confirmation.
Figure 2.9, AB is the primary trend line connected with two reaction lows. How-
ever, chart movements tell us that this primary trend line has been overshadowed
by a secondary trend line developing. We can now draw the secondary trend line,
AC, that we see again connects two valid points. In fact, the revision of the trend
line is as important as drawing the trend line.
A combination of price and time filter may also be used. It may be useful to
remember here that the trend violation may be followed by either a reversal or a
consolidation.
FIGURE 2.11 Support and resistance trend line in the Nifty (daily chart). Created with
Amibroker
34 Basic principles of technical analysis
2.6.1 Fan principle
Fan lines on a chart are basically two or three trend lines drawn in succession on a
chart representing upward or downward movement. For example, in Figure 2.13,
AB constitutes the first valid trend line connecting three points; prices can be seen
to move downwards before again rallying further. AC is the next trend line that is
drawn. Prices fall further before rallying, resulting in another trend line, AD, that
can be drawn. Similarly, we can have fan lines for the downtrend. How are these
fan lines to be used? The breaking of the third line is usually taken as an indication
of a trend reversal.
Basic principles of technical analysis 35
2.6.2 Channel line
Another commonly used technique in charting is the use of the channel line or the
return line. In this case, we have two parallel trend lines both moving up or down
so that prices move within the channel. It is important to note that both the trend
lines must be valid and touch at least two points. Figure 2.14 shows channel lines
for an uptrend.
The channel line is one of the most useful indicators in technical analysis. What
it suggests is that prices will move within the channel until there is a clear indica-
tion of a reversal. In an upward-sloping channel, traders can enter in direction of
the trend once prices show a reversal sign from the trend-line support. In the case
of a downward-sloping channel, traders can look forward to selling or shorting
once prices reverse from the resistance trend line. Aggressive traders can use this
channel to have counter-trend positions, although it is not advisable for the new
traders in the market.
As seen in Figure 2.15, prices have been moving within the channel. The angle
of ascent of the lower trend line is below 45 degrees, which indicates that it can
be a drifting market to the upside instead of a strong uptrend. Traders can look
forward to buying when prices arrive near the lower end of the channel and sell
near the upper resistance line unless a decisive break is witnessed in either direction.
Once a breakout happens from the channel, prices are likely to move a distance
equivalent to the width of the channel, forming an important price objective. The
channel movement in the Nifty is given in Figure 2.15.
Figure 2.16 shows multiple support and resistance trend lines in the DJIA.
The DJIA was moving between the range of 18000 and 15000 levels between
the resistance and support trend line. A breakout above the upper resistance
line was witnessed in July 2016 post which prices came down to retest this line.
A resistance trend line earlier is now acting as a support. Prices made higher highs
and higher lows, thereby providing a positive trend confirmation as per Dow
Theory. Upward-sloping channel is drawn by connecting the lows together and
36 Basic principles of technical analysis
taking a parallel to that towards the highs. A strong breakout above the upper
trend line of the channel will suggest increasing momentum whereas a breakout
below the lower trend line of the channel will be a warning sign. In this chan-
nel, traders could look for a buying opportunity in the index as the overall trend
is on the upside and move towards the lower channel support provides a buying
opportunity.
Basic principles of technical analysis 37
2.6.3 Retracements
Retracements refer to the tracing back of the previous trend. While the major
objective of technical analysis is to understand the basic direction of the market
to help us initiate a position and trade in the direction of the trend, it is equally
important is to exit the market before the trend reverses. Simply knowing a rever-
sal takes place is not enough; it must be clear to the chartist how far prices are
expected to move following the reversal or consolidation. For this, we need to
understand retracements. Retracements simply suggest reversals ‘retrace’ the move-
ment that has happened in a given direction. How much prices retrace the portion
of the previous move is what is of interest to the chartist.
One of the most commonly used techniques to forecast retracements in techni-
cal analysis is the Fibonacci series. The Fibonacci number series is as follows:
Each number in this series is the sum of the two prior numbers (1 + 2 = 3, 2 + 3 = 5,
5 + 8 = 13, 8 + 13 = 21, etc.). Furthermore, a number divided by the previous num-
ber approximates 1.618 (called the golden ratio), and a number divided by the next
highest number approximates 0.6180. A number divided by another two places
higher approximates 0.3820 and divided by three places higher approximates 0.236.
38 Basic principles of technical analysis
It is assumed in trend analysis that the move traced out by prices in the direction
of the trend is retraced by the Fibonacci ratios, most popularly 61.8%, followed by
38.2 % and 23.6%. Again, a retracement by 50% or 100% is commonly expected.
To give an example, suppose prices have moved from 50 to 100 and the chartist
spots a reversal in the chart. The move from 50 to 100 is a move of 50 points, so
if the chartist expects a 61.8% retracement of this move, prices post the reversal
should move down by 61.8%. The Fibonacci retracements are obtained by join-
ing a major peak and trough and dividing the vertical distance as per important
Fibonacci ratios.
It is important to note here that prices may retrace the entire previous trend or
move, and the percentage retracements give are only the probable levels that will
be taken. Needless to mention the prior trend must be in place for a retracement
to happen. Without the prior trend in existence, drawing a retracement line has no
significance. When using software systems to draw percentage retracements, one
must be careful in connecting not any high and low but a valid peak and trough
in the market.
In the Nifty daily shown in Figure 2.17, we can see that prices had a sharp fall
from the highs towards 10000 levels. Post that there was a sharp upside retrace-
ment in prices towards the Fibonacci level of 38.2%, followed by 50% and 61.8%.
The retracement on the upside took a pause near 38.2% for few days before going
towards 50% level. Prices halted around the 50% mark for quite some time and
finally went towards the 61.8% level, from which it reversed back on the downside.
Thus, for a positive trend to emerge, a further break above 61.8% level is required.
Fibonacci retracement gives a range of expected movement, and it has to be com-
bined with channels and trend lines for better perspective and high-conviction
trade set-up.
2.6.4 Case studies
FIGURE 2.18 Bar technique on Altria Group Inc. daily chart. Created with Amibroker
40 Basic principles of technical analysis
day’s low on the intra-day basis, but on the closing basis, prices managed to close
within the prior bar’s high-low range. An outside bar or an inside bar only rep-
resents a temporary pause in the trend and does not necessarily indicate a change
in the trend. An early trend-change indication was obtained in late January when
prices closed above the prior bar’s high and continued to rise.
Later in February, there was a clear higher high and higher low formation that
confirmed that the trend has reversed back on the upside as per Dow Theory. A trader
can look forward to entering on the long side, as shown by the second up arrow in
February. A trader can look to ride the trend unless there is a break below the trend-
line support or close below the prior bar’s low provided it is not an outside bar. The
first down arrow shows a negative close but on an outside bar formation. This is a
caution sign, but an exit can be done on the second down arrow, where there is a
close below prior day’s low (which is not an outside bar). By following the above-bar
technique with channel Dow Theory, one can follow the trend.
FIGURE 2.19 Analysisof crude oil futures in INR (continuous contract; weekly chart).
Created with Amibroker
reversal in the middle of February 2020. The fall was extremely sharp and retraced
the entire rise of 2019 in only a few weeks’ time. The severity of decline seen in
2020 is comparable to that seen during the fall of 1987. The rise seen in the index
from 2019 till February 2020 was contained between the resistance and support
trend lines. Prices failed to break above the resistance line forming a top at 29568,
and as soon as the support trend line was broken, selling pressure intensified in the
index, which crashed towards the low of 18213 levels. This is a decline of more
than 38% in a few weeks which is of a similar magnitude seen during the 1987
crash. The support trend line was broken near the price level of 27650, which pro-
vided a negative confirmation to traders and investors. The selling was coincident
with the increasing concern over COVID-19 globally, but if a trader paid attention
to the price action, there was a clear negative confirmation below the support trend
line much early on. This suggests that charts do provide vital indications for mak-
ing prudent trading or investment decisions even during the eventful year of 2020
that will be historically known for the intensity of fall in global equity, commodity
markets, and the fear of the COVID-19 pandemic.
In this chapter, we have detailed the basic tents of technical analysis, which
will provide a foundation for understanding of the application of technical analysis
principles throughout the book. As we have seen through the case studies, apply-
ing these basic principles can go a long way in helping us form correct decisions in
the market. In fact, in uncertain times, the basics of technical analysis form a solid
foundation to steer us through greed and fear that plagues the markets.
In the next chapter, we take up the classical technician analysis theory and see
its application in trading. Extending Dow Theory, we delve into the principles of
classical technical analysis and trading on the basis of reversal and continuation pat-
terns identified in classical technical analysis in Chapter 3.
2.7 Key takeaways
• Technical analysis is the methodological study of charts movement to forecast
foreign exchange rates.
• Market action, according to chartists, is reflected in prices and volume.
• Chart construction is the basis of technical analysis.
• Basic principles of technical analysis are based on the Dow Theory.
• Markets quickly assimilate all the information, and the same is reflected in
price action.
• There are three major trends in the market: primary, intermediate, and short
term.
• Any trend has three phases: accumulation phase, public participation phase,
and distribution phase.
• For a trend to be confirmed, major averages should be in the same direction.
• Volume must confirm the trend.
• A trend may be assumed to be in motion till there is a definite signal for
reversal.
Basic principles of technical analysis 43
• Trend is the direction of the peaks and troughs that constitute the market
movement.
• Support is formed by reaction lows or troughs, where buying interest is suf-
ficiently strong to overcome selling pressure.
• Resistance is formed of reaction highs or peaks, where selling pressure over-
comes buying pressure so that a price advance is turned back.
• Trend analysis is crucial for understanding reversal patterns.
Notes
1 Dow, C. (1900, December 14). Review and outlook, as cited in Dow, C., and Sether, L.
(2009). Dow theory unplugged: Charles Dow's original editorials & their relevance today, Traders
Press.
2 In software systems frequently used for technical analysis, blue or white bars represent up
moves and red or black bars represent down moves.
3 Nifty 50 is the National Stock Exchange’s (NSE’s) diversified 50 stock index accounting
for 13 sectors of the economy.
3
CLASSICAL REVERSAL AND
CONTINUATION PATTERNS
3.1 Introduction
In the previous chapter, we have looked at the building blocks of technical analy-
sis. The underlying idea behind Dow Theory forms the basis of trend analysis, as
discussed in the previous chapter. In this chapter, we take up classical technical
analysis which also stems from the broad notion underlying Dow Theory. The
classical patterns embody the essentials of technical analysis, with a belief that
patterns are repetitive and can be used to predict the future price movement.
The visual patterns are formations appearing on the charts which can help us
predict a reversal or a continuation in the trend. The patterns themselves are easy
to understand and see on a chart. However, the chart analysis, although seem-
ingly ‘simple’, is anything but so. The interpretations of the patterns are highly
subjective, and often, the price forecast requires a careful understanding of the
prior movement and reason behind the formation of the pattern to be able to
predict future prices correctly. Reversal patterns suggest that a trend reversal is
taking place while continuation patterns suggest pauses in the markets before the
existing trend continues in the same direction. In considering reversal and con-
tinuation patterns, due importance must be given to the volume as it often helps
confirm an otherwise subjective visual pattern.
3.2 Reversal patterns
The understanding of reversal patterns forms the core of classical technical analysis.
The trader who spots the reversal before anyone else in the market is the astute
trader and would gain from riding the trend for the longest possible time. For a
Classical reversal & continuation patterns 45
reversal pattern to appear on the chart, it is important that there is a strong sug-
gestion of a prior existing trend. As we have discussed in the previous chapter, the
recognition of trend lines is the first important step for technical analysis. The break
of a major trend line is the first sign of a trend reversal. An important consideration
for reversals is how much the market is going to move in the opposite direction. It
is useful to remember here that the bigger the reversal pattern, usually the greater
would be the move in the opposite direction (Murphy, 1999). We consider here
the most popular reversal patterns.
The confirmation of the reversal happens with the break below the neckline.
The volume indications are very important as the first rally (left shoulder, S) should
be made on high volume, and the next high at the head, H, should be on lesser
volume. The break of the neckline at DD’ should again happen at higher volume
for the Head and Shoulders pattern to be confirmed.
The Head and Shoulders formation can also happen on the downtrend, which
is popularly called the Inverse Head and Shoulders pattern. Similar to the pattern
discussed earlier, the Inverse Head and Shoulders pattern must also be supported
by a volume confirmation.
The price objective for the Head and Shoulders pattern is given by the height
of the pattern, HH′, in Figure 3.1 that is the vertical distance from the head to
the neckline. For example, if the head is formed at 200 and the neckline is 180,
the vertical difference is 20. The price objective on the downside, that is the
level that the market is expected to move down to, after breaking on the down-
side, is 160 (= 180 – 20). The distance of the shoulder from the neckline can be
used for a conservative projection.
It is important to note that a Head and Shoulders pattern (or its Inverse) is com-
plete and valid only once there is a breakout below (or above) the neckline area.
Assuming a Head and Shoulder completion before the neckline gets broken can
result in wrongly planned trades.
In Figure 3.2, the Nifty index has exhibited classical topping Head and Shoulder
pattern on the hourly chart. The Head and Shoulder pattern is formed near the top
after a sustained rise. As it is a reversal pattern, it is important to see the formation
FIGURE 3.2 Head and Shoulder pattern on the Nifty (hourly chart). Created with
Amibroker
Classical reversal & continuation patterns 47
of this pattern after the rally. This means that with a Head and Shoulders pattern,
you spot that the downtrend or market bottom is actually not a valid pattern. The
pattern target of this stock is derived by measuring the height of the head from
the neckline and projecting it on the downside from the breakout area. This gives
the target of 11300 on the downside. Prices broke below the neckline near 11590
levels and moved quickly towards the target of 11300.
In Figure 3.3, crude oil traded on Multi Commodity Exchange of India Lim-
ited (MCX) in INR formed a classical Inverse Head and Shoulder pattern. It is
important to remember that a Head and Shoulders pattern comes at the end of the
uptrend and an Inverse Head and Shoulder should come after a valid downtrend.
Crude oil formed an inverse Head and Shoulder pattern on the weekly chart after
a sustained fall from higher levels. This pattern is a bottoming reversal pattern. The
pattern target is the height of the head projected on the upside from the neckline
area. Prices broke above the neckline area, thereby confirming the Inverse Head and
Shoulder pattern as complete, and moved towards the target level. It is always good
to remember that prices might fall little short of the target or overshoot as well, so a
trader should always look forward to taking some profits when prices are near to the
target level and not necessarily wait for the exact price point to be touched.
In Figure 3.4, Alcoa stock on weekly basis formed a classical Inverse Head
and Shoulder pattern. Prices formed an Inverse Head and Shoulder pattern with
clear shoulders on the left and the right side of the head. The pattern is valid on
the break above the neckline area, that is the breakout. There was a retest of the
FIGURE 3.3
Inverse Head and Shoulder pattern on MCX crude oil (weekly chart).
Created with Amibroker
48 Classical reversal & continuation patterns
FIGURE 3.4 InverseHead and Shoulder pattern on Alcoa Corp (weekly chart). Created
with Amibroker
neckline after breakout which further confirmed the importance of the neckline
from which prices bounced back. This also provided an opportunity to enter the
stock on the retest if not already entered on the breakout. The pattern target is
measured by projecting the height of the head from the neckline on the upside.
In the first attempt, prices fall little short of the target and came back lower. It is
therefore wise to book partial profits when prices have travelled substantially in
favour and to not wait for the exact target point. There is always the possibility of
prices overshooting or missing the exact target by a few points.
The neckline which was resistance earlier is acting as support later, which is
known as polarity reversal. Prices came near the neckline later in 2017 and again
moved higher later, moving above the pattern target levels.
FIGURE 3.6 Double Bottom formation on MMM (daily chart). Created with Amibroker
50 Classical reversal & continuation patterns
height of the peak from the lower end of the pattern and projecting it on the
downside from the neckline. For a Double Bottom formation, the pattern target is
derived by measuring the distance between the trough to the high of the pattern
and projecting it on the upside from the neckline.
In Figure 3.6, MMM (3M Co) shows a Double Bottom formation during the
period between 2015 and early 2016. Prices formed a Double Bottom formation
and later break out above the neckline. The pattern target is derived by measur-
ing the bottom of the pattern to the neckline and projecting it on the upside. The
height of the pattern is 160 – 135 = 25 points, which gives the target of 185 levels
by projecting 25 points above the neckline. A trader should adopt a trailing stop
method, that is revising the stop loss higher, and when positions move favourably
to ensure some profits are locked in, in case prices misses to reach the target level.
FIGURE 3.8
Triple Bottom pattern on EUR/USD (weekly chart). Created with
Amibroker
not necessarily occur at the exact same price points. As can be seen in the figure,
the bottoms are near the support range and not at the same exact price level.
A breakout takes place on a move above the neckline which connects the top of the
pattern. Post breakout there is a tendency of retesting the neckline. This provides
an excellent opportunity for a trader to enter with a stop loss below the neckline.
The pattern target is derived by measuring the height of the bottom to that of the
neckline. So the target is taken as 1.15 – 1.05 = 0.10 projected on the upside from
1.15 which is the neckline area. The target for taking the profits is placed at 1.25
which is achieved on the upside. Also, a trader should book partial profits when
the positions are favourable and trail the remaining to the cost price to ensure that
the position becomes risk-free.
FIGURE 3.9 Saucer
Source: Author
3.3 Continuation patterns
Continuation patterns indicate that the markets are going to continue with the
previous trend (uptrend or downtrend) and have stopped to consolidate or ‘take a
breath’ before continuing with the prior trend. Usually, continuation patterns are
of shorter durations than reversal patterns.
Classical reversal & continuation patterns 53
3.3.1 Triangles
The most commonly seen continuation pattern is the triangle. There are three
types of triangles seen on charts: Symmetrical, Ascending, and Descending.
The Symmetrical Triangle has two converging trend lines, an upper descending
line and a lower ascending line. In Figure 3.11, AB is the base of the triangle, and C is
the apex of the triangle. As mentioned earlier, a triangle is a continuation pattern, so
it is expected that the market will move in the same direction as earlier after the com-
pletion of the formation. On rare occasions, a triangle may act as a reversal pattern.
Generally, prices break out in the direction of the prior trend – somewhere from
two thirds to three quarters of the horizontal width of the triangle (the distance from
the base to the apex). It must be remembered that there must be four points at least
for a triangle to be formed, as shown in Figure 3.11. Volumes should be less as the
prices moved towards the apex and increase significantly when the breakout happens.
A pattern target is derived by measuring the width of the triangle and projecting
it in the direction of the breakout. In Figure 3.11, AB represents the width of the
triangle which is projected on the upside from the breakout level.
The Ascending Triangle should have a flat upper line and a rising lower line
as shown in Figure 3.12, and the Descending Triangle must have a falling upper
trend line and a flat lower line as shown in Figure 3.13. While, usually, triangles are
continuation patterns, they may also represent a reversal on the upside (for Ascend-
ing Triangles) or downside (for Descending Triangles). In this case, the breakout
should be on a noticeably larger volume.
Figure 3.14 shows Symmetrical Triangle pattern. The triangle pattern seen on
the chart has been a continuation pattern, and the trend prior to the pattern was
down, which continued after the breakout from the pattern. Both trend lines were
converging, with the upper line descending and the lower line ascending, thereby
giving the form of a Symmetrical Triangle. The pattern target is derived by meas-
uring the widest leg of the triangle which is the base and projecting it on the
downside from the breakout area. A conservative target is derived by projecting
on the downside from the last move completed within the triangle. As we can see
in Figure 3.14, after the lower trend line of the pattern was broken, the target was
achieved on the downside.
In Figure 3.15, the DJIA shows classical Descending Triangle pattern. The DJIA
shows a horizontal lower trend line and a downward-sloping upper trend line,
Classical reversal & continuation patterns 55
FIGURE 3.15
Descending Triangle pattern on the DJIA (daily chart). Created with
Amibroker
a downtrend, it has a slight upward slope. Volumes should be noticeably less when
the patterns are forming. Both patterns should not take much time to form in the
market, and the break of the patterns suggests that the move of the prior trend will
continue. How much the markets will move in the direction of the prior trend is
given by the initial straight-line move or flagpole. The market should move at least
half the distance of the flagpole in the previous direction following the breakout.
3.3.3 Wedges
A wedge pattern is similar to a triangle pattern. Similar to a triangle, a wedge has
two converging trend lines, but the important difference is that in a wedge both
the trend lines are sloping in the same direction. An upward sloping wedge will
have both lower and upper trend lines converging in the same direction. A wedge
results in a pause of the ongoing move. A rising wedge will occur during a down-
trend, and a falling wedge will occur during an ongoing up move. There have been
instances when wedges act as a reversal pattern and not as a continuation pattern.
So this pattern, if formed near important tops or bottoms, can result in a reversal
action. More often, we see it as a continuation pattern but may also act as a reversal
pattern. Volumes normally reduce during its formation and increase on the break-
out. The breakout from a wedge can result in a violent move. Figure 3.18 shows a
wedge-pattern formation. A falling wedge can be seen during the uptrend, and a
rising wedge is seen during the downtrend.
In Figure 3.19, the Nifty formed a wedge-shaped pattern which was a pause
in the ongoing downtrend and later, after giving a breakout from the wedge, it
resumed. Prices after the downtrend formed a wedge-shaped pattern with two
converging trend lines moving on the upside direction. The break below the
wedge resulted in a sharp fall towards the start of the pattern which is usually the
FIGURE 3.18 Wedge
Source: Author
58 Classical reversal & continuation patterns
FIGURE 3.19 Wedge pattern on the Nifty Index (daily chart). Created with Amibroker
FIGURE 3.20 Flag, pennants, and wedge on the DJIA (daily chart). Created with Amibroker
target. The breakout from the pattern is confirmed after the lower trend line was
broken, which provided good entry level for the trader keeping the high of the
wedge as a stop loss.
In Figure 3.20, the DJIA exhibits different patterns during the rise. The flag
pattern seen during November 2017 resulted in a temporary pause in the strong
Classical reversal & continuation patterns 59
uptrend. The breakout from the flag continued the up move with a near-vertical
rise and later continued the trend with strong momentum. A small pennant was
formed with a downward drifting move that, again, resulted in a positive continua-
tion of the prior trend. Later, an upward-sloping wedge-shaped pattern was formed
near the top that acted as a reversal pattern, not a continuation. Prices formed an
inverse-V-shaped pattern, resulting in a strong sell-off after the lower trend line of
the wedge pattern was broken.
3.4 Gaps
A gap is formed when there is an area where no trading takes place. It is usually
seen on daily charts when prices open above the high of the previous day or below
the low of the previous day. It is an empty space between trading periods. Traders
often believe that gaps are always filled up, but this might not always be the case.
There have been instances when certain gaps remain unfilled for months or years
and might never get filled. It is rare to see gaps on a weekly or monthly time frame,
as for a weekly gap to occur, prices have to open with a gap up or gap down, out of
the entire past week’s price range. A gap is an important aspect of technical analysis
as the lower and upper area of the gap acts as support and resistance at times for the
subsequent price action.
There are different types of gaps – Breakaway Gap, Runaway Gap, and Exhaus-
tion Gap.
3.4.1 Breakaway Gaps
As the name suggests, Breakaway Gaps are formed when there is a gap up or gap
down post completion of a pattern. If there is a consolidation in the form of any
pattern and prices open directly above or below, the breakout area it creates is a
Breakaway Gap. Patterns associated with Breakaway Gaps have a higher probability
of success. It is always better to see that a breakout from the pattern is associated
with higher than normal volumes even if it is with a gap. Figure 3.21 shows a
Breakaway Gap from a consolidation pattern.
3.4.2 Runaway Gaps
Runaway Gaps are formed usually during the middle of the trend. Prices move
in a specific direction, and as the momentum is strong, we can see Runaway Gap.
This gap normally represents a strong trend in that direction. There can be more
than one Runaway Gap when the trend is very strong. A third or fourth Runaway
Gap should be viewed with caution as there is a high probability of them getting
filled and resulting in the culmination of a trend. Runaway Gaps are also known
as Measuring Gaps, as they occur around the halfway point in a trend. Figure 3.22
shows a Runaway Gap during a downtrend and an uptrend.
60 Classical reversal & continuation patterns
3.4.3 Exhaustion Gaps
An Exhaustion Gap occurs after the prices have sharp advance or decline and the
momentum is slowing down. A gap which occurs after a sustained trend, before
reversals, is an Exhaustion Gap. Exhaustion Gaps can get filled instantly or after a
few days. When prices close below the last gap area after a sustained uptrend, and
Exhaustion Gap is represented. During the downtrend, if we see a gap near the
terminal end of the trend, which gets filled within few days by a reversal on the
upside, it is a sign of Exhaustion Gap in the downtrend.
3.4.4 Island Reversals
An Island Reversal is formed when, after a sustained move, we see an Exhaustion
Gap which is then followed by a few days or weeks of a price pattern later followed
by a Breakaway Gap. The significance of an Island Reversal depends on the area
where it has formed. If there is a sustained up move with an Exhaustion Gap accom-
panied by a reversal pattern, discussed earlier, and then there is a Breakaway Gap,
it can lead to a significant reversal. An Island Reversal can be seen in Figure 3.23.
Gaps provide important technical information depending on the area where
it occurs. In Figure 3.24, we can see Runaway Gap during the sustained uptrend
FIGURE 3.24 Runaway Gap, Exhaustion Gap, Island Reversal, and Breakaway Gap
Source: Author
which occurred during the middle of the trend. The second Runaway Gap
turned out to be Exhaustion Gap as it was near the terminal end of the trend.
The Exhaustion Gap was followed by a Double Top, broken with a gap down
opening, resulting in a Breakaway Gap. The entire formation gave rise to an
Island Reversal as there were prices in the form of an island separated on either
side with a gap.
In Figure 3.25 using Facebook data, there are various gaps seen during the
period of 2019. Prices gave a Breakaway Gap on the upside, which was the first
gap up after the trend reversal. The same gap remained unfilled, and prices moved
higher. Later, there was a gap up after a sustained rise which resulted in an Exhaus-
tion Gap, and the same was filled after a few days of the move. The high made after
the Exhaustion Gap remained protected for many days. The reversal seen on the
downside resulted in prices moving towards the upper end of the Breakaway Gap.
This upper end of the gap provided support from where there was a positive move.
There were two Runaway Gaps in the middle of the trend that showed strong posi-
tive momentum, driving stock prices higher.
Classical reversal & continuation patterns 63
FIGURE 3.26 Gap, wedge, and flag on the Nifty (daily chart). Created with Amibroker
The second example we take is of Apple Inc. (AAPL) chart (logarithmic scale)
shown in Figure 3.27. Channel and gap analysis has been combined here for trad-
ing decisions. Prices showed a rise from the lows of 170 levels made on 3 June 2019
and touched a high of 327 made on 29 January 2020. This rise was within the
upward-sloping channel. Within this primary trend, there was an intermediate trend
contained within the internal channel. Post forming a top, prices moved in a nar-
row range before breaking below the lower trend line of the internal channel and
then moved down with a Breakaway Gap. The trend-line break and Breakaway Gap
provided an indication of the possible trend reversal early on in this stock. This was
further confirmed with the rise in volumes along with the down move. Later, prices
again retested the Breakaway Gap area and reversed back, going sharply lower. This
rise was associated with reduced volumes. During the fall, the volumes were increas-
ing, and during the rise witnessed in March and April 2020, volumes continued to
reduce. This is typical behaviour one can observe during a medium-term down-
trend. A trader had the advantage of looking at the chart for warning signals: Breaka-
way Gap, trend-line break, and rise in volumes, which helped confirm the reversal to
the downside. This confirms that the charts continue to provide clarity even during
the events categorized as market shocks, such as the COVID-19 pandemic.
To sum up the discussion on classical patterns, a few important things to note
for the trader. First, classical patterns, except for gaps, typically take considerable
time to develop. This means that whatever the time frame, the patterns would take
Classical reversal & continuation patterns 65
FIGURE 3.27 Analysisof channels and gaps on Apple Inc. (daily chart). Created with
Amibroker
time on the chart, so trades can be planned as the patterns develop. This also means
instantaneous signals will not emerge from these patterns. The idea is to capture big
moves in the market by being on the side of the trend.
Second, classical patterns are subjective in nature, so interpretations may vary
across traders. When in doubt about the validity of a signal from the classical pat-
tern, we can look at technical analysis indicators for confirmations.
Third, we need not wait for the price target to be reached: trades can be put in
when prices are close (1%–3%) to the target level.
Classical patterns discussed in this chapter, therefore, can be an effective instru-
ment for trading and can help to get sizeable moves in the market. Combining
different patterns is equally important for trading decisions. In the next chapter, we
take up candlestick patterns and discuss ways to trade them.
3.5 Key takeaways
1 Classical price patterns are price formations appearing on the charts which
help predict a reversal or a continuation in the trend.
2 Classical price patterns are based on visual analysis of charts and therefore are
subjective in nature.
3 For a reversal pattern to appear on the chart, it is important to have strong
evidence of a prior existing trend.
66 Classical reversal & continuation patterns
4 The most common reversal patterns for a reversal from an uptrend to a down-
trend include Head and Shoulders, Double Tops, Triple Tops, and spikes.
5 The most common reversal patterns for a reversal from downtrend to uptrend
include Inverse Heads and Shoulders, Double Bottoms, Triple Bottoms, sau-
cers, and spikes.
6 Continuation patterns are pauses in the market and indicate that the markets
are going to continue with the previous trend (uptrend or downtrend).
7 The most common continuation patterns include triangles, wedges, flags, and
pennants.
8 Volume confirmations are helpful to confirm the classical reversal and con-
tinuation patterns.
9 Gaps represent areas where no trading takes place, and the lower and upper
area of the gap may act as support and resistance for the subsequent price
action.
Note
1 Bogle, J. (2015). The Clash of the cultures in Investing: Complexity versus Simplicity is the title
of his Keynote Speech at The Money Show, Disney Coronado Springs Resort, February 3,
1999, which leaned for simplicity in investing, Bogle, J. (2015). John Bogle on investing:
The first 50 years. Hoboken, NJ: John Wiley & Sons, p. 17.
4
CANDLESTICKS PATTERNS AND
THEIR USE IN TRADING STRATEGIES
4.1 Introduction
Japanese candlesticks captured the attention of the Western world since the 1990s
(Pring, 2014), especially with the publication of Steve Nison’s Japanese Candlestick
Charting Techniques. There continues to be a wide interest in Japanese candlestick
patterns and its applicability especially for short-term trading. Japanese candlesticks
go back a long way in history, explored in detail by Nison (1991), to the legend-
ary Munehisa Homma, who used the candlesticks for trading in the Japanese rice
market during the late 18th century.
The city of Osaka, with its access to the sea, was Japan’s leading commercial
centre, and it was here in Osaka, in the Dojima Rice Exchange that Homma flour-
ished. The rice trade, which developed in Japan in the 17th and 18th centuries,
had its culmination in the setting up of the Dojima Rice Exchange in the late 17th
century in Osaka and became the foundation of Osaka’s prosperity (Nison, 1991).
Homma is believed to have developed strong analytical tools for forecasting rice
prices and was helped by an elaborate information network on rice cultivation
and weather. In later years, Homma served as a financial consultant to the govern-
ment and was bestowed the title of Samurai for his contributions (Nison, 1991).
His trading principles, which developed for the rice markets, are believed to have
evolved into the candlestick methodology, used extensively in Japan and now the
rest of the world.
While candlesticks have traditionally been used by traders of the East, with
their introduction to the Western world, the popularity of candlestick patterns has
immensely grown. What lies behind the popularity of candlesticks is that it brings
68 Candlesticks patterns
in the simplicity of the patterns yet with a rich understanding of market psychol-
ogy. In this chapter, we consider in detail the concept of candlesticks, touched upon
in Chapter 3, and the various reversal and continuation patterns. The patterns are
supplemented by examples to explain how to trade using the candlesticks patterns.
4.2 Concept of candlesticks
Candlesticks can be referred to as the Japanese bar charting technique and similar
to a bar construct, it also records the four important data that technical analysis
traders are seeking: open, high, close, and low. On the candlestick chart, the open
and close is reflected in the body of the candle. The high and low for the period is
reflected in the shadows or the wicks of the candle. As already discussed in Chap-
ter 2, the shaded portion shows the body of the candle, with the upper and lower
lines reflecting either the open or close for the day. If the close is on the higher side
as compared to the open, the shaded area is shown in blue or white. If the close is
on the lower side as compared to the open, the shaded area is shown as red or black.
The wicks of the candle show the high and low as shown in Figure 4.1. The use of
candlesticks for charting is very popular amongst traders. Candlestick patterns refer
to the visual analysis of formations appearing on candlestick charts.
The body and shadow combinations in candlesticks have different interpreta-
tions. Before looking at the reversal and continuation patterns that come with
Japanese candlesticks, let us consider the types of candles that we can see on the
chart. While many of these candlestick patterns are usually popular and commonly
used by many traders, the subtle intricacies are not often understood which ham-
pers informed decision-making. It is important to note that while there are several
candlestick patterns that we can study, only a few are commonly noted in the mar-
ket and have higher probabilities of giving accurate predictions (Thomsett, 2015).
Candlesticks not only show us the more important prices for that particular
asset, but they also show the breadth of trading and the volatility during the trad-
ing period (Murphy, 1999, Thomsett, Ibid). It may be noted that the longer the
body of the candlestick, which reflects the difference between the open and close
prices, the greater is the breadth of trading. Again, the longer the shadows, upper
or lower, more is the volatility. A long upper or lower shadow represents efforts by
traders to take the price in that specified direction and the failure to do so. Thus, a
candle with a very long upper shadow represents the strong effort of bulls to take
the market up and the failure of prices to move up to that level. Similarly, a candle
with a very long lower shadow represents the efforts of bears to take the market
down and the capacity of prices to bounce up from that level. Shadows therefore
speak volumes on the sentiment in the market.
While there are more than 100 candlestick patterns, all candlestick patterns
evolved out of six basic candlestick formations (Thomsett, Ibid). These are elabo-
rated in Figures 4.2a and 4.2b.
4.2.1 Long candlesticks
Long candlesticks, as discussed earlier represent a huge breadth in the market, may
be either bullish or bearish. The longer the real body of the bull (bear) candle, the
more positive (negative) the market sentiment. It reflects a strong interest in the
trading session and, more often than not, signify reversal patterns developing in
the market. An interesting variant of the long candlestick pattern is the Marubozu,
which in Japanese means ‘with little hair’. The perfect Marubozu should have no
shadows, although an extremely small shadow on one side can be allowed. The
Marubozu shows open and close prices which have been extremely important,
in that there was little tendency to move the market beyond these prices. For the
Marubozu, the bullish (white) or bearish (black) sentiment is much stronger than a
candlestick of the same size with the larger shadow.
4.2.2 Short candlesticks
Short candlesticks, shown in Figure 4.3, may have shadows on both the sides or
only a lower shadow. There are several popular candlestick patterns which involve
single-session short candlesticks, including the Hanging Man, the Hammer, and
the Inverted Hammer. The shorter the real body of the candle, the narrower the
breadth in the market. It is therefore common to note short candlesticks during
sideways movement of the market. Shorter candlesticks with longer shadows show
the struggle between the bulls and the bears as they try to take the price to one
direction but settle to close within a narrow range compared to the open. Spinning
tops are small real-body candles with longer or shorter shadows. They reflect side-
ways movement and therefore indecision in the market. Spinning tops that appear
Candlesticks patterns 71
4.2.3 Doji candlesticks
In Japanese, the term Doji means ‘mistake’ (Nison, 1991). Dojis are candlesticks with
little or no real bodies so that the rectangle of the candle is replaced by a horizontal
line. Combined with shadows, Dojis may be bullish or bearish. Dojis, when they are
part of trading ranges, strengthen the indecision in the market and show that bulls
and bears are temporarily in balance. A Doji with a long upper shadow is also called a
Gravestone Doji and is assumed to be bearish in nature while a Doji with a long lower
shadow is called Dragonfly Doji and is considered to be bullish in nature (Figure 4.4).
FIGURE 4.6 Doji on the Nifty (hourly chart). Created with Eikon, Refinitiv
Figure 4.6 shows Doji candlesticks on the Nifty chart. While Dojis reflect inde-
cision in the market, the Gravestone Doji is bearish while the Dragonfly Doji is
bullish. We can see here that the aforementioned Dojis have led to sharp reversals
in the Nifty.
4.3 Reversal patterns
In technical analysis, reversal patterns imply the tendency of the prior trend to
reverse. Combinations of Japanese candlesticks, which predict a reversal in trend,
are called reversal candle patterns. Similar to the classical trend analysis, it is
important to note that the evidence of a prior trend is essential before a reversal
is seen on a chart. While the patterns listed in this section present the perfect
visual formation, there are likely to be divergences when they are seen on the
charts. It must be remembered that technical analysis can be subjective, and it is
not wise to expect perfect patterns to form on charts. In the case of divergences
from the actual pattern, traders should rely on other indicators to confirm the
decision taken.
It is very important to note that reversal patterns need not necessarily translate
into an abrupt change of trend in the other direction. This implies that the appear-
ance of a reversal pattern in a strong uptrend does not necessarily mean that the
trader is to go short. It does not signify an immediate reversal of the trend from up
to down. However, it does signify a good time to liquidate the long position as the
reversal patterns show that the prior trend is likely to change. The subsequent price
action becomes important to observe to take the trading decision.
depending on where they appear in the trend. Hammers are characterized by small
bodies and long lower shadows. The Hanging Man appears at the top of the market
and represents an end in the uptrend while the Hammer appears at the bottom of
an ongoing downtrend, and suggests an end of a downtrend. The Japanese word
for Hammer is Takuri, meaning ‘trying to gauge the depth of water by feeling for
its bottom’ (Nison, 1991), while that for Hanging Man is Kubitsuri (literally ‘hang-
ing’). The Hanging Man, as ominous as it sounds, at the top of the market looks
like a Hanging Man with dangling legs. Both of these patterns when they appear
in a rally is a strong indication that the prior move may be ending. The implica-
tions of the Hanging Man and the Hammer depend much on where they appear
in the market.
Three things must be confirmed for the Hanging Man or Hammer pattern.
The real body must be at the upper end of the trading range of the said period.
It is important to note here that the colour of the real body is less important
than the shape and position (Nison, 1991). A long lower shadow is essential for
both the patterns, and ideally, the shadow should be twice the height of the real
body. It can be understood that the longer the lower shadow and smaller the real
body, the more bullish the Hammer and the more bearish the Hanging man. If
the real body of the Hammer is white and that of the Hanging Man black, the
bullish or bearish tendencies, respectively, are strengthened. When the Hammer
has a white body, it shows that the efforts of the bears to take the market down
was not only defeated but also that the price bounced back to be at or near the
session’s high. Similarly, if the Hanging Man has the black real body, it shows that
the close could not reach up to the opening price level, reinforcing the bearish
tendencies.
For the Hammer to denote bullish tendencies, it is important that there should
be a prior downtrend, and for the Hanging Man to denote bearish signals, there
should be a prior uptrend. As the Hammer appears in a chart (provided the
downtrend has been in continuation for some time), it reflects that the tendency
in the market was to go down in this trading session (as can be seen from the
long lower shadow) but that the bulls have managed to raise it above the open,
taking it near to the high of the trading session. In a prior uptrend, when the
Hanging Man appears, it shows that markets have not been able to close higher
than open, and the tendency to take the markets lower (as seen in the lower
shadow) is strengthened by the fact that the close was very near to the open. The
Hammer and the Hanging Man are shown in Figure 4.7. It is important to note
that we may not get the ideal pattern in most cases, and often, the lower shadow,
although long, will not be twice that of the real body. In Figure 4.8, for exam-
ple, we see the appearance of both the Hammer and the Hanging Man on the
euro (EUR/USD) weekly chart. As we can see, the Hanging Man at the top and
Hammer at the bottom of the first rally have small upper shadows. However, it
satisfies the condition of the lower shadow being twice the real body. The Ham-
mer, again, does not have to have a white body but can lead to a significant rally
in the markets.
Candlesticks patterns 75
FIGURE 4.8 Hanging Man and Hammer on EUR (weekly chart). Created with Eikon,
Refinitiv
that comes on the chart. It is important that there is a prior uptrend for a bearish
engulfing pattern. There should be clearly identifiable uptrend or downtrend prior
to these candlestick formations. It may be noted here that the second candle must
necessarily cover the prior real body; however, covering the shadows is not essen-
tial. However, if the second candle is engulfing the first one totally, the bearish or
bullish tendencies are reinforced.
The second candle must necessarily be of the opposite colour to the first one
except when the first one is a very small candle or Doji. It is possible that a small
candle or Doji is engulfed by a big black candle after a rally, or Doji is engulfed by
a big white candle after a downtrend; in both cases, it is taken to be engulfing pat-
tern (Nison, 1991). The greater the difference between the lengths of the bodies
of the first and second candles, the greater the force of momentum in the market
for a change. Again, heavy volume on the second candle confirms the pattern.
Figure 4.9 shows the bullish and bearish engulfing patterns. Figure 4.10 shows a
bearish engulfing pattern on HDFC Bank, where the real white body is covered
by a real black body, although not the shadows. Figures 4.11 and 4.12 show bullish
engulfing patterns on HDFC bank and EUR, which had a big white candle cover-
ing the prior black body, showing strong bullish tendencies.
day having with a long black candle as seen in Figure 4.13. On the second day,
the bears have completely overtaken the bulls, so a trend reversal is expected. It
represents a move to the downside. It is important that the first candle should be a
strong white real body. The second candle opens higher than the first candle’s close
78 Candlesticks patterns
FIGURE 4.12 Bullish and bearish engulfing on the Nifty (daily chart). Created with
Eikon, Refinitiv
but fails to sustain the momentum and closes well within the prior candle’s body,
near the low of the session. Traders usually look for 50% penetration of the second
session’s close into the white real body. In the case of less than 50% penetration, it
would be wise to wait for a second confirmation.
The market segment that defines the dark cloud cover is typical of bearish pat-
terns. The first day’s strong white candle is followed by an opening on a gap higher
to the previous days close. The bullish tendencies are strong, and expectations are
badly hurt when there is no continuation of the prior uptrend. Contrary to expec-
tations, the market moves much below the previous day’s high, giving the bears a
strong go-ahead to liquidate the long positions. If the second opening is with very
heavy volume, the appearance of the dark cloud would mean that the longs would
also liquidate their position. The opening of the dark cloud, that is the second ses-
sion’s body at a major resistance level, shows the failure of the bulls to continue the
rally upward (Nison, 1991).
Candlesticks patterns 79
FIGURE 4.15 Piercing line on Hindustan Zinc (daily chart). Created with Amibroker
80 Candlesticks patterns
of the star and a close above the midpoint of the first day. The Evening Star develops
after a prior uptrend and the Morning Star after a prior downtrend.
As can be seen in Figure 4.16, in the case of the Evening Star, initially, there is a
strong white candle. The second candle opens higher to the previous day’s close. The
star is usually above the body of the first candle; the third candle is a black one which
opens much below the star and closes lower to the second day’s open. While there
should be a gap between the first and second real bodies and another gap between
the second and third real bodies, the second condition is, however, less common than
the first one. However, the likelihood of a reversal post the Morning Star or Evening
Star is reinforced when there is a gap between the first candlestick and the star’s real
bodies and then between the star and the third candlestick’s real bodies (Nison, 1991).
The Evening Doji Star is similar to the Evening Star but the middle small candle is
replaced by a Doji. It also reflects a bearish pattern. Similarly, we may have a Morn-
ing Doji Star pattern. In the case of a Morning Star, initially, there is a black real body,
showing the bearish tendency in the market. Then a small real body appears, usually
with a gap, the small size of the candle showing that sellers are unable to keep the
market down. In the next trading session, a strong white real body appears, showing
that bullish tendencies have now come to the market and are taking over. The third
candlestick closing deeply into the first candlestick’s real body shows strong reversal
tendencies. A lighter volume in the first candlestick and heavier volume on the third
candlestick would increase the chances of the reversal (Nison, 1991). If there is an
upside gap Doji star for the Evening Star pattern or a downside gap Doji star for
Morning Star pattern, it is referred to as an Abandoned Baby Top or Bottom.
The Evening and Morning Star patterns are also called the Three River Evening
Star and Morning Star. According to Nison (1991), the name comes from the three
rivers which the army of Nobunaga Oda, the powerful feudal lord of Japan, had to
cross to defeat its enemies. It signifies a difficult hurdle, which when crossed leads to
a change in the other direction. Figure 4.18 shows the Evening Star on Nifty Daily,
which given the very small body of the star, can be referred to as Evening Doji Star also.
Figure 4.19 shows a Morning Star on AUD, which led to sharp reversals in the market.
FIGURE 4.18 Evening Star on the Nifty (daily chart). Created with Eikon, Refinitiv
82 Candlesticks patterns
FIGURE 4.19 Morning Star on AUD (daily chart). Created with Eikon, Refinitiv
4.3.7 Harami pattern
This pattern has a small real body enclosed within a previous long real body. In
Japanese, the term Harami means pregnant. The long candlestick in this case is the
Candlesticks patterns 83
mother and the small candlestick, the baby. The small candle is important as it
shows how spinning tops with small real bodies are very useful in predicting certain
formations. One can also think of the pattern as being the reverse of the engulfing
pattern. We have discussed that in the case of the engulfing pattern, the bearish or
bullish tendencies are strengthened if the two candlesticks are of opposite colours.
84 Candlesticks patterns
However, for the Harami pattern, this is not necessary. It is important to know that
this pattern may not be as strong for reversal sign as a Hammer or Hanging Man
pattern. It surely gives an indication to a stop of the prior trend, but further con-
firmations may be required before the prediction of the reversal is made. While the
Harami pattern by itself may not be a strong reversal pattern, if the second-day can-
dle is a Doji, then it represents strong reversal tendencies. This pattern is referred
to as a Harami Cross. Figure 4.24 shows the bullish and bearish Harami pattern in
CAD, and Figure 4.25 shows the bearish Harami on Maruti.
FIGURE 4.28 Bullish Belt Hold and Evening Star on GBP (daily chart). Created with
Eikon, Refinitiv
FIGURE 4.29
Three Mountain Tops on GBP (weekly chart). Created with Eikon,
Refinitiv
88 Candlesticks patterns
resistance three times and backed off, suggesting bearish pressures. The high point
of the third mountain should have a bearish candlestick pattern for a good confir-
mation of the downtrend. Similarly, the Three Rivers represent bottoms that give
support to the market and therefore predict a change in trend after the formation
of the third bottom. The presence of a bull candlestick pattern at the third bottom
signifies strong tendencies to reverse to an uptrend.
The variant of these patterns is the Three Buddha pattern (inverse Buddha
pattern), which is similar to the Head and Shoulders pattern (Inverted Head and
Shoulders pattern), with the middle top (bottom) higher than the other two. The
name comes from the common feature in Buddha temples, in which the bigger
Buddha statue is flanked by two smaller saints (or Buddhas) on both sides (Nison,
1991).
4.4 Continuation patterns
4.4.1 Windows
A window in Japanese candlestick study is a gap in the price pattern. The most
commonly used window patterns are Tasuki gaps. In the uptrend, the gap is between
the previous period’s upper shadow and next period’s lower shadow while in the
downtrend the gap is between the previous period’s lower shadow and current
period’s upper shadow. The gap represents a pause in trend movement and hints at
the continuation of the prior trend. In other words, windows act as support in the
uptrend and resistance in the downtrend.
The upside gap Tasuki is a formation of two candles after a gap up. In an
uptrend, a gap appears. A white candlestick appears or gaps up and is followed by a
black candlestick which closes under the white candle’s real body. The close of the
black candle is the buying point. If the black candle closes the gap and selling pres-
sure is still on, it would weaken the bullish pressures. Otherwise, markets should
continue the uptrend post the gap up.
The downside Tasuki has two candles in a downtrend, which appears after a gap
down. A black one is followed by a white one, which closes above the black candle.
It does not usually close the gap and will suggest a resumption of the downwards
trend post this pause in the market. The upside and downside gap Tasuki are shown
in Figure 4.30.
of the three must have black bodies. It can be thought that there is a three-period
Harami as all the three candles must hold within the body of the first one. The
final day must have another long white candle showing that prices will continue
upwards, and the open of this candlestick line should be above the close of the pre-
vious session. Figure 4.32 shows the Rising Three Methods on daily GBP.
The Falling Three Methods (Figure 4.33) will form in a similar pattern. The
first candle will be a black candle followed by three candles in the course of the
next three periods. At least two of these three candles should be white followed
by a long black candle, which will continue the move downwards. As mentioned
previously, while this represents the definition of the ideal formation, most often,
markets will have patterns different from the ideal formation. Traders in such cases
should not wait for the perfect pattern to develop and can make a trading decision
by combining two or more techniques.
4.4.3 Separating lines
Separating lines are formed by two candlesticks of opposite colours where both
have the same open. In an uptrend, a black candle is formed, and in the next trad-
ing session, the market opens at the same level as the previous candle’s open but
moves up instead of falling. Thus, a black candle is followed by a white candle. In
this case, it suggests bullish dominance and markets will move up in continuation.
In a downtrend, a white candle is formed, and in the next trading session, the
market opens at the same level as the previous session, but prices fall, with a black
candle emerging. In this case, prices will continue to fall as earlier (Figure 4.34).
Figure 4.35 shows the separating lines for GBP/USD.
We have looked at the most common candlestick patterns, reversal and con-
tinuation, that appear on charts. It is good to remember that the list is by no
means exhaustive, and several other patterns can emerge (see e.g. Nison, 1991).
FIGURE 4.32
Rising Three Methods on GBP (daily chart). Created with Eikon,
Refinitiv
Candlesticks patterns 91
FIGURE 4.35 Separating lines on GBP (weekly chart). Created with Eikon, Refinitiv
Candlesticks give an in-depth view of the market sentiment and can be used to
have effective trading decisions.
However, it needs to be appreciated that candlesticks, like classical patterns, do
involve subjectivity, especially if the formation on the chart is far from perfect. The
trader in those cases can make effective decisions by seeking confirmation from the
technical analysis indicators. Indicators, which we take up next in Chapters 5, 6
and 7, are more objective than classical or candlestick patterns and give clear-cut
trading signals. Let’s see how to effectively use them for trading.
4.5 Key takeaways
1 Candlesticks record the open, high, close, and low of price movement in a
particular time period.
2 On the candlestick chart, the open and close are reflected by the body of the
candle.
3 On the candlestick chart, the high and low for the period are reflected in the
shadows or the wicks of the candle.
4 The longer the real body of the bull (bear) candle, the more positive (negative)
the market sentiment.
5 Short candlesticks are noted during sideways movement of the market.
6 Dojis are candlesticks with little or no real bodies and represent indecision in
the market.
7 Reversal patterns do not translate into an abrupt change of trend in the other
direction.
8 The most common reversal patterns are Hanging Man and Hammer, engulf-
ing patterns, Dark Cloud Cover, piercing lines, Morning and Evening Stars,
Three Black Crows and Three Advancing White Soldiers, Harami, Tweezers,
Belt Hold lines, Three Mountains, and Three Rivers.
Candlesticks patterns 93
9 The most common continuation patterns are windows (Tasuki gaps), bullish
Rising Three Methods and the bearish Falling Three Methods, and separating
lines.
Note
1 Nison, S. (1991). Japanese candlestick charting techniques: A contemporary guide to the ancient
investment techniques of the Far East. New York: New York Institute of Finance.
5
MOVING AVERAGES AND THEIR
USE FOR TRADING STRATEGIES
The longer the trend has persisted, the larger the accumulation.
– George Soros1
5.1 Introduction
In 1886, Sir Francis Galton published an article titled ‘Regression towards Medioc-
rity in Heredity Stature’ underlining one of the most fascinating concepts biologi-
cal science had come across. He noted with surprise the tendency of the height of
children in a family to gravitate towards the mean from one generation or another
(Kahneman, 2011). He was fascinated by a phenomenon commonly referred to
today as the ‘regression towards the mean’, which underlines how there is a ten-
dency for any variable, observed over time, to gravitate towards its mean. As Daniel
Kahneman in his book Thinking Fast and Slow points out that this ‘statistical regu-
larity’ is, in fact, ‘as common as the air we breathe’ (2011, p. 179). This can explain
why a ‘less than average’ performance of a sports person or musician is likely to
be followed by a ‘better than average’ one, as her overall performance tends to be
close to the mean.
Does this not sound too common to the financial markets? Prices demonstrate a
tendency to move towards the mean values historically, giving rise to mean rever-
sion as one of the commonly observed phenomena in financial markets (Balvers,
Wu, and Gilliland, 2000). Times-series mean reversion implies that prices will be
deviating from and returning to their long-term average mean. Mathematically, this
means that the change of price in the next period is proportional to the difference
between mean price and current price (Chan, 2013). If prices do indeed tend to
move towards the mean, for the trader, it is important to understand how this can
be used to generate effective trading signals. In this chapter, let us understand the
concept of mean or average and its use in trading. With moving averages, we also
Moving averages 95
start into indicators which address the basic lacunae of classical indicators, that is
subjectivity of analysis.
D E F
FIGURE 5.1A 30-period moving average on the Euro. Created with Eikon, Refinitiv
FIGURE 5.1B 30- and 60-period moving averages on the Euro. Created with Eikon, Refinitiv
Moving averages 97
number of periods for the moving average? Figure 5.1.b contrasts the price move-
ment to both the 30-period and 60-period moving average lines. As we can see,
the 60-period moving average line (dotted line) is smother than the 30-period line
(solid line), averaging the data over a longer period. However, unlike the 30-period
moving average curve, it does not show the finer movements in price. For any mov-
ing average, an increase in the number of periods will lead to a smother curve while
neglecting the finer movements of the price. Selecting the number of periods for the
moving average therefore requires careful consideration. We will take up the section
of the number of periods of moving average in section 5.2.2.
5.2.1.1 SMA
The SMA is an unweighted moving average, effectively giving equal weightage to
all data points. Thus, for a 10-day SMA, each day’s movement is equally important
and therefore assigned equal weight. The calculation of an SMA in given in col-
umn M of Table 5.2.
1 K L M N O
data. In the case of LWMA, the most recent period observation gets the weightage
n, the just prior observation gets weightage n − 1 and so on. Thus, for a 10-period
LWMA, the 10th-period observation will be multiplied by 10, the 9th period by 9,
the 8th period by 8, and so on. For the 10-period LWMA, the most recent obser-
vation is thus given twice the weightage as the middle observation and 10 times
the weightage as the first observation. Similarly, a 20-period LWMA will put 20
times the weightage on the most recent observation than the first one so that as we
increase the number of periods for which the LWMA is calculated, the weightage
for the most recent observations increases by the same magnitude. The calculation
of LWMA is given in column N of Table 5.2.
where Multiplier (w) or Weight is 2/(1 + N), where N is the number of days for
which the EMA is calculated.
For n-period EMA (denoted by the superscript) pertaining to the t-th period
(denoted by subscript), we can write, assuming n = 10, t = 15, in equation 1,
2 10 2
10
EMA15 P15 EMA14 1 (1),
11 11
2 9 2 9 100
10
EMA15 P15 P14 EMA13 (1b),
11 11 11 11
81 9
10
EMA15
2 18
P15 P 81 * 2 P 121 * 11 EMA10
14 13
12
11 121 121 11
81 9
22 18 81 2 * 10
EMA P15
10
P14 * P13 121 11 EMA12
15
121 121 121 11
729 9
242 198 162 729 2 *
10
EMA15 P15 P14 P13 10
* P12 1331 11 EMA11
1331 1331 1331 13331 11 (1c),
and so on.
Moving averages 99
FIGURE 5.2 SMA and EMA on the Euro. Created with Eikon, Refinitiv
10
Equation 1 can be rewritten with the EMA14 term expanded as in equation 1(b).
10
Again the EMA13 can be expanded and so on. As we can see, the weights go on
decreasing exponentially, with the largest weight assigned to P15, the most recent
price. As we can see, unlike the LWMA, the EMA does not assign disproportionate
weight to the last observation, so we get a more representative series.
The calculation of EMA is shown in column O of Table 5.2. The EMA is one
of the most popular moving averages commonly used by traders. To understand
why it appeals to traders, consider Figure 5.2 which shows the SMA (dotted line)
and the EMA (solid line) of the same data. As we can see the SMA fails to reflect
the recent movements (e.g. points 1 and 2) while the EMA is more representative
of the recent fluctuations while still producing a smoother version of the price
movement. The figure shows the SMA and the EMA as compared to prices. The
SMA is the dotted line. It shows the trend but fails to give the recent swings in
prices. For example, the kink in the data at points marked by arrows is not reflected
in the SMA but is reflected in the EMA. The EMA cuts the noise but does not over
smoothen the movement, retaining the swings in price in the recent past.
Pt Pt n
ER . (2)
i t to t n
Pi Pi 1
TABLE 5.3 Calculation of KAMA
1 B C D E F G
The ER thus divides the net price movement by the summation of all price move-
ment, with the sum of each of the individual moves taken as a positive number. The
default setting for the n is 10 periods. Thus, the 10-period ER reflects price changes
with reference to 10 periods prior compared to the extent of movement in prices in
the recent 10 periods, having a value between 1 and 0. If prices have moved consid-
erably in the recent past, the value would be considerably higher near 1:
where
2
alpha f = ;
( fastest moving average period + 1)
2
alphas = .
( slowest moving average period + 1)
The default setting for the fastest-moving average period is 2 and that for the
slowest-moving average period is 30. Using the ER and the SC, the formula for
Kaufman’s Adaptive Moving Average (KAMA) is given as
The calculation of KAMA is given in Table 5.3. We can see in Figure 5.3, the
AMA (dotted line) gives the big swings in data while providing a smoother curve
compared to the EMA (solid line). For example, at point 1 the swing in prices is
reflected in the AMA, as also in the EMA, but the smaller movement at point 2
is smoothed better by the AMA. The sideways movement at point 3 is reflected
better in the AMA, which gives a clear idea that the trend is sideways, than in the
EMA, which followed the fluctuations in data.
FIGURE 5.3 AMA and EMA on the Euro. Created with Eikon, Refinitiv
102 Moving averages
5.2.2 Choice of period
Moving averages are powerful tools but the question for the trader is often which
moving average to use and for what period. The choice of the right period deter-
mines how effective the moving average will be for the trader. As discussed ear-
lier, the greater the period, the smoother the moving average. So one of the first
thoughts of the trader when using the moving average tools is the optimum num-
ber of periods to be used for moving averages. The number used for moving aver-
ages largely depends on the time frame used for trading. Faster moving averages
(shorter duration) would typically generate more trades than slower moving aver-
ages (longer duration). Those below 30 are generally considered to be shorter-
period averages while those above 30 are longer-period averages. Commonly used
periods include 7, 10, 14, 20, 28, and 30 for faster signals and 50, 100, and 200
for longer-period averages for recognizing the support and resistance patterns in
the market. Pring (2014) opines that the choice of the period for moving average
should depend on the type of trend identified, that is primary, intermediate, or
short, and will differ from market to market. The time frames suggested are 10
to 30 days (short term), 30 to 200 days (intermediate term), and 200 days to 24
months (long term). For the intra-day traders, it makes sense to tweak this principle
in terms of period instead of days. It is useful to remember that the choice of the
time span represents a trade-off between the laggardness of the moving average and
obtaining quick signals in the market. A too-short time span will lead to a greater
number of signals being generated but will lead to whipsaws for the trader. A too-
long time span would lead to few but stable signals; however, the fewer number of
TABLE 5.4 Calculation of centred moving average
J K L M N
29 2/28/2019 70.85
30
31 3/311/2019 71.01
32 =AVERAGE(K29:K35)
33 3/4/2019 70.92 =AVERAGE(K29:K37) =AVERAGE(M32:M34)
34 =AVERAGE(K31:K37)
35 3/5/2019 70.494 =AVERAGE(K31:K39) =AVERAGE(M34:M36)
36 =AVERAGE(K33:K39)
37 3/6/2019 70.09 =AVERAGE(K33:K41) =AVERAGE(M36:M38)
38 =AVERAGE(K35:K41)
39 3/7/2019 70.138 =AVERAGE(K35:K43) =AVERAGE(M38:M40)
40 =AVERAGE(K37:K43)
41 3/8/2019 70.028 =AVERAGE(K37:K45) =AVERAGE(M40:M42)
42 =AVERAGE(K39:K45)
43 3/11/2019 69.861 =AVERAGE(K39:K47) =AVERAGE(M42:M44)
Source: Author.
Moving averages
103
104 Moving averages
FIGURE 5.4 Moving average as support and resistance. Created with Eikon, Refinitiv
FIGURE 5.5
Comparing AMA, centred moving average, and EMA. Created with
Eikon, Refinitiv
signals also means a loss of trading opportunities. Moving average value can also be
decided by a trial-and-error method. During an uptrend, an average that tends to
provide support to prices more number of times than the others can be considered,
and during the downtrend, the average, which acts as resistance and results in price
reversals, can be considered as a good period for the moving averages.
trend or direction of the price movement. It marks the trend – it smoothens, cuts
out the noise, and tells the trader which direction he or she should be on.
The moving average as support and resistance gives the floor and ceiling,
respectively, of the price movement. The moving average thus is a dynamic level
of support and resistance (Pring, 2014). Supports are areas where prices find
the strength to go up. It establishes the uptrend as anytime the prices reach this
level; the buying activity of the bulls surpasses the selling activity of the bears.
Similarly, resistance establishes the downtrend as anytime prices reach this level;
the selling activity of bears overcomes the buying activity of the bulls so that
prices fall. Support and resistances thus are pauses in the market with reference
to the trend.
Look at the 100-period EMA in Figure 5.4. As we can see, the EMA has acted
well as a support to the prices as whenever prices have started to correct in this
uptrend, they recovered from the moving average line, which acted as the support.
This suggests that the line presents the levels below which the currency finds it dif-
ficult to go down. Similarly, the 100-period EMA line has acted as the resistance,
an upper limit for prices to slump back from.
How to use the support or resistance levels? As discussed in Chapter 2, supports
and resistance are entry points in the market. Supports act as entry points to go
long in an uptrend while resistance represents entry points to short in a downtrend.
There is nothing more delightful to the trader than being on the right side of the
trend, and support and resistances allow the trader to enter the market at the most
opportune moment. As the price falls to the support levels, it represents a good
buying opportunity in an uptrend while temporary price hikes to the resistance
levels represent a good selling opportunity in a downtrend.
giving the maximum emphasis on the recent observations, is therefore best suited
and extensively used for the crossover technique.
5.4 Crossover technique
The first major use of moving average is to understand the price movement rela-
tive to the longer-term trend in the market. The divergence between the price and
the trend is important, as prices tend to revert to mean, as discussed earlier. Again,
the use of two or more averages can generate useful trading signals in the markets.
5.4.1 Double crossover
A double crossover is one of the most commonly used moving average tools. The
double crossover method employs two moving averages to generate buy and sell
signals. The double crossover method employs two moving averages: a shorter and
a longer period. The technique rests on a very simple principle: if two moving
averages were plotted on a price line, the shorter-period moving average would
follow the price line more closely than the longer-period moving average. For
example, a 10-period and a 20-period moving average may be used for the dou-
ble crossover method. The 10 periods covering a shorter duration will follow the
prices more closely while the 20-period moving average is the smoother of the
two. Therefore, when the 10-period moving average crosses above the 20-period
moving average, it shows prices are rising faster than the average movement and
a move to an uptrend is signalled. Similarly, when the 10-period moving average
crosses below the 20-period moving average, it signals a downtrend.
It would be good to reiterate here that any change in the trend will first be
reflected in prices going below the average. Price will lead the movement while the
moving averages, lagged by nature, will follow. As the price heads downwards, the
shorter-period moving average (following the price action more closely) will turn
earlier to the longer-period average. This implies that there will be a point where
the shorter-period average intersects the longer-period moving average from above
as the price moves downwards. The shorter-period moving average cutting the
longer-period moving average from above signifies a reversal towards the downside.
Similarly, the shorter-period moving average cutting the longer-period moving
average from below signifies trend reversal towards the upside. The first one is
called a bear cross or dead cross whereas the second one is referred to as the golden
cross or bull cross (Bedford, 2012).
As we can see in Figure 5.6 of State Bank of India for a 30-minute time frame,
the EMA for 30 and 20 periods are plotted with the price movement. The two
moving averages follow the price line but with different intensities. The finer dot-
ted line following the price line closely is the 20-period EMA2 while the larger
dotted line farther away from the price line is the 30-period exponential moving
average. The crossover technique compares the price movement with reference
to the two moving averages and generates signals based on crossovers in the two
Moving averages 107
FIGURE 5.6 Double crossover on the State Bank of India (30-minute chart). Created
with Eikon, Refinitiv
FIGURE 5.7 Sideways movement and moving averages. Created with Eikon, Refinitiv
moving averages. As you can see in Figure 5.6 at point 1, the 20-period EMA
cuts the 30-period moving average from below, making a bull cross. This suggests
that the prices are moving up or there is a reversal on the upside. Point 4 shows a
bear cross, implying that prices will move on the downside. As can be seen from
Figure 5.6, points 1 and 4 give definite signals of trend reversals and help the trader
ride the trend. However, the shortcoming of the double crossover method lies in
the lagged nature of the moving average. As can be seen in Figure 5.6, the reversal
of the trend on the upside happens at point 2, while the reversal on the downside
happens at point 3. However, the crossover signals come at points 1 and 4, so the
trader misses out a part of the trend. This shows that the double crossover method
can be helpful in generating signals in the market, but the signals will generally be
lagged in nature.
108 Moving averages
In addition to the delayed signals generated by the moving average crossover tech-
nique, another problem is the false signals generated. In the case of sideways move-
ment, there can be false signals as the bigger moving average can turn flat and the
shorter moving average will keep moving above and below the bigger average. For
example, in Figure 5.7, points 1 and 2 show false signals generated with a moving
average crossover. As we can see, post the crossover signal at point 1, which predicts a
downtrend, the market may have actually moved flatly and corrected upwards. Simi-
larly, while point 2 predicts an uptrend, but there is a correction before the market
moves up that would have led many traders’ stop-loss levels to be hit.
One way to tackle the issue is to use filters to give confirmation before making a
decision, discussed in Chapter 2 in the context of trend reversal. Traders frequently
use price and/or time filters (Murphy, 1999) for decision-making in such scenarios.
For example, if the crossover suggests prices are going to move up (down), the trader
may wait for prices to go up (down) by a certain number of percentage points before
making the decision. The percentage points will be different from market to market
and depend on the security in questions. In the case of a time filter, the trader may
wait for two candles to show a rise or fall in the direction envisaged for a confirma-
tion. A combination of price and time filter can be also used to give confirmation.
FIGURE 5.9
Using moving averages: EUR/USD (daily chart). Created with Eikon,
Refinitiv
moving average crossover method can give effective signals but the problem for the
trader is to decide when to exit the market. In this case, using Fibonacci retrace-
ments can be useful for setting both take-profit and stop-loss levels.
Let us take up now the chart of gold futures (continuous contract) in INR in
Figure 5.10, which underscores once again the importance of moving averages.
In this case, we show that a combination of longer and shorter moving averages
can be used, identifying support and resistances. The use of moving averages as
dynamic support and resistances gives the trader entry and exit points in a market.
Three different EMAs of periodicity 200 days, 100 days, and 25 days are selected.
The longer-term moving average provides support to the primary trend, and the
same can be seen earlier. The EMA of 100 days managed to provide support to
the intermediate swings, and the shortest moving average of 25 days acted as good
support during the minor trends. It may be noted that the moving average period
may be selected not necessarily based on standard parameters but with regard to its
support for prices.
It can be seen that early to mid-September 2018, the 25-day EMA crossed
above the 100- and 200-day average, and later prices also moved above all of these
averages. There were instances when prices moved below the averages, but the
25-day EMA continued to sustain above the 200-day average, thereby helping the
trader stay in the direction of the trend or look for buying opportunity unless there
is a negative moving average crossover.
Gold futures rallied from the bottom of 30220 towards 46000 levels in just
over a six-month period. Prices are also moving between the support trend line
and the resistance trend line of the channel. It is best to avoid entering fresh long
positions when prices are near the upper trend line of the channel and buy when
it comes near the support of moving averages or the lower trend line of the chan-
nel provided when there is a short-term positive reversal pattern near the support
Moving averages 111
area as per methods discussed in earlier chapters. A trader should combine multiple
techniques discussed earlier in the book in addition to the preceding to identify a
good trade set-up.
It would be incorrect to assume that global uncertainty due to COVID-19 fears
is driving the price of gold higher as gold prices in terms of INR have continued
their upward journey since 2019.
Moving averages are one of the most useful tools to understand the trend, as
we have discussed in this chapter. The use of different moving averages according
to need helps the trader be on the right side of the trend. However, one of the
major problems with moving averages is the delayed signals obtained. In the next
chapter, we take up momentum indicators which can help us address this lacuna of
the moving average method.
5.6 Key takeaways
1 Prices demonstrate a tendency to move towards the mean values historically
(mean reversion).
2 Moving averages cut out the noise in the price series and help with recogniz-
ing the trend.
112 Moving averages
3 The greater the number of periods used for calculating the moving average,
the smoother the moving average will be.
4 An SMA is an unweighted moving average.
5 The LWMA gives the most weightage to the most recent period observa-
tion, with the weights reducing linearly from the most recent to the first
observation.
6 The EMA also gives more weightage to the recent data, with the weights
reducing exponentially from the most recent to the first observation.
7 The AMA, developed by Perry Kaufman, balances the smoothing of the price
series with incorporating swings in the series.
8 The centred moving average assigns the moving average values corresponding
to the midpoint of the series.
9 The choice of the period for moving average should depend on the type of
trend identified.
10 Moving averages are dynamic levels of support and resistance.
11 The double crossover method employs two moving averages to generate buy
and sell signals.
12 The shorter-period moving average, which follows the price line more closely,
cutting the longer-period moving average from above signifies a reversal
towards the downside.
13 The shorter-period moving average cutting the longer-period moving average
from below signifies trend reversal towards the upside.
14 The triple crossover method employs three moving averages, where one signal
is confirmed by a second crossover.
15 Moving averages are trend-following indicators and therefore give lagged
signals.
Notes
1 Soros, G. (2015). The alchemy of finance. Hoboken, NJ: John Wiley & Sons.
2 We are using the EMA here for the double crossover method. While other moving aver-
ages can be used for the double crossover method, the use of the EMA is most pertinent
as discussed earlier. The use of the EMA implies that we give the greatest emphasis to the
most recent price movement.
6
MOMENTUM INDICATORS AND
STOCHASTICS
6.1 Introduction
While trend-following strategies have historically proven to be profitable (Hurst
et al., 2017), the challenge for the trader at the desk is to understand the trend early
on. To be what Murphy (1999) calls the ‘astute trader’, you have to be the prover-
bial early bird who understands the trend generation before others in the market.
The ‘early trend-catcher gets the profits’ is an adage many live by in the financial
markets. Therefore, how to be the early trend catcher has remained a perennial
question for traders. Trend-following indicators are abundant, but the problem
remains that they ‘follow’: signals are generated later, so you miss a major portion
of the market with such strategies. This has already been explained in Chapter 5,
where we saw one of the major problems with the crossover technique is the lagged
signals generated.
It is here that momentum-based based indicators or oscillators step in. The
major idea behind oscillators is to understand what the force in the market is.
Momentum indicators try to address a major lacuna of the moving average–based
strategies: the laggardness of the signals. If the moving average shows the direction
of the trend, momentum gives the strength of the direction. The momentum indi-
cators give early signals of trend reversals by suggesting when the market has lost its
momentum to go forward in the same direction or trend. Momentum-based indi-
cators and oscillators are hugely popular in that they give early signals and are fairly
easy to interpret. Can the momentum-based indicators be the solution the trader
is looking for? While momentum-based indicators help to understand the trend
earlier than others, the signals generated often turn out to reflect market vagaries
114 Momentum indicators and stochastics
or ‘moods of the moment’ rather than the general market trend. To be effective,
indicators therefore should try to blend in an understanding of trend following
with the momentum. Swing recognition and reversal confirmation are also aided
by stochastics. Stochastics use the position of price in a range to generate trading
signals. Stochastics show whether prices are in the upper or lower end of the trad-
ing range and can be used for effective confirmations. We will see in this chapter
the momentum indicators and stochastics to understand better trend reversals.
M = V −V * ,(1)
In this case, the momentum will be positive (negative) if the closing price at time t
is greater (smaller) than the prices at t − n. This would suggest prices have moved
on the higher (lower) side compared to what it was n periods back. The period
for the momentum indicator is also called the look-back period, the momentum
indicator comparing the price of the present position to the price position at the
look-back period (Miner, 2008).
Momentum indicators, also popularly known as oscillators, capture the velocity
of price movement or the rate of change in prices. If prices are increasing, it asks,
are they increasing at an increasing rate? If prices are falling, it asks, are they falling
at an increasing rate? For any momentum indicator the concept of midpoint line,
depicting a zero rate of change in price, is very important. In the previously men-
tioned case for momentum indicator M, if prices at t period are more than what
they were t − n periods back the momentum indicator will show a positive value
above the zero line. The reverse scenario would show a negative value below the
zero line. Thus, the momentum line will give the buy or sell signals prior to the
moving average crossover.
Momentum thus gives a very useful indicator of the rate of price change. We
can elaborate on this point with the help of Table 6.1 and Figure 6.1.
Table 6.1 gives the price, the three-period moving average, and the three-
period momentum. From the Price column of Table 6.1, we can see that the price
shows an increase from 16/8/19 to 8/9/2019 and then a decline from 9/9/2019 to
16/9/2019. However, the rate of increase as prices increase or decreases is not the
Momentum indicators and stochastics 115
TABLE 6.1 Comparison of prices with three-period moving average and momentum
16/08/19 10
17/08/19 10.5
18/08/19 11.13 10.54 1.13
19/08/19 11.91 11.18 1.41
22/08/19 12.86 11.97 1.73
23/08/19 14.02 12.93 2.11
24/08/19 16.82 14.57 3.96
25/08/19 22.04 17.63 8.02
26/08/19 26.67 21.84 9.84
29/08/19 30.13 26.28 8.09
30/08/19 31.04 29.28 4.37
31/08/19 31.66 30.94 1.52
1/9/2019 31.97 31.56 0.94
2/9/2019 32.29 31.98 0.64
3/9/2019 32.62 32.3 0.64
4/9/2019 32.94 32.62 0.65
5/9/2019 33.27 32.94 0.66
6/9/2019 33.61 33.27 0.66
7/9/2019 33.94 33.61 0.67
8/9/2019 30.55 32.7 –3.06
9/9/2019 28.1 30.86 –5.84
10/9/2019 26.42 28.36 –4.13
11/9/2019 25.36 26.63 –2.74
12/9/2019 24.85 25.54 –1.56
13/9/2019 22.87 24.36 –2.49
14/9/2019 22.64 23.45 –2.21
15/9/2019 22.41 22.64 –0.46
16/9/2019 22.19 22.42 –0.45
Source: Author.
same for the entire period. We can see from the first column that price increases
by jumps till 30/8/2019 and then the price increase stagnates. The Momentum
column reflects this, with momentum increasing to 30/8/2019 and then falling.
Similarly, the momentum column gives the rate of change when prices fall from
9/9/2019 onwards. The three-period moving average cannot reflect the rate of
change in prices. This can be seen from Figure 6.1, which plots the price, the
three-period moving average, and the three-period momentum. Initially, the price
increases at an increasing rate; then it increases at a decreasing rate. Similarly, when
the price falls initially, it falls at a higher pace, and then the rate of the fall is sub-
dued. From Figure 6.1, it is clear that the three-period moving average is not able
to reflect any of these changes in the rate of change of price. The moving aver-
age simply follows the price line. The momentum indicator shows clearly that
till point A on price line and point B on the momentum line, the price increases
at an increasing rate. From point B, the momentum falls sharply while the price
116 Momentum indicators and stochastics
B
40.00
35.00 C
30.00 A
25.00
20.00
15.00
10.00
B
5.00
D
0.00 E
16/08/19
17/08/19
18/08/19
19/08/19
22/08/19
30/08/19
31/08/19
1/9/2019
2/9/2019
3/9/2019
4/9/2019
5/9/2019
6/9/2019
7/9/2019
8/9/2019
9/9/2019
10/9/2019
11/9/2019
12/9/2019
13/9/2019
14/9/2019
15/9/2019
16/9/2019
23/08/19
24/08/19
25/08/19
26/08/19
29/08/19
-5.00
-10.00
continues rising till point C, but it rises at a decreasing rate. Again, the drop in
price from point C is very sharp, reflected in the fall in momentum from point D,
while from the point E, the price continues to fall but at a decreasing rate. In the
downtrend, the momentum is negative, reflecting the price fall.
The ROC is one of the simplest momentum indicators. The ROC is a ratio
constructed to compare the recent closing price to the price, a certain number of
periods back. To make the indicator easily comparable, it is taken with reference
to the 100 line.
The n-period ROC therefore can be written as
In this case, the midpoint line will be given by 100, and movement above that line
is taken to be representing an uptrend, while movement below that line repre-
sents a downtrend. If the ROC indicator is above the reference line (or midpoint
line), it shows that the price is higher than it was n periods earlier. As we can see,
momentum looks at the rates of increase or decrease. This means that if the ROC
line is above the line of reference or zero line and rising, the uptrend is accelerating.
If the ROC line is above the line of reference but slopes downwards towards the
line of reference or zero line, we can say the rate of ascent is falling. This implies
Momentum indicators and stochastics 117
that the uptrend is losing momentum. We can interpret on similar lines, when the
ROC line is below the zero line. As the momentum measures the differences in
prices at two given time points, if the price advance is by the same amount, the
momentum line will be flat.
It is important to note that momentum indicators reflect momentum trends and
not price trends (Miner, 2008). Many times, traders take the change in the direc-
tion of the momentum line (e.g. from upwards to downwards) to be a change of
trend. However, what is happening when the momentum line changes its direction
is simply a change in ‘rate of price movement’. In an uptrend, the change in the
direction of the momentum line from upwards to downwards shows the uptrend
becoming less forceful. On the other hand, when the market is in a downtrend and
the momentum line moves down sharply, it means that bearish tendencies are in
full force in the market. A change in the momentum line to the upside, while the
downtrend is still on, shows that the bearish tendencies are reducing. Thus, it is
very important to remember that as momentum indicators represent momentum
trends (and not price trends), we cannot always expect the prices to reverse when
the indicator makes the reversal (Miner, 2008). While this may sometimes hold
true, many times, the price and the momentum will move in opposite directions,
as the price change is only slowing, trend is not changing.
What should be the correct time span for a momentum indicator? Pring (2014)
opines that like moving averages, for longer-term trends, a 12-month or 52-week
momentum is reliable while for intermediate trends, 9-month, 6-month, and
3-month momentum work well. Shorter-duration momentum indicators include 20,
25, or 30 days (or hours in the case of intra-day data). The time frame for momentum
indicators can also be looked at by understanding the cyclicality of prices.
One of the key advantages of using a momentum indicator is shown in Fig-
ure 6.2. Figure 6.2 shows the momentum line for GBP daily price. We can see that
FIGURE 6.2 Moving average and momentum on the GBP (daily chart). Created with
Eikon, Refinitiv
118 Momentum indicators and stochastics
the momentum lines gives faster trend-reversal signals than moving average lines.
At point 1, as shown by the arrow, we have a crossover, with a 30-period EMA
cutting the 40-period EMA from below. However, momentum moved above the
midpoint line much earlier at point 2, shown by the arrow. Note the move thereaf-
ter. We can see prices moved up first, stagnated, and finally registered a fall, which
was reflected in the momentum line. The sharp fall in price towards the end is
reflected in the momentum line, but while the EMAs come close together, there
is no crossover to suggest the move downwards that actually happened. Thus, the
momentum line can give vital clues to the strength in the market and is much faster
than the moving averages. However, it is important to stress that the movement in
the momentum line suggests a change in momentum, not necessarily change in
trend, as discussed earlier.
Let us look at some characteristics of momentum indicators which must be
considered before using the momentum indicator for trading decisions.
First, the momentum characteristics tell us about the strength or weakness of
the underlying price trend. The most commonly used technique of interpretation
is the consideration of overbought and oversold levels. While for indicators like
ROC, which has a wide range of variability, it is difficult to define the overbought
and oversold boundaries, other oscillators like RSI have clearly defined overbought
and oversold levels. Overbought levels show that the rate of increase in prices is
very high, which may not be sustainable over time, while an oversold level indicates
the rate of fall in price has been extreme, which is unlikely to be sustainable. How-
ever, when the price reaches an overbought or oversold level, it is not to be thought
of as a reversal (Pring, 2014). An overbought reading simply suggests that prices
have run up too far away, or an oversold condition suggests that prices have run
down steeply and there is a possibility of consolidation to relieve the overbought
or oversold state. It does not suggest taking the opposite stance but does provide a
warning that buying in the overbought condition or selling in the oversold condi-
tion is not prudent.
Second, the characteristics of momentum indicators in a bull and a bear market
are different (Pring, 2014). In the bull market, it is easy for oscillators to move into
an overbought region, and this is especially true in the initial bull market phase.
When the rally has just started it is easy for the momentum to quickly move to the
overbought region and give high values which should not be taken as suggestions
of a trend reversal. However, if the overbought region is reached during a maturing
bull trend, there are greater chances of a reversal. In a bear market, moving to an
oversold region does not suggest an immediate rally as markets are less sensitive to
an oversold reading, and it may simply suggest a move into a trading range.
Third, one of the most useful ways in which momentum can be used is to
signal divergences between the prices and its velocity. If price makes a new high
which is not confirmed by the momentum indicator, a negative divergence results.
This suggests that a correction can be expected in prices. Analogously, if prices
are moving down, making a new low not confirmed by the momentum indicator,
a positive divergence results. Divergences usually imply that a reversal in trend is
Momentum indicators and stochastics 119
likely. However, for the reversal signal to be confirmed, there should be an indi-
cation from the price itself that it has reversed (Pring, 2014). It is important for
traders not to rush into a trend-reversal-based trade on the basis of the divergences
alone. The confirmation can be obtained from another indicator or a trend line
break by the price or completion of a price pattern (Pring, 2014).
Fourth, trend lines may be drawn on the momentum chart by connecting the
peaks and troughs just like in a normal price chart. This is important as it helps
with understanding where the momentum is going; also, it helps with correctly
reading a divergence. The break on a momentum trend line should be taken as a
caution, and if accompanied by a break in the price trend, it offers evidence of a
trend reversal.
Fifth, a simplistic interpretation of the midpoint line can be: when momentum
goes over the midpoint line, it is a buy signal, and when momentum goes below
the midpoint line, it is sell signal. However, it can be quickly seen the momentum
indicators are pretty volatile, so such a strategy would lead to a lot of whipsaws.
One way to handle the situation is to use a moving average to smooth the oscilla-
tor. However, another way in which the problem of erratic movements in simple
momentum indicators like the ROC is addressed is the use of oscillators like the
RSI. The RSI sees the velocity of price changes over a period, unlike the ROC,
which calculates a jump between two points in time. The RSI is also useful in giv-
ing a definite range of overbought and oversold regions, which helps with devising
trading strategies. In the next section, we consider RSI, one of the most popularly
used momentum indicators or oscillators.
6.3 RSI
Developed by J W Wilder, the concept of relative strength index looks to address
some problems of the simple momentum indicators. As discussed earlier, any sharp
rise in price on a particular date compared to n periods back will represent a sharp
movement in the momentum indicator. RSI brings in a smoothening to the indi-
cator, as well as giving it a range useful for interpretation of the indicator. The RSI
is given by the following formula:
period may be adjusted. However, as most analysts agree that the 14-period default
time span works ‘consistently well’ in most markets (Pring, 2014, p. 283), we suggest
keeping the default at 14 periods unless there is evidence of the market cycle being
different from the weekly or monthly cycle. It is important to point out here that
compared to the ROC, the RSI will not be subject to wide fluctuations given the
averaging over the 14-period cycle.
In the case of the RSI, as we have seen, we are finding the average ‘up values’
and the average ‘down values’, and the relative strength is given by the ratio of the
average of X periods’ ‘up closes’ divided by the average of X periods’ ‘down closes’.
If the average of X periods’ up closes is greater than that of X periods’ down closes,
RS will have a high value. The greater the RS, the smaller the 100 / (1 + RS * ) in
equation 3 and the greater the RSI. Similarly, the smaller the value of RS, the
greater the 100 / (1 + RS * ) and the smaller the value of the RSI.
How is the RSI to be interpreted? Values over 70 are taken to be representative
of overbought conditions in the market while values below 30 are taken to be rep-
resentative of oversold conditions in the market. In some markets, the overbought
region is taken to be above 80, and the oversold region is taken to be below 20. As
the RSI calculation is with reference to 100, the midpoint is given at 50. It may
be noted that if up closes equal the down closes, RS takes the value of 1, and the
RSI will be 50.
Traders should be cautious in the overbought and oversold region as it shows
that the market is overheated and we might see some consolidation or near-term
correction. It is also important to understand that the overbought or oversold
regions will change with respect to a bull or a bear market. In the case of a bull
market, the RSI will oscillate from 40 to 80 levels whereas in the case of a bear
market, the readings can be seen generally between 20 to 60 levels. A better way
for deciding the overbought or oversold levels is to look at the history of data and
see the areas from where the RSI has reversed earlier. As pointed out earlier for
the ROC, the RSI in the overbought region does not mean that we liquidate the
long position immediately; neither does the oversold region mean we go long. The
overbought and oversold regions can be taken to be a warning sign which shows
that the momentum in the market is too high and may not be sustainable.
One of the most useful ways in which the RSI are used in the market is to spot
divergences. Divergences, as discussed earlier, is the movement of price and its
velocity in different directions. If the price is on an uptrend, making higher highs,
and the RSI starts moving down (fails to make a higher high and makes lower
high), we note a negative divergence. Negative divergence suggests that the rise in
prices may be misleading and that the momentum is no longer strong in the mar-
ket. If the price is on a downtrend, making lower lows, and the RSI starts moving
up (fails to make the lower low and makes higher low), we note a positive diver-
gence. If divergences happen in the overbought and oversold regions, they give
very strong signals. If the market is in the overbought range and prices are moving
higher while the RSI makes a lower high, it is a sign of divergence. It is likely that
the uptrend will reverse. However, in this case, confirmation from either the price
Momentum indicators and stochastics 121
line or any other indicator is required before we liquidate the long position. Simi-
larly, if the market is in the oversold range and prices are moving down while the
RSI makes a higher low, it can be taken to be a sign of positive divergence. In this
case, it is likely that there will be a reversal from downtrend to uptrend. This sug-
gests that we can go long on the confirmation from either the price line itself or if
there is any price pattern breakout.
Figure 6.3 shows negative divergence for GBP/USD on the daily time frame. As
we can see there is an uptrend (marked in upper panel), prices made higher highs
but the RSI makes lower highs (marked in lower panel), suggesting that the move
in prices has lost momentum and a negative divergence. Note RSI borders on the
Over Brought range before showing divergence. Figure 6.4 shows positive diver-
gence for EUR/USD on the daily time frame. The downtrend (marked by region
1) is not supported by strong momentum as the RSI makes higher lows (marked
by region 2) when prices made lower lows, suggesting a positive divergence. The
trend reversed thereafter as we see in the chart. The RSI is in the oversold range
when it shows divergence. This is a strong signal, as the move to the overbought
and oversold regions suggests an overheated trend, so the divergence becomes all
the more potent.
6.4 MACD
Along with the RSI, the MACD is one of the most useful indicators which can
be applied to any time frame. The MACD indicator uses two important lines, the
MACD line and the signal line. The MACD line is constructed with the help
of two exponential moving averages, usually the 12- and 26-period EMAs. The
MACD line is the difference between the 12-period and 26-period EMAs. The
signal line is the nine-period average of the MACD line. The MACD is thus an
oscillator based on EMAs. While different periods can be used for the two expo-
nential moving average as well as the signal line, the most commonly used are 12
and 26 for the two averages and 9 for the signal line.
The MACD line therefore performs what the two exponential moving averages
do in a double crossover technique. When the MACD line is above the midpoint
or zero line, it shows a bullish trend as the shorter period or faster-moving average
is above the longer-period moving average. As we know, in an uptrend the faster-
moving average (12) is closer to the price line than the slower-moving average (26).
Similarly, when the MACD line is below the midpoint line, it shows a bearish trend
or that the difference between the faster- and slower-moving averages is negative.
In a downtrend, the faster-moving average (12) again will lie lower to the slower-
moving average (26), following the price line closely. The MACD line reaching
zero means there is a crossover in the 12- and 26-period EMAs.
Again, when the MACD line is above zero and rising, it shows that there is
strong momentum in the market, while the MACD line going down shows weak
momentum. Below the midpoint line, in a downtrend, the MACD line moving
sharply down indicates strong bearish pressures, while a move up suggests that the
downtrend momentum is drying up. Thus we see the MACD line itself can tell us
a lot about the trend and the momentum. The MACD line represents a change in
momentum.
However, with this indicator, we are interested in going beyond moving averages
and the crossovers. For this purpose, a new line called the signal line is brought in.
The signal line, being the nine-period average of the MACD line, is the smoother
and slower version of the MACD line. This means that, when plotted together, the
MACD line and the signal line will generate crossovers, giving buy and sell signals.
As the MACD represents the momentum, the crossovers, in this case, show the
swings in momentum. A buy signal is generated when the fast-moving MACD line
crosses the slower signal line from below, and a sell signal is generated when the
fast-moving MACD line crosses the signal line from above. The MACD thus tells
Momentum indicators and stochastics 123
us not only the trend but also the change in momentum, so the trader can be both
on the side of the trend and trade with the swings in momentum.
MACD histograms reflect the difference between the MACD line and the signal
line. The difference between the two lines reflects changes in the momentum in
the market. A histogram increasing in size shows an increase in momentum while
a histogram falling in size shows decreased momentum in the market.
Just as in other momentum indicators, divergences between the movement in
the MACD and price lines can also be useful for trading decisions. If the price line
in an uptrend makes a higher high while the MACD makes a lower high, it suggests
a negative divergence. Similarly, when prices are in a downtrend and make lower
lows and the MACD fails to make a fresh low, it suggests a positive divergence.
While divergence is a very useful indicator, it is useful to remember that divergence
by itself does not translate to a trading decision and needs confirmation of price
action (Tudela, 2010). According to Tudela (Ibid), the MACD technique using the
signal line and the MACD line for crossover gives a more stable crossover than mere
exponential moving averages. However, we must look at the fundamental market
structure to evaluate signals from the MACD.
Figure 6.4 shows the MACD for euro daily data. The MACD crossover is faster
than a moving average crossover. The correction from point 1 to 3 is reflected in
the crossover of MACD and signal lines. The areas marked by 3 and 4 show the
uptrend in prices and downtrend in MACD, respectively. Prices formed higher
highs whereas the MACD formed a lower high which suggests a negative diver-
gence, just like for the RSI. Point 5, where the MACD goes below the zero line,
suggests that a crossover signal (from 26- and 12-period EMA) was given at this
point, which is lagging behaviour as moving averages turn later compared to actual
prices.
In Figure 6.6 with the incorporation of the MACD forest2 or histogram, we
see that the histogram which reflects the difference between the MACD line and
signal line effectively show the swings in price. The move from point 1 is reflected
in the MACD forest becoming negative as the MACD line is below the signal line.
The MACD forest is in the negative range: while there is an uptrend in prices
(region 3), there is a fall in momentum (region 4). Note the smaller histograms at
the maturing trend phase, suggesting a significantly small strength in momentum.
6.5 Stochastics
Stochastics use the position of price in a range to generate trading signals. The
idea behind the stochastic is that if price tends to be near the upper end of a trad-
ing range, it suggests an uptrend while with the trend maturing and approaching
a reversal, price will tend to move away from the high of the trading range. In the
downtrend, the reverse conditions would be true. The stochastic use two lines: %D
and %K. The %K line is obtained as follows:
where Close is the recent close, Low refers to the lowest low for the last n trad-
ing periods, and High refers to the highest high for the last n trading periods.
By default, n is usually taken to be 5. One of the most useful things done by this
formulation is to bring the comparison between the latest price and the range of
prices to a number in the range 0 to 100. The %D line is a three-period average
of the %K line. As we have faster and slower lines, we can use these two lines to
generate crossovers which can give us useful trading strategies. Just like an RSI, the
%K and %D lines also have overbought and oversold regions, usually taken to be
above 70 and below 30 for overbought and oversold, respectively. A crossover, that
is the %K line crossing the %D line from above, is a sell signal, while the %K line
Momentum indicators and stochastics 125
FIGURE 6.7 %D and %K line on EUR chart. Created with Eikon, Refinitiv
crossing the %D line from below is a buy signal. However, trading solely based on
indicator crossover should be avoided, and confirmation from prices is must either
in the form of a breakout from the patterns or a break of important support or
resistance levels or a trend-line break.
In Figure 6.7 we see the %D and %K line plotted in the lower panel of the
chart. The crossovers between the lines give the swings in the price movement
as shown by points 1 and 2. In the region shown by 3, the stochastic shows that
the price nearing the oversold region as the down move has lost its momentum,
heralding the correction to the uptrend marked by 4. However, as can be seen in
Figure 6.7, there are several crossovers in the given period. While they suggest a
change in momentum, not all suggest a change in trend, so we should be careful
in interpreting the signals.
In the next section, we discuss a variant of the stochastic method or an applica-
tion of the stochastic on Heiken Ashi (HA) candlesticks.
6.6 HA Stochastic
Effective trading in live markets requires an indicator that can predict the trend
generation, the swings with big momentum in the market, and the next reversal.
To address this issue, we develop an indicator, the HA stochastic, or HASTOC,
which can give a unique insight into the trend as well as momentum in the mar-
ket.3 The HASTOC gives a numerical value to show if the trend is changing and
how much is the momentum in the market.
HA is a variant of the very popular Japanese candlestick technique. HA uses a
form of averaging to smooth out the movement in the market. As with the tra-
ditional candlestick pattern, HA also uses the open, high, low, and close prices.
However, in the HA candlesticks, this information is reflected in a different way.
126 Momentum indicators and stochastics
Close = (Open Price + High + Low +Close) / 4, each price being of the cur-
rent period;
Open = Average of Open and Close Price of the previous HA candle;
High = Maximum value of the (High of the Period, Open of HA, Close
of HA);
Low = Minimum value of the (Low of the Period, Open of HA, Close of HA).
The preceding formula tells us that each price in the HA candlestick is a derived
one. The open of the HA candlestick is the average of the open price and close
price of the previous HA candle, which implies that it reflects the average move-
ment that the price has taken previously. The close of the HA is the average of
the entire price movement during the period. As the HA open of each period
requires knowledge of the prior period’s HA open and close, for the initial
period, we assume that the HA open equals the average of the market open and
close.
The HA close would be greater than the HA open (resulting in an HA bull
candle) only when the average prices for the period exceed the average of the
previous period’s HA. The greater the momentum therefore the longer would be
candle. The small-body HA candles, especially coming after a series of long-body
HA candles, therefore represent a change in momentum. The HA candle length, as
well as the wick sizes, can be a good indicator of reversal. Trend reversal is marked
by small-body HA candles. We note that the difference between the HA candle
open and close can be good as an indicator of a trend reversal, and trades taken
accordingly should be based on this difference narrowing down.
However, the problem with using the difference between the HA candle open
and close (Dt) as an indicator for analysis is that it gives absolute values, which tend
to differ across securities and markets. So we attempt to develop a standardized
indicator HASTOC with a definite range of values to get clear-cut quantitative
signals out of the tool.
The HASTOC takes the values between 0 to 100%. Any value greater than 70%
is taken to be increased trend momentum while any value less than 10% would be
taken to be a trend reversal. The stochastic tries to put the HA open and close dif-
ference in the context of the average difference over the last 10 periods:
Dt − Min ( Dt )
HASTOCt = ,
Max( Dt ) − Min ( Dt )
price confirmation by a break below the trend line or the pivot low which was at
350 levels. The MACD indicator shown below also indicated a sell signal by the
MACD line (thick) moving below the signal line.
The moving average of 240 periods had been plotted by looking at the past data
as the same average provided support during the rise. The parameter of the average
was selected on the basis of the support provided in the past. Each stock or asset
has its own characteristics and can be selected on the basis of whether it provides
support or resistance to prices. The 240-period EMA acted as a good support, and
a breach of this average was also a negative signal.
For a trader, it is always important to have a cluster of evidence that confirms
that a trend is changing and that provides good trade set-up. By having multiple
indicators and methods pointing in the same direction, there will be high convic-
tion with objectivity to make the trade.
Thus, on 22 July prices, breaking below 350 confirmed that there was a channel
support break, a Double Top pattern formation, negative divergence on the RSI,
a sell signal on the MACD, and a breach below the moving average, which was
enough of a cluster of evidence for a trader to take a short position. The pattern
target as per the Double Top formation was obtained by taking the length between
the peaks and the neckline and projecting it on the downside from the neckline.
This gave the target of 330 on the downside.
There are different ways to approach the scenario once prices reach the target
levels. A trend-follower trader might look forward to book partial profits at the
target level of 330 for 50% of the position and, for the remaining 50% position, to
follow a trailing-stop method.
There are various levels shown on the chart where the stops can be trailed as
prices move lower. These levels are shown by minor pullback on the upside which
provides a good level to trail the stops. By following the method of booking partial
profits and following a trailing-stop method, the trader will ensure to have taken
something off the table, making the position risk-free, and then ride the entire
trend unless there is confirmation of a price reversal.
In early August 2019, there is an indication that the downtrend is losing
momentum as we can see a positive divergence between prices and the RSI and
between prices and the MACD. Prices formed a lower low whereas the RSI and
the MACD exhibited higher lows. Here, a trader can look to book another 25%
of profits and then trail the remaining 25% of the position with the trailing-stop
method. The final 25% of the position can be booked when prices move above
the trailing-stop level. The preceding methods show the complete trade set-up by
combining indicators with patterns, the moving average, the trend line, and the
trailing-stop technique.
B. Nifty 50
The Nifty 50 is the NSE’s index for the Indian equity market. We see the monthly
chart of the Nifty in Figure 6.9 for the period 2009 to 2019. A strong uptrend in
Momentum indicators and stochastics 129
FIGURE 6.10 Nifty daily chart analysis (May–July 2019). Created with Eikon, Refinitiv
the Nifty is seen in Figure 6.9, and we see that the ongoing uptrend is showing
signs of a slowdown in momentum. The RSI and the MACD show the negative
divergence between prices and its momentum.
On the daily chart shown in Figure 6.10, we see that during the uptrend there
was a clear negative divergence between prices and its momentum indicators dur-
ing the period April to June 2019. Prices reversed to the downside after the diver-
gence. Prices formed lower highs and lower lows and confirmed negative trend as
per Dow Theory. Post correction from the peak, at point 1, prices did not make a
higher high, and the MACD line moved below the 0 level from point 2 soon after-
wards. The Fibonacci level of 23.6% (11605) was important as prices found sup-
port at this level, and later on, this level also acted as resistance in early July 2019.
A break below this level resulted in a move towards 61.8% level near 10799 from
where there has been a bounce back. Thus, we see the move in the Nifty from May
130 Momentum indicators and stochastics
to June 2019 would be forecasted with the help of the RSI and the MACD. The
Fibonacci levels could be used by the trader to pinpoint a forecast to definite levels.
This illustrates how Fibonacci retracement and momentum indicators can be used
to form a trading strategy.
The move in the Nifty thereafter is analysed on the weekly chart, shown in
Figure 6.11. We see the formation of wedge pattern along with continued negative
divergence on RSI, seen also on the monthly and daily charts discussed earlier. On
the weekly chart, we see the Nifty formed higher highs in January 2020 compared
to June 2019 and August 2018. Each of these consecutive tops was associated with
lower readings on the RSI that clearly suggested that the rise is on the back of
lower momentum. This was a warning signal for the investors. The formation since
September 2018 looked like a wedge pattern, and a negative confirmation was
obtained as soon as the lower trend line of the pattern was broken in March 2020.
This breakdown coincided with the outbreak of COVID-19 in India which was
already spreading across the globe. It is a coincidence that the already-topping pat-
tern for more than a year with slower momentum resulted in a breakdown along
with the pandemic. This indicates that even if a trader or investor is not paying
attention to the news or events and is focusing on charts, it would have helped in
understanding the weak market structure and distribution ongoing for more than
a year. There was sharp decline, or rather crash, in subsequent weeks after the
FIGURE 6.12 Nifty daily chart analysis (July 2019–April 2020). Created with Amibroker
132 Momentum indicators and stochastics
For a trader to take a position over the short term, it is important to also look
at shorter time-frame charts. Figure 6.13 showing the hourly chart of the Nifty
Index. The breakaway gap was formed between 11650 and 11400 levels on 6
March 2020. This was a negative confirmation on the short-term chart pattern.
For a trader, it is always important to have a cluster of evidence that confirms
that a trend is changing and provides a good trade set-up. Multiple indicators and
methods across the time frame pointed out that the major Indian equity index
was reversing to the downside. A trader can capitalize on the down move by tak-
ing short positions on the break of the wedge pattern, shown in Figure 6.12, and
later by adding more during the breakaway gap, shown in Figure 6.13. Also as
discussed earlier, gaps provide resistance to subsequent price action. Later during
the decline, there were two Runaway Gaps, and a trader could have trailed the
stop to these gap areas, thereby ensuring the protection of the initial capital and
riding the trend using the trend-following method based on gaps and trend-line
resistance levels. The fall was contained within the downward sloping channel,
and the upper trend line of the channel acted as strong resistance. By following
trailing-stop method, a trader can squeeze out the maximum from a trade until
it is confirmed to have reversed by taking out the trend-line resistance. The final
gap was later proved to be an Exhaustion Gap as the same gap was filled later.
The low formed near 7511 in March 2020 was then associated with positive
divergence seen on the Nifty hourly chart, where prices formed lower lows and
the RSI formed higher lows. The subsequent rise took out the trend line resist-
ance and the earlier minor high which was the trail-stop level at 8880. This way, a
trader would have been able to capture the trend from near 11400 to 8880 levels.
Fibonacci retracements are shown on the hourly chart.
The preceding method shows a complete trade set-up using multiple time-
frame charts, indicators, patterns, and moving averages following a trend-following
method.
We saw in this chapter, how momentum indicators can give us leading signals
for effective trades. They help to understand the trend and its strength, enabling us
to ride the trend as well as effectively trade the swings. Momentum indicators can
be used effectively with both classical and/or candlestick patterns for effective trade
set-up. In the next chapter, we take up volatility and volume indicators, which are
effective for trending as well as non-trending markets.
6.8 Key takeaways
1 Momentum indicator considers the rate of change in prices over a particular
time interval.
2 Momentum indicators give an indication to the strength in the market and
suggest early signals to trend reversals.
3 Momentum indicators reflect momentum trends, not price trends.
4 Overbought levels show that the rate of increase in prices is very high, which
may not be sustainable over time.
5 Oversold levels indicate the rate of fall in price is too sharp, which is unlikely
to be sustainable.
6 The RSI, one of the most popular momentum indicators, addresses problems
of the simple momentum indicators.
7 Divergences are the movement of a price and its velocity in different directions.
8 If a price is on an uptrend, making higher highs, and the RSI starts moving
down (fails to make a higher high and makes lower high), it is called a negative
divergence.
9 If a price is on a downtrend, making lower lows, and the RSI starts moving
up (fails to make the lower low and makes higher low), it is called a positive
divergence.
10 The MACD is an oscillator based on 12- and 26-period EMAs.
11 Stochastics use the position of price in a range to generate trading signals.
Notes
1 Italics in original. Shiller, R. J. (2016). Irrational exuberance (3rd ed., p. 2). Princeton, NJ:
Princeton University Press.
134 Momentum indicators and stochastics
7.1 Introduction
Volatility is an essential feature of financial markets. In fact, often without volatility
there is no trend generated, and it is difficult to delink and distinguish between the
two. As Dr. Bibek Debroy, chairman of the Prime Minister’s Economic Council,
put in the context of the Indian rupee, ‘(it is) difficult to distinguish between vola-
tility and what is a trend’ (First Post, Jan 2nd, 2018). The advent of new informa-
tion in financial markets is a catalyst for action. The impact of such information, in
the form of macroeconomic news, on market volatility has also attracted substantial
economic analysis. There is strong empirical evidence of macroeconomic news lead-
ing to volatility in financial markets (Bessembinder, 1994; Fleming and Remolona,
1999; Evans and Lyons, 2008; Omrane and Hafner, 2015; Vortelinos, 2015).
What happens in financial markets following the arrival of macroeconomic
news? Fleming and Remolona (1999) show that macroeconomic announcements
led to an increase in spreads and that the impact on bid–ask spreads is greatest in
the shortest time frames. This sharp change in bid–ask spreads following a macro-
economic announcement is, interestingly, irrespective of trading. In microstructure
theory, bid–ask spreads represent order-processing costs, asymmetric information
costs and inventory carrying costs (Bessembinder, 1994).
In the dealer-driven foreign exchange market, for example, the act of mar-
ket making imposes on interbank dealers the need to either maintain liquidity in
terms of currencies themselves or provide liquidity to counterparties by trading at
given rates immediately. This ‘provision of immediacy’ leads to opportunity costs
136 Volatility and volume indicators
7.2 Volatility indicators
( t 1Pt P )
2
BBUB MA 2 (1)
( t 1Pt P )
2
BBLB MA 2 (2)
The preceding formulae underline the logic behind Bollinger Bands: if markets
follow a standard normal distribution, Bollinger Bands will cover 95 % of the
market movement. Traditionally, the Bollinger Bands are always constructed with
reference to the SMA and not the EMA. This is because the standard deviation is
calculated always with reference to the SMA, and therefore, the use of the SMA
with the Bollinger Bands formula is logically consistent (John Bollinger, 2019).
However, the use of the formula for calculation of upper and lower bands and
the interpretation drawn from them, that Bollinger Bands should cover 95% of
the market movement, should be taken with caution. It may be remembered that
in most cases, the sample size of the data used is too small for the statistical sig-
nificance. Second, markets, in reality, do not follow a normal distribution (John
Bollinger, 2019). What this means is that typically we may find a lot of market
values outside of the Bollinger Bands which however can be used for trading
decisions.
Difference between the upper band and lower band (bandwidth) is an indicator
of the extent of the volatility of the series. The Bollinger Bands strategy requires
determining the volatility of the series as it is expected that the periods of high
volatility, represented by higher bandwidth, are followed by periods of low vola-
tility, with the bands coming closer. In market parlance, this is called a ‘squeeze’.
A squeeze is generally followed by a period of increased volatility.
Usually, the Bollinger Bands are constructed for 20 periods; the default in most
charting systems would be the same. Similarly, by default, the standard deviation
used for calculation of the lower and upper bands is 2. However, some traders opt
for 1.5 or 2.5 depending on the market conditions. It must be remembered that if
we increase the number of periods, we can get a smoother but less sensitive version
of the Bollinger Bands. John Bollinger (2019) points out that if the average period
Volatility and volume indicators 139
FIGURE 7.2 Bollinger Bands (EUR hourly chart). Created with Eikon, Refinitiv
140 Volatility and volume indicators
the 20-period moving average and are moving towards the upside, the upper band
is the next price target. However, as point 2 shows, many times, they will be cross
back into the lower zone, so the trend does not reverse with the simple crosso-
ver above the moving average. In these cases, confirmation from other indicators
would help in taking a trading decision. Point 3 shows prices reaching the lower
band post a crossover of the moving average line.
Figure 7.3 shows an interesting aspect of price which is underlined by the Bol-
linger Bands. As we can see, while at points 1 and 2, the price level is the same,
the condition of the market is very different. The Bollinger Bands show that while
at point 1, the prices are at an oversold level; at point 2, the prices touching the
upper band are overbought. Thus, even at the same prices, market conditions may
be much different, as brought about by the Bollinger bands.
During a range-bound market, the upper and lower bands provide resistance
and support to prices, respectively. During a strong up-trending market, one can
observe that prices tend to cling towards the upper end of the band which also
turns up along with prices and that prices tend to stay in the upper region of mov-
ing average and the upper band. Similarly, during a strong downward-trending
move, prices tend to stay near the lower end of the band which also turns down
and stays within the range of the lower band and the moving average.
In a nutshell, Bollinger Bands provide vital information to trader for making a
trading decision and suggests that volatility is about to increase when bands expand
or is reducing when bands contract.
In Figure 7.4, the Nifty Index shows range-bound movement for nearly three
months before finally managing to break out of the range on the upside. Bollinger
Bands provided resistance and support during the range-bound action. There was a
squeeze in the bands which was later followed by expansion along with a breakout.
Prices clung to the upper end of the bands as the trend was strong and stayed in the
region of upper bands and moving average.
FIGURE 7.3 Bollinger Bands overbought and oversold levels (EUR hourly chart).
Created with Eikon, Refinitiv
Volatility and volume indicators 141
7.2.3 ATR
The ATR, developed by J. Welles Wilder in his 1978 book, New Concepts in
Technical Analysis, looks at the range between high and low prices to arrive at an
estimate of volatility. While the indicators discussed earlier, moving average enve-
lopes and Bollinger Bands, are based on the close prices of a security, ATR looks
at the difference between the high and low values, or the range in prices during
a trading session (Northington, 2009; Grafton, 2011). For calculating the ATR,
we consider
1 the difference between the present period’s high and low (D1),
2 the difference between the previous period’s close and the present period’s
high (D2), and
3 the difference between the previous period’s close and the present period’s
low (D3).
TR = Max ( D1 , D2 , D3 ) . (3)
(We take the greatest of the three preceding values, which is the true range for the
present period.)
142 Volatility and volume indicators
The ATR is calculated as follows using the modified EMA, as done by Wilder
in his book (Grafton, Ibid):
The ATR is fairly simple to interpret. As the range widens, it is reflected in the
ATR, showing that there is an increase in volatility. An increase in value of the
ATR indicates that volatility is increasing, and we normally see a rising ATR dur-
ing a downtrend as a down move is associated with a rise in volatility. However,
when the market is coming out of the range, we might witness a rise in the ATR
value, along with a rise in the prices as well. So a lower reading of the ATR is
associated with a non-trending or range-bound market. Again, as with Bollinger
Bands, a small value for the ATR suggests a narrow range which usually comes just
before a breakout in the market (Rockefeller, 2002).
It may be noted that the ATR can incorporate the market vagaries arising in the
market. As can be seen with the formula noted earlier, the second and third items
(i.e. the difference between the previous periods close and the present periods
high and the difference between the previous periods close and the present periods
low) take care to incorporate any gap that has come in the market. This is crucial
because gaps represent ‘sudden change in perceptions and preferences’, as pointed
out by Rockefeller (2002). Such a gap would undoubtedly reflect on market vola-
tility. Using the ATR for a period, we can project the average range for coming
periods which is an extremely useful tool in the market.
Commonly the ATR is normalized using the closing prices that is by dividing
the value by the underlying closing price for the period. While high or low can
also be used for the purpose, using the closing price gives a sufficiently normalized
value for interpretation (Northington, Ibid). As seen in the chart volatility changes
are clearly reflected in ATR, closely matching the Bollinger Bands, and the ease of
interpretation of ATR makes it suitable to be used for calculation of stop loss and
take profit levels, as we will do in Chapter 10 on backtesting.
Figure 7.5 shows the ATR for EUR/USD along with the Bollinger Bands.
As we can see, the ATR maps to increase in volatility just as in an indicator like
Bollinger Bands. Moreover, in range-bound areas also, the decreased volatility is
depicted well by the average true range as seen from the area marked 2 in the chart.
The ATR value is lower during range-bound movement, and it increases during
trending move.
7.3 Volume-based indicators
While volume-based indicators specifically look at the trading volume to generate
signals, even for price-based indicators or price patterns, it is important for techni-
cal analysts to see whether price and volume patterns are in agreement. Price and
volume patterns in agreement suggest the extension of trend whereas when the
price and volume patterns are not in agreement, it suggests that the underlying
trend has lost its momentum (Pring, 2014). Sometimes, when price action gives
subdued signals of a trend reversal, volumes give strong signals. On most charts,
volume is charted directly under the price action so that for each price action, the
corresponding volume action may be noted. Some softwares uses the volume bar
colour white or green if the prices have closed higher compared to the previous
close and black or red if the price closes down. Let us consider here two com-
monly used volume-based indicators: volume oscillator and the Chaikin Money
Flow Index.
7.3.1 Volume oscillators
A volume oscillator is calculated in the same way as a price oscillator, the price data
being replaced with volume data. Commonly moving averages of volume data are
used as volume data typically are more volatile than price data (Dormeier, 2011).
Commonly used volume oscillators include the ROC of volume and the per-
centage volume oscillator. There also some price-based volume oscillators, which
include the accumulation/distribution line and the Chaikin Money Flow Index.
One of the most commonly used volume oscillators is the ROC of volume.
The ROC of volume is calculated in the same way as that for price, replacing the
price data with volume. Thus a volume ROC is simply the percentage change
between the current period’s volume and the volume n periods back:
However, the simple ROC of volume is not a smooth indicator and has limited
applicability given the sharp move in the volume data. A day with a significant less
144 Volatility and volume indicators
FIGURE 7.6
Volume and volume ROC on SBI (daily chart). Created with Eikon,
Refinitiv
trading volume will unnecessarily influence the value of ROC even though it may
not influence the trading in the current period (Kirkpatrick and Dahlquis, 2011).
The volume ROC is used to recognize spikes in the volume. Spikes in the volume
are more common at the beginning and end of the trend, and therefore, higher-
than-usual volumes are used to recognize reversal patterns.
Figure 7.6 shows the 10-day ROC-of-volume indicator. Peaks in the ROC
indicator signal the exhaustion of a trend, but the same is not reflected in the
volume histogram alone. The ROC can also show divergence between price and
volume which signifies that the trend is losing its strength. For example, point 1 on
the chart shows a divergence between the volume and the price action. As we can
see, the price makes a higher high, but the volume histogram and ROC shows a
rate of change in volume makes a lower high, signifying divergences between price
and volume. At point 2, we can see that prices registered a rise, but the volume
ROC and the histogram are clearly showing that the trend lacks strength as volume
has been minimal. Point 3 shows the divergence between price and volume, sug-
gesting that the trend is not sustainable.
The Chaikin Money Flow Index thus sees market strength in prices closing in the
upper half of the daily range with increasing volume. The market is weak when
prices close in the lower half of their daily range with increasing volume. As can be
seen from the formula, if prices consistently close in the upper half of their range on
increased volume indicator would be positive. If prices are closing in the lower half of
their daily high low range on increased volume then the indicator would be negative.
It also enables us to have overbought and oversold levels for this indicator. Positive
divergence is seen when prices are making lower lows, but the indicator makes higher
lows, and similarly, a negative divergence is seen when prices make higher highs
while the indicator makes lower highs. While divergences are common in all oscil-
lators, it looks very strong and balanced in the money flow indicator (Pring, 2014).
Just like the volume ROC, the Chaikin Money Flow Index helps with under-
standing the volume accompanying the price. We can see at point 1 of Figure 7.7
prices have been increasing as shown by the higher highs made by price, but the
Chaikin Money Flow Index shows a fall, suggesting that the trend is not supported by
increased volumes. Similarly, at point 2, we note divergences in prices and the volume.
At point 3, prices have been making a higher high, and the volume histogram also
shows an increase in the volume. However, the Chaikin Money Flow Index shows
lower highs, suggesting that the price trend is not supported by an increase in volume.
FIGURE 7.7 Chaikin Money Flow Index on SBI (daily chart). Created with Eikon,
Refinitiv
146 Volatility and volume indicators
A. Reliance industries
In Figure 7.8 of reliance industries, there are multiple methods applied – Bollinger
Bands, volume, and ATR. Following are the important observations.
During the period from November 2018 to mid-January 2019, the stock moved
in a narrow range. This resulted in a contraction of Bollinger Bands. During the
same period, the average volume also steadily reduced. Prior to the consolidation,
there was a sharp fall in prices in October 2018. This sharp correction resulted in a
rise in the ATR value as expected. A fall in prices is normally associated with a rise
in volatility and bigger candles. The trending move was followed by non-trending
move, and the ATR moved lower during the consolidation phase.
On 18 January 2019, there was a clear breakout above the upper end of the Bol-
linger Bands. There was a contraction in the bands which indicated a non-trending
move, and this was followed by an expansion that confirmed a trending move is
probably emerging. This was also associated with a sharp rise in volume which fur-
ther supported the breakout. The ATR also rose slightly along with the breakout,
B. Nifty 50
In Figure 7.9, the Nifty Index daily chart is taken to keep it in continuation from
the case in the previous chapter. This will enhance the perception of looking at
the charts using different methods discussed in previous chapters and analysing the
crash during 2020 known historically for financial markets meltdown, economic
turmoil, and the COVID-19 pandemic. During the period from September 2019
till January 2020, there was wedge-pattern formation discussed in detail in earlier
chapters. This was associated with a reduction in volatility, and the ATR clearly
represented that. The average range of the index continued to decline until the
breakdown from the wedge pattern was witnessed. The Bollinger Bands contracted
during the period, and the break on the downside from the pattern was later fur-
ther confirmed along with the Bollinger Bands’ expansion. The ATR also reversed
back on the upside, thereby indicating the rise in volatility which is normally asso-
ciated along with the fall. The ATR reading was nearly 100 on 28 January 2020
which shot up above 500 levels by 24 March 2020. The similar outcome was seen
in the India Volatility Index that moved from the sub-12 levels to the high above 86
by 24 March 2020. This clearly confirms that the ATR can be used as a proxy for
volatility. Any positional or swing trader in this scenario would have had to adjust
the position sizing and stop-loss levels accordingly to accommodate for the rise in
volatility as the risk profile of the market drastically changed post January 2020.
The cases discussed in the last three chapters underline how to use multiple trad-
ing frames and indicators for effective trading decision-making. In recent times, as
148 Volatility and volume indicators
markets have become more volatile, the use of volatility and volume indicators will
be crucial for trading decisions. Both volatility and volume indicators can help us
refine trading decisions and have effective trading both in trending and non-trend-
ing markets. Moreover, trading strategies based on indicators discussed in the last
three chapters can be easily backtested and used for framing algorithms, as discussed
later in Chapter 10. However, the visual analysis of chart patterns is incomplete
without considering the Elliot Wave Theory which, as we will see, is extremely
useful for longer-term forecasting and in-depth understanding of the market trend.
Let us now take up an understanding of the price movement which will allow us
to predict long-term price movements: the Elliott Wave Principles, in Chapter 8.
7.5 Key takeaways
1 Moving average envelopes are the simplest measure of the volatility of price
movement.
2 For Bollinger Bands, two trading bands are placed around a suitable moving
average, ±2 standard deviations of the series.
3 The difference between the upper band and lower band (bandwidth) is an
indicator of the extent of volatility of the series.
Volatility and volume indicators 149
Notes
1 Taleb, N. N. (2001). Fooled by randomness: The hidden role of chance in life and in the markets.
New York: Penguin Random House LLC.
2 Normal distribution is a continuous probability distribution frequently used for repre-
senting random variables whose distribution is not otherwise known. Standard normal
distribution is a normal distribution with mean 0 and the standard deviation 1. For a vari-
able with the standard normal distribution, 68% of the observations lie within ±1 stand-
ard deviation of the mean of 0 and 95% lie within ±2 standard deviations of the mean.
8
ELLIOTT WAVE PRINCIPLES
After all, the Wave Principle indeed may be nature’s way of giving us a peek at
the future.1
− Robert Prechter
8.1 Introduction
Two of the basic premises of technical analysis are that history repeats itself and that
markets are fractal in nature. By this it means that the patterns and price behaviour,
we witness on the shortest time-frame charts can be witnessed even on the longer
time-frame charts. This is the reason why the concepts of technical analysis and, in
turn, an Elliott Wave can be applied across the time frames. In an Elliott Wave, the
smallest of the waves combine to form higher-degree wave patterns which, in turn,
combine to make a much higher-degree wave construction. This is the reason why
the forecasting ability of Wave Theory is very strong, and it can be done right from
the shortest of the time frames, stretching towards years ahead.
Developed by Ralph Nelson Elliott in the 1930s, this theory proved to be an
effective means for analysing patterns in the stock market. According to him, the
psychology of investors plays an upper hand in the financial markets, and the stock
prices move in a particular pattern or ‘waves’. He later went on to analyse this in
detail. By plotting the prices in graphical form, one can clearly see that on many
occasions the collective behaviour of the crowd results in price movements which
are repetitive in nature. It is preferred that the Wave Theory is applied to the cash
markets. In the case that there are only futures data available, the theory can be
applied on the same but with a little caution.
R. N. Elliott discovered that prices of freely traded market move in a repeatable
pattern. One has to understand these patterns, with their variations in terms of
price and time, in order to forecast the future price action.
Elliott Wave Principles 151
8.1.1 What is a ‘wave’?
Market fluctuations are fractal, so for every movement, there are subdivisions.
A wave is a movement that takes the form of one of the Elliott Wave model’s
descriptions.
It is best to understand the patterns of an Elliott Wave by categorizing it as either
an impulse pattern and a corrective pattern. It is important to label the impulse and
corrective waves differently to make a clear distinction on the price chart. Impulse
waves are labelled with numbers, and corrective waves are labelled with letters.
the prior impulse pattern either in terms of price and/or time. Waves 1, 3, and 5
are themselves travelling in the direction of major movement and result in a pro-
gression. These waves are themselves impulsive in nature.
Figure 8.1 emphasizes the building block for an Elliott Wave. The move from
label 0 to label 1 is termed as the entirety of wave 1; the move from label 1 to label 2 is
termed as wave 2. Therefore, waves are labelled at their respective completion point.
• Wave 2 will not retrace more than 100% of wave 1. This means that wave 2
cannot move below the starting point of wave 1.
• Wave 3 cannot be the shortest among the impulse waves, and it is very com-
monly the longest. This means that wave 3 cannot be shorter in terms of price
with respect to both wave 1 and wave 5. It can be shorter than one of the
waves but not both waves at the same time.
• Wave 4 cannot enter into the territory of wave 1. This means that in an
impulse up move wave 4 cannot move below the highest point of wave 1 and
Elliott Wave Principles 153
in the case of an impulse down move, wave 4 cannot overlap with the lowest
point of wave 1.
In the case of a third wave extension, it is common to see wave 2 retracing wave 1 to
the extent of Fibonacci golden ratio 61.8%. Wave 4 has a tendency to retrace wave
3 to the extent of 38.2% (100% − 61.8%). This is the guideline based on the Fibo-
nacci relationship between different waves but should not be considered as a rule.
Figures 8.2a–c show the counts that are invalid based on the preceding three rules.
8.3.2 Understanding degrees
It is important to understand the concept of degree. The smallest degrees of the
waves combine and form a one-higher-degree pattern. This way, the wave pattern
of the same degree combines to form higher-degree counts.
In Figure 8.3, the smallest-degree waves labelled (i) through (v) combine to form
a higher-degree wave (1). This entire wave (1) is corrected by wave (2) that retraces a
portion of wave (1). The internal pattern of wave (2) is divided into three waves labelled
as (a), (b), and (c). Thus, wave (1) comprises a five-wave pattern of larger degree which
is then corrected by wave (2), which is a three-wave pattern of the same degree. Simi-
larly, wave (1) through wave (5) combine together to form another higher-degree wave
((1)) which is later followed by wave ((2)) that retraces a portion of wave ((1)).
This is the most important aspect to understand in the Wave Theory. The rules
cannot be broken to any degree across any time frame under consideration.
To summarize:
wave can travel to the extent of Fibonacci 1.618 times of non-extended waves. On
a few occasions, the extended wave can also be 2.618 times of non-extended waves.
Usually, it is the third wave which is extended in stock markets. In commodities,
wave 5 is usually the most extended. It may also be the case that an extension is
witnessed in the extending wave itself.
Note: This is not a rule and must be followed as a guideline.
Also, it is often observed that the non-extended waves tend towards equality. So,
if the third wave is extended, then wave 1 and wave 5 will tend towards equality.
An extension typically occurs only in one of the impulse waves.
Wave 3 is extended or elongated in comparison to wave 1 and wave 5.
Subdivision: Mostly the extended wave is also subdivided into its internal five-
wave pattern. This means that the extended waves will show the internal subdivi-
sion of five waves. Figure 8.4 shows that wave 3 is extended and subdivided as
well. It is not necessary that the extended waves are always subdivided. On a few
occasions, the non-extended waves can show subdivisions.
Figure 8.5 presents an hourly chart of the Nifty index that represents an impulse
wave that is adhering to all the rules of an impulse pattern. The following are
important points to note:
Wave 3 is an extended wave and measures 1.618 times of wave 1.
Post completion of wave 5, the corrective pattern is under formation.
156 Elliott Wave Principles
Diagonal pattern
This is a variation to the impulse pattern and is also known as diagonal-triangle
pattern. It takes the form of a wedge pattern with the two converging trend lines
moving either upside or downside. In this pattern,
Elliott Wave Principles 157
The third rule has an exception wherein wave 4 will mostly overlap with the price
territory of wave 1.
A diagonal pattern can appear in wave 1 or wave 5. A diagonal formation in
wave 1 is called a leading diagonal. The internal sub-waves of a leading diago-
nal are 5–3–5–3–5, which is similar to that of a normal impulse pattern with the
exception that wave 4 here overlaps with wave 1. This is a rare pattern, and the
probability of the occurrence is very low. It is best to avoid counting the start of
an impulse with a leading diagonal. The ending diagonal that appears in wave 5 or
wave C is an important pattern. Sub-waves of an ending diagonal pattern are all
threes or corrective in structure (3–3–3–3–3). Therefore, wave 1, wave 3, and wave
5 are all threes within the ending diagonal. At times, there can be a throw-over
above the upward-sloping trend line in the case of an upside-sloping pattern, which
is a ‘bull trap’, and when the pattern is downward-sloping, we see a throw-under
below the lower trend line, which is a ‘bear trap’.
An ending diagonal pattern occurs in fifth wave position, especially when wave
3 is elongated or extended. It is also found in wave C of corrective A–B–C for-
mations. This pattern indicates termination of the move of one higher degree. In
Figure 8.6, an ending diagonal is formed in wave 5.
FIGURE 8.7 Ending diagonal pattern (Nifty daily chart). Created with Amibroker
Elliott Wave Principles 159
• Wave 5 of the impulse failed to go beyond the end of wave 3, forming a fifth
failure pattern.
• Wave 5 internally is subdivided into five waves.
• Wave 3 is strong and extended. When wave 3 is sharp and strong, the chances
of wave 5 failing is high. This can be seen here.
FIGURE 8.9 Fifth failure pattern (Maruti weekly chart). Created with Amibroker
8.4 Corrective waves
A corrective pattern results in a move against the prior trend of one higher degree.
It has the tendency to correct the prior move which can be either up or down.
This correction can be in terms of price and/or time.
There are standard corrective patterns and complex patterns that combine these
standard corrections. It is important to understand the standard corrections clearly
so that it is easier to apply and identify them during complex pattern formations.
Corrective patterns are labelled as alphabets.
Standard corrective patterns are zigzag, flat, triangle, and Diametric.
waves, and therefore, the internal counts are labelled as an impulse pattern. Wave B
itself will be corrective. Also, there is a tendency for wave C to move below the end
of wave A. These are important guidelines to remember when identifying a zigzag
pattern. The 0–(B) trend line shown is an important trend line. If we see breach
above (or below) this trend line in the case of a downward (upward)sloping zigzag, it
indicates that the pattern is probably getting over and the up (down) move is resum-
ing. In the case of an upside-sloping zigzag pattern, a break below the 0–(B) trend
line indicates that the pattern is probably complete and the downtrend is resuming.
The length of wave C is normally dependent on the retracement level of wave
B. If wave B is small in terms of price compared to wave A, there is a possibility for
wave C to move beyond equality to that of wave A. On occasion, wave C can be
1.618 times to that of wave A, which is known as an elongated zigzag. If wave B
retraces 38.2% to 61.8% of wave A, there is a high possibility that wave C will be
equal to the price distance of wave A or will exceed the equality target.
Figure 8.11 shows a Nifty zigzag pattern on the upside with clear subdivisions.
Wave A and wave C are impulse waves, and wave B is a corrective pattern. The
following are the important observations:
• Wave C moved beyond the upper trend line of the channel and prices reversed
back on the downside, thereby giving trapping bulls at the highs.
• The internals of wave A and wave C show an impulse move whereas wave B
formed a corrective pattern itself.
162 Elliott Wave Principles
• Wave B has retraced only 38.2% of wave A, and therefore, wave C has a ten-
dency to go beyond equality of wave A.
• A break below the 0–B trend line confirms that the upside zigzag pattern is
complete and a move in the opposite direction has started.
“x” waves. So, after the formation of the triple zigzag, the pattern has to complete
itself, and an opposite trend to the entire corrective pattern will emerge.
8.4.3 Triangle
A triangle correction usually results in sideways action without any strong trend in
either direction. A triangle pattern cannot form in wave 2 but is very commonly
seen in wave 4 formation. This pattern is labelled as A–B–C–D–E and has all cor-
rective sub-waves, which is 3–3–3–3–3. When we say three waves, it can take the
form of any corrective pattern. So each leg of the triangle is itself a corrective pat-
tern. This pattern if identified correctly can provide the pattern target which is the
width of its widest leg from the completion of wave E.
Figure 8.19 shows a regular triangle pattern in which wave a is the largest. The
upside move is halted by this triangle correction. The pattern target is derived by
measuring wave a and projecting it upside from the end of wave e. Normally, the
next leg will travel 100% to 125% of the widest leg of the triangle pattern. In the
preceding case, as wave a is the biggest, we can expect a target of 100% to 125%
of wave a. The b–d trend line is an important line, and a break above this confirms
that the triangle pattern is over and the original trend on the upside is resuming.
target is derived by projecting 100%to 125% of wave b on the upside from the end
of wave e. Normally, the target of the triangle is achieved before the vertex. A ver-
tex is the point where two converging trend lines will meet if extended.
Triangles can also form as a part of a complex corrective pattern which is dis-
cussed later.
On occasion, wave c forms the widest part of a triangle, which is known as an
irregular wave C triangle, shown in Figure 8.20b.
Triangles can also take the form of expansion instead of contraction, known as
expanding triangle pattern. In this instance, wave e is the biggest leg and wave a is
normally the smallest among all legs of triangle.
A triangle can drift on the upside or on the downside, giving the form of a run-
ning triangle. Wave e of a triangle can itself be a triangle as well.
Figure 8.21 shows a classical triangle pattern formed in ICICI Bank from the
top of 2008 until the low was formed in 2013. This shows multi-year triangle
pattern.
For investors, the best opportunity to enter the stock market was on the break
above 240 levels which was near the high of wave (D) and also (B)–(D) trend line
was broken.
Targets are derived by measuring the widest part of the triangle which is by
measuring wave (A) and projecting from the lows of wave (E).
172 Elliott Wave Principles
FIGURE 8.21 Triangle pattern (ICICI Bank weekly chart). Created with Amibroker
Elliott Wave Principles 173
Post completing wave G, there is a break on the upside above the trend line, thereby
confirming the completion of the entire Diametric pattern and the start of positive
retracement.
FIGURE 8.23 Bow-Tie Diametric pattern (Facebook daily chart). Created with Amibroker
Elliott Wave Principles 175
Alternation
Alternation is an important guideline and is a common occurrence between wave
2 and wave 4. There are different ways in which wave 2 and wave 4 will alternate
with each other. Ideally, it is best if wave 2 and wave 4 alternate in as many ways
as possible. The different ways of alternation are pattern, price, time, complexity,
and severity. For example, if wave 2 forms a zigzag pattern that retraces wave 1 to
the extent of 61.8% and consumes 10 days and wave 4 forms a triangle that retraces
wave 3 to the extent of 38.2%, taking 30 days, there are pattern, severity, and time
alternations present between wave 2 and wave 4.
Combination pattern
It is common to see wave X connecting different corrective patterns together.
Glenn Neely (1990) mentions that a slower reversal post completion of the last leg
of the corrective pattern will normally indicate the formation of wave x. It is best
understood by looking at the charts. Wave X itself can be any corrective pattern.
The 0–b trend line can be drawn by connecting the starting point of wave a and
ending point of wave b of a zigzag or a flat correction. If the 0–b trend line is bro-
ken in lesser time than wave c took to form or if the entirety of wave c is retraced
back in lesser time than it took to form, it will indicate that a complex correction
is probably under formation involving ‘x’ waves.
6,400
B
6,200
(X) 6,000
5,800
B
A 5,600
(X)
5,400
5,200
C A B 5,127.35
(W)
5,000
C
(Y) A 4,600
C
(Z)
Oct 2011 Apr Jul Oct 2012
Created with AmiBroker - advanced charting and technical analysis software. http:/www.amibroker.com
FIGURE 8.27 Triple zigzag pattern (Nifty daily chart). Created with Amibroker
In Figure 8.27, the Nifty has exhibited a very clear triple zigzag pattern. The
following are the important observations:
• The fall has been contained very well within the channel involving two “X” waves.
• The pattern is zigzag–X–zigzag–X–zigzag. It is labelled as (W)–(X)–(Y)–(X)–(Z).
• Waves A and C of the zigzag pattern exhibited an impulsive fall, showing five
waves decline.
• There can be a maximum of two “X” waves, and the completion of wave (Z)
indicates a strong positive reversal with a breakout above the channel resistance.
Elliott Wave Principles 179
Summary:
• Zigzag: a–b–c pattern that is composed of 5–3–5 sub-waves
• Regular Flat: a–b–c pattern that is composed of 3–3–5 sub-waves, with wave
b travelling nearly to the beginning of wave a
• Irregular Flat: a–b–c pattern that is composed of 3–3–5 sub-waves, with
wave b travelling beyond 100% of wave a and, on occasion, 138.2% of wave a
• Running Flat: a–b–c pattern that is composed of 3–3–5 sub-waves, with
wave b travelling beyond the beginning of wave a and wave c ending well
above the end point of wave a, resulting in a strong post-pattern implication
• Triangle: a–b–c–d–e pattern that is composed of 3–3–3–3–3. Regular and
irregular triangle patterns can be observed.
• Diametric (new pattern as per Glenn Neely): seven-legged correction
labelled as a–b–c–d–e–f–g and composed of 3–3–3–3–3–3–3 with two varia-
tions of Bow-Tie Diametric and Diamond-shaped Diametric pattern
• Double Three: a–b–c–x–a–b–c pattern that is composed of a mix (or rep-
etition) of any two aforementioned patterns (x wave is a link between two
patterns)
• Triple Three: a–b–c–x–a–b–c–x–a–b–c pattern that is composed of a mix (or
repetition) of any three of the aforementioned patterns (two x waves form a
link between three patterns)
8.5 Channelling
Channels are a very important aspect within technical analysis. It is crucial to apply
channels to a chart when doing the wave counts. It gives profound clarity on the
completion of a wave pattern if channels are drawn properly. In the case of an
impulse pattern, during its formation, the 0–2 trend line and a parallel to that from
end of wave 1 is important. Post that, once wave 4 formation is complete, then the
2–4 trend line is drawn by connecting end of wave 2 and end of wave 4. A parallel
to that is drawn from the end of wave 1 when wave 3 is extended. This channel will
then give the pattern target for the wave 5 formation. In the case of the first exten-
sion or the fifth extension impulse wave, connect the end points of wave 2 and
wave 4 as the lower trend line and connect the end points of wave 1 and wave 3.
In the case of zigzag and flat corrective patterns, a 0–b trend line can be drawn
by connecting the starting point of wave a and the end point of wave b. A parallel
to this trend line can be taken from the end point of wave a. For a triangle pattern,
the end point of wave b and the end point of wave d can be connected to draw a
b–d trend line and, on opposite side, an a–c trend line can be drawn, and in the case
of an irregular wave c triangle, a c–e trend line can be drawn.
Impulse pattern completion confirmation: Glenn Neely (1990) men-
tions that in order to obtain a confirmation that wave 5 of an impulse pattern is
complete, 2–4 trend line should be broken in a faster time than wave 5 took to
form. Neely called it as the first stage of confirmation that wave 5 is over and the
counter-trend is starting. The second stage of confirmation is obtained when the
180 Elliott Wave Principles
entire wave 5 is retraced back completely in a faster time than wave 5 took to form.
These two stages of confirmation will strongly indicate that the impulse pattern is
complete and the counter-trend move is starting. In the case that these two stages
of confirmation are not visible or even if only one stage of confirmation has hap-
pened without the second stage, it will open up a few probable scenarios – wave
5 is not over and is probably subdividing in the form of an ending diagonal pat-
tern, or wave 4 itself is still ongoing, so the 2–4 trend line needs to be revised and
redrawn post completion of wave 4.
Corrective pattern completion confirmation as per NEoWave logics:
Glenn Neely (1990) mentioned that for completion of a zigzag or a flat correction,
the 0–b trend line should be broken in a faster time than wave c took to form. It
will provide the first stage of confirmation that the ongoing corrective pattern is
complete. The second stage of confirmation is obtained when the entire wave c
is retraced back in a faster time than it took to form. By obtaining two stages of
confirmation, there is a very high probability that the ongoing corrective pattern
is complete and the prior trend is resuming. In the case of a triangle, the b–d trend
line should be broken in a faster time than wave e took to form, and the second
stage of confirmation is obtained by faster retracement of the entire wave e. This
will strongly confirm that the triangle pattern is complete.
In case the two stages of confirmation are not obtained in a corrective pattern,
there is a very high likelihood that a complex corrective pattern involving an x wave
is under formation and that the retracement was only wave x, which will connect
the two standard corrections together. The other possible scenario that also opens
is that wave c is not yet over, in the case of a zigzag or a flat, and wave e is not yet
over, in the case of a triangle, if prices fail to provide the two stages of confirmation.
For a trader, the two stages of confirmation can provide a lot of clarity for form-
ing a trade set-up plan.
In Figure 8.28, the weekly chart of Maruti, we can see the rise in the impulsive
pattern. Following are important observations:
• Post completion of wave 5 in the fifth failure pattern, prices broke below the
2–4 trend line which provided confirmation that the entire impulsive rise is
over and the corrective pattern is starting.
• A parallel line to that of the 2–4 trend line was drawn from the end of wave 1.
The rise in the form of wave 5 was truncated and came near to the upper trend
line of the channel.
• Wave 3 has a tendency to break the channel on the upside as it is the most
powerful and elongated move among the impulsive legs. This can be clearly
seen here.
In Figure 8.29, the DJIA, after forming a low in March 2009, showed a rise in
the form of an impulsive pattern. Following are the important observations:
• The rise is marked impulsive, and there have been clear subdivisions within
wave (3), which itself is largest and subdivided.
Elliott Wave Principles 181
MARUTI - Weekly 09/04/2020 Open 4150, Hi 5399, Lo 4120, Close 5326.65 (32.8%)
10,500
3 5 5th Failure pattern
v 10,000
iii 9,500
i
iv
9,000
ii
8,500
4 8,000
7,500
7,000
6,500
1
6,000
2 4,500
4,000
3,500
3,000
^DJI -Weekly 21-04-2019 Open 26407.8, Hi 26424.8, Lo 26316.4, Close 26384.8 (-0.1%) 19,000
3 18,543.5
18,000
17,000
16,000
4
15,000
14,000
1 13,000
12,000
(1)
11,000
2
10,000
(2)
9,000
8,000
7,000
FIGURE 8.29 Application of an Elliott Wave (DJIA weekly chart). Created with Amibroker
182 Elliott Wave Principles
• Prices completed wave 4 of (3) in January 2016 and started wave 5 on the
upside.
• There is a clear alternation seen between wave 2 and wave 4.
[W]e can label wave (4) as a double three. We have explained that all
the waves since January 2018 have been threes, thereby ruling out a flat
pattern into the December 2018 low. We can accommodate all these
three-wave structures only one way: by identifying the classic shape of a
double three comprising a zigzag-X-triangle. This is the only labelling
that breaks no rules, and it is the only way to account for a completed
bull market.
34,000
^DJI -Weekly 09/04/2020 Open 21693.6, Hi 24009, Lo 21693.6, Close 23719.4 (12.7%) 5 32,000
(5) 30,000
(3) X 28,000
5
26,000
Y
(4) 23,719.4
W double 22,000
three
20,000
3
18,000
16,000
4
14,000
1
(1) 12,000
loganithmic scale
2 10,000
(2)
zigzag
8,000
4 6,000
2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020
Created with AmiBroker - advanced charting and technical analysis software. http:/www.amibroker.com
On a long term basis, time and price are satisfied, and the current era’s finan-
cial optimism – in the stock market, the bond market and real estate – dwarfs
all previous such conditions in recorded history by a huge margin. Some
indicators reveal that optimism is greater than past extremes by multiples.
There is no financial fear now, but when it arrives it will be epic. So, let’s
reflect the general mood and say that we’re optimistically bearish.
The DJIA formed a top on 12 February 2020 at 29406 and crashed by 38% over
the next few weeks. The preceding showcases that Elliott Waves are predictive in
nature with such an uncanny forecasting capability.
8.6 Key takeaways
• R. N. Elliott discovered that prices of freely traded market move in a repeat-
able pattern.
• A wave, in its very simple terms, can be described as a movement of price from
one level to the next level without producing any significant retracement in
terms of price and/or time.
• An Elliott Wave can be categorized between impulse patterns and corrective
patterns.
• An Elliott Wave has five waves forward and three waves backward. Both five
and three are Fibonacci numbers.
• A normal impulse pattern has to follow three important rules across all degrees
of formation.
• Smaller-degree waves combine to form higher-degree waves.
• It is common to see one of the impulse waves be extended.
• A diagonal triangle is a variation of an impulse pattern that has the form of
a wedge pattern with the two converging trend lines moving either on the
upside or the downside.
• On a few occasions, wave 5 fails to move beyond the end of wave 3.
• A corrective pattern results in a move against the prior trend of one higher
degree.
• A zigzag correction is composed of 5–3–5 sub-waves.
• A flat correction is composed of 3–3–5 sub-waves.
• A triangle correction usually results in sideways action without any strong
trend in either direction. It has all sub-waves corrective which is 3–3–3–3–3.
• Glenn Neely, founder of NEoWave, discovered a pattern which is very com-
monly seen across the asset classes – a seven-legged corrective pattern known
as a Diametric.
• On occasion, standard corrective patterns will occur more than once, thereby
forming a complex corrective pattern.
184 Elliott Wave Principles
Notes
1 Prechter, R. (1990). The major works of R. N. Elliott (2nd ed., p. 3). Gainesville, GA: New
Classics Library.
2 Prechter, R., and Frost, A. (2005). Elliott wave principle (10th ed.). Gainesville, GA: New
Classics Library.
3 NEoWave™ (1995). Conference and Workshop
9
TIME CYCLES
Two forms of general economic change have long been accepted by most econ-
omists as systematic features of industrialized economies organized under capi-
talist institutions. One is persistent long-term growth; the other is the business
cycle.1
− Moses Abramovitz
9.1 Introduction
Technical analysis majorly considers charts patterns with reference to time. While
price and volume are studied majorly with reference to time, time as an independ-
ent variable of study can also yield valuable insights for trading decisions. The peri-
odic fluctuations impacting a price series is referred to as time cycles.
Consideration of time cycles is important because the cycle periodicity can
change, and so a trader has to keep tweaking the cycle length from time to time to
keep it up to the mark with the changing market dynamics. At the same instance,
a trade, if not timed correctly, can result in a non-desirous outcome, and it is
therefore important to combine the price forecasting tools along with time cycles
to understand the major turning junctures. There are recurring cycles in financial
markets and by identifying the cyclicality, one can forecast the possible tops or bot-
toms and accordingly take trading or investing positions.
The concept of time cycle has its roots in the Schumpeterian theory of business
cycles (Pring, 2014). Schumpeter’s business cycles, intertwined in his theory of
economic evolutions, are ‘pulsations of the rate of economic evolution’ (Kuznets,
1940). In the Schumpeterian theory, economic changes are driven by three groups
of forces: external factors, existing economic growth, and innovations which rep-
resent substantial changes in the production process. Innovations in this construct
are a key driver of the evolution of a capitalist economic system. Business cycles
186 Time cycles
represent repetitive fluctuations brought about by the rate at which innovations are
introduced into the economy. Schumpeter argues that there would be a ‘bunching
of innovations at one time and comparative scarcity at others’, leading to a recog-
nizable cyclical pattern in the economy (Kuznets, Ibid).
The infusion of innovations in the economy is accompanied by an expansion
of credit and the increase in prices and interest rates, which, however, soon reach
their culmination with the exhaustion of innovation opportunities. As the rate of
innovations fall, a period of readjustment ensues when credit contracts, price and
interest rates decline, but output averages are higher than the previous level from
where the expansion started. This is the Schumpeterian theory that forms the basis
of the first two-phase cycle, an expansion upwards from an equilibrium level and
the restriction to a new equilibrium level (Kuznets, 1940).
The revival from the depression rests on secondary factors in this model,
largely guided by the conditions under which entrepreneurial activity takes place
in reality, including the individual’s speculative tendencies, forecasting errors, and
peculiarities of economic organizations that define the intricacies of the adjust-
ment from recession to the new equilibrium, being thus conceivable for the cycle
of prosperity, recession, depression, and revival. While the turning point towards
recession is determined by the primary model, the revival point is determined
by secondary factors. Based on this model Schumpeter argues for consideration
of the entire four-phase cycle, the study of time series, so that cyclical units
are defined from the beginning of prosperity till the arrival of the new normal
(Kuznets, 1940).
The difference in the magnitude of innovations leads to the presence of several
primary and secondary factors, which, in turn, lead to time cycles of different
durations and intensities. Based on the historical patterns observed during the
19th and early 20th centuries, Schumpeter identified the long waves of about
50 years in duration (Kondratieffs); intermediate waves about 8 to 9 years in
duration (Juglars); and short waves of about 40 months in duration (Kitchins),
named after the economists who first identified these cycles. The coexistence
of the three major types of cycles was used by Schumpeter to explain why the
periods of depression from 1825 to 1830, 1873 to 1878, and 1929 to 1934, were
so ‘long and deep’ (Kuznets, 1940). The Schumpeterian model helps with appre-
ciating the interaction of shorter cycles with longer ones (Kuznets, 1940; Pring,
2014). Hurst (2000) points out that there are multiple cycles acting on the market
price, and it is important to isolate these multiple cycles into its individual com-
ponents. To understand the dominant cycles acting on the prices, it is important
to understand the basic principles of cycles.
9.2 Characteristic of cycles
The cycle bottoms are referred to as troughs and the tops are referred to as crest.
One complete cycle is movement from trough to trough. The important charac-
teristics of cycles are amplitude, period, and phase.
Time cycles 187
9.2.1 Period
A cycle is measured normally from the lows to the next low. The time taken by the
price to move from one low (trough) to the next low (trough) is known as a period
of the cycle. Each cycle will have its own periodicity.
9.2.2 Amplitude
The height of the cycle is referred to as amplitude. In the case of price action, it is
the distance travelled by prices from their long-term average or mean.
9.2.3 Phase
It measures the time elapsed after the trough of the cycle. A cycle that has a period
of 10 days and if 5 days has been elapsed, then it defines the phase as 5 days. An
ideal cycle tops out at the middle. So a 10-day cycle will have upside thrust in
the first half of the cycle period which is for 5 days. A peak is considered on the
fifth day, and then a downside thrust happens in the second half of the cycle. By
knowing the phase of the cycle, one can understand when the next low or trough
is going to be formed.
Figure 9.1 shows the amplitude, phase, and period of the cycles.
then it indicates that a 40-day cycle has topped out and that prices might be in
the second half of the 40-day cycle. So understanding whether the cycle is left- or
right-translated is important from trading or investing perspective.
9.4 Principles of cycles
9.4.1 Principle of summation
Hurst (2000) has identified that there are multiple cycles of different magnitude
acting on market prices. The value of the smaller cycle at that point of time is
summed with the value of one bigger cycle which is then summed to the value of
a longer cycle. This results in a composite cycle.
9.4.2 Principle of harmonicity
Cycles are related to one another by the factor of 2. Hurst defined that if there
is a cycle of 40 weeks, then there will be two smaller cycles of 20 weeks. These
20-week cycles will be composed of two 10-week cycles. Thus, cycles are harmo-
nious in nature and are mostly related by the factor of 2. There are exceptions in
the higher time-frame cycle of 54 months, which is composed of three 18-month
cycles. Similarly, a 54-year cycle is composed of three 18-year cycles.
9.4.3 Principle of synchronicity
As per this principle, cycle troughs are synchronous in nature. This means that
the troughs formed by bigger cycle will also be troughs of the harmonious smaller
cycles. Thus, by identifying a bigger-cycle low, one can safely assume that the lows
of the subsequent harmonics are also at the same time. So, if a 40-week cycle has
formed a low, then the 20-week and 10-week cycles’ lows will be synchronous,
forming lows at the same period. Tops are non-synchronous in nature, so the cycle
period is preferably measured between the troughs and not between the peaks or
the crest. This is the reason why tops are dispersed and bottoms are formed in
panic.
9.4.4 Principle of nominality
Hurst (2000) has described a specific set of cycles that can be identified in finan-
cial markets. These are called nominal cycles. The actual cycles that prices follow
will be in close approximation to the nominal cycle. Hurst cycle analysis makes
cycle identification easy through a scientific and systematic approach. Follow-
ing are the set of nominal cycles in terms of calendar days and trading days that
Christopher Grafton (2011) has mentioned in his book Mastering Hurst Cycle
Analysis:
Time cycles 189
Calendar days
Years – 54, 18, 9
Months – 54, 18, 9
Weeks – 80, 40, 20, 10
Days – 80, 40, 20, 10
Trading days – 56, 28, 14, 7
Hurst (2000) uses calendar cycles, but it is not easy to plot calendar cycles on a
charting platform. Calendar days can be converted to trading days for easy identifi-
cation and plotting. Weekly, monthly, and annual cycles do not require conversion
to trading days as one week/month/year will always be considered as one irrespec-
tive of the number of trading days.
9.4.5 Principle of variation
The actual cycles will be different from that of the nominal cycles. Even if the
actual cycle identified is of 55 days, it is not necessary that each cycle for that mar-
ket price will be exactly 55 days. Cycles will be of varying lengths, and the mean of
the cycle length is important. For example, on a Nifty chart, there can be a 55-day
cycle, followed by a 53-day cycle, followed by a 57-day cycle. This will result in a
mean actual cycle of 55 days.
9.4.6 Principle of proportionality
A cycle with a higher periodicity will have bigger amplitude. A 40-week cycle will
have twice the amplitude of a 20-week cycle. If a cycle amplitude falls short of the
expected value, it indicates that a bigger cycle has probably topped out.
9.4.7 Principle of commonality
The principle of cycles is applicable across the asset class and different markets for
the price history.
In Figure 9.2, three different cycles are shown. Following are the important
observations:
• Two small cycles, 1s, combine to form a bigger cycle, 2; two cycle 2s then
combine together to form cycle 3. This exhibits the principle of harmonicity.
• The troughs formed by bigger cycle are also the troughs formed by the har-
monious smaller cycles. This exhibits the principle of synchronicity.
• Cycle 3 has the biggest amplitude compared to cycle 2 and cycle 1. The
amplitude of cycle 2 is bigger than that of cycle 1. This exhibits the principle
of proportionality.
190 Time cycles
9.5.1 Observational analysis
There are different methods that can be used to isolate the cycles. By doing a visual
inspection, one can try to find if there is a rhythmic movement in prices and if
there are troughs that are formed at periodic intervals. Try to identify two or three
important lows that seem equidistant and then see if the next lows are also around
this period. Many charting software programs provide equidistant cycle lines that
can be used to plot the cycles using a trial-and-error method. Also note that there
can be higher lows or lower lows depending on the longer-term cycle. It is not
necessary that prices have to come to the same level of the prior cycle’s low.
In Figure 9.3, the periodic lows are marked along with the number of days taken
between each low. Per the nominal cycle model, there is a 56-day nominal cycle.
In the figure, we can observe rhythmic lows being formed near these cycle days.
Following are the important observations:
• The Nifty is forming lows anywhere between 51 days to 62 days. The average
of all the data points gives 55 days as the average trading cycle.
• Two 55-day trading cycle combine to form a bigger degree cycle. The aver-
age periodicity of the bigger cycle is 111 days (approximately 22 weeks). Two
22-week cycles combine to form a 44-week cycle.
• Principle of harmonicity – two shorter-period cycles combine to form a big-
ger-degree cycle with an average period of 111 days.
• Principle of variation – the cycle can deviate from its mean periodicity, and
therefore, cycles of varying length around that mean value can be seen.
Time cycles 191
• Principle of nominality – the nominal cycle of 56 days and the actual cycle are
in near approximation to the observed 55 days.
• Lows formed on the cycle day can be above the prior lows as seen in points a,
b, and c and lower lows seen in points d and e.
• Cycles between a and b and between b and c are right-translated; that is the
tops are formed on the second half of the cycle. Cycles between c and d and
between d and e are left-translated. A left translation indicates that a bigger
cycle has topped out. As the 44-week cycle that determines the larger trend
has topped out in the middle, we can see the smaller cycles on the second half
of the 44-week cycle are left-translated. So translation gives a very important
indication of the larger trend.
Figure 9.4 shows cyclicality in the DJIA. There are important lows that are
occurring at the time distance of 170 weeks which can also be considered as
approximately 39 months. Note here that the nominal cycles in terms of months
are 9 months, 18 months, and 54 months. It seems that the DJIA is following
the cycle by a factor of 2, not 3. Therefore, twice the cycle length of 18 months
gives a 36-month nominal cycle. The actual cycle of 39 months, or 170 weeks,
192 Time cycles
FIGURE 9.5 Cyclicality with momentum indicator (DJIA weekly chart). Created with
Amibroker
9.5.4 Envelopes
Hurst (2000) used envelopes to confirm the observational analysis and see if there
is an objective way to identify the existence of the same. For doing this, it is best
to plot the centred moving average, which is half the length of the cycle that has
to be validated, and plot the percentage band above and below this centred moving
average. In Figure 9.7,
• a 78-week cycle is analysed using the observational method which is also close
to the 80-week nominal cycle.
• the centred moving average of half the period of the cycle is plotted. The
39-week centred moving average is shifted back by 20 weeks to identify the
78-week cycle.
• The 20% bands above and below this centred moving average give a good
indication of the cyclicality.
• prices tend to touch the lower end of the band and reverse from there which
are placed at an average distance of 78 weeks.
• an inversion is seen in early 2015 where a top is formed instead of a low, which
indicated that a cycle of bigger length has topped out, resulting in an inversion.
Time cycles 195
FIGURE 9.7 39-week centred moving average with 20% envelope (Alcoa weekly chart).
Created with Amibroker
Following are the important observations based on Figure 9.8 of the Nifty:
• Observational analysis on the Nifty shown earlier in Figure 9.8 suggested that
the Nifty is following average cycles of 55 days and 111 days, which is in sync
with the principle of harmonicity. By using the detrended method, a valida-
tion of the bigger-degree cycle is done in Figure 9.8.
• The centred moving average of 55 days is plotted, which is shifted back by 28
days along with a 4% band. This results in an envelope that shows the majority
of the lows being formed on the lower band except for 22 May 2018 and early
April 2019.
• The low formed in early April 2019 is far away from the lower end of the
band, suggesting that a bigger-degree cycle is up and the price low near 11550
should remain protected for weeks ahead. A break below this low level will
indicate that the cycle formed an inversion that is a top instead of a low and
will be a bearish sign.
• The price divided by the centred moving average of 55 days is plotted below
the prices in the form of an oscillator. This further validates the observational
analysis that a 109-day cycle is more accurate and that the lows of the oscillator
are following equal periodicity.
• From a trading perspective, this indicates a positive bias as long as 11550 levels
remain intact, which is the cycle low of April 2019.
196 Time cycles
FIGURE 9.8 109-day time cycle with a 55-day envelope and detrended oscillator (Nifty
daily chart). Created with Amibroker
FIGURE 9.9
86-week time cycle and an Elliott Wave pattern (USD/INR weekly
chart). Created with Amibroker
• Time cycles can also help in identifying Elliott Wave pattern under progress
earlier on since we can identify the areas of probable lows on the chart.
In Figure 9.10 of Berger Paints, there is a clear impulsive rise. The following are
the important observations:
FIGURE 9.10 164-week time cycle and Elliott Wave pattern (Berger Paints weekly chart).
Created with Amibroker
• As time cycle of 164 weeks formed a low near wave IV, there is a possibility
that the low near 232 will remain protected until the cycle enters the topping
zone.
In a weekly chart of USDINR (Figure 9.11), the following are the important
observations:
• USD/INR showed a very strong move from the lows of 39 to the high of 52
in 2008. The rise is marked as wave A. Post completion of wave A, the cor-
rection retraced the prior rise by exactly 61.8% in the form of wave B.
• Wave B looked to have formed complex corrective Elliott Wave pattern.
• There were multiple attempts near the level of 43.85, but a 61.8% Fibonacci
retracement level acted as a strong support, and USDINR did not break that
level.
• Prices formed resistance near the 38.2% level and support at the 61.8% level
for many weeks.
• From April 2010 to July 2011, there was a clear loss of momentum as can be
seen by the series of positive divergence exhibited on the RSI and the MACD
indicator.
Time cycles 199
FIGURE 9.11 Timecycles and Elliott Waves (USD/INR weekly chart). Created with
Amibroker
• As per the basic pattern analysis, it also formed a descending triangle pattern
during the same period.
• Bollinger Bands showed contraction during the period from 2010 to July 2011.
• Time cycles of 75 weeks also worked very well and can be identified using the
simple observational method. This 75-week cycle is also in close approxima-
tion to the standard 80-week cycle identified by Hurst.
• In early August 2011, there was a strong thrust on the upside that broke above
the level of 46. This resulted in a break above the upper trend line of the
orthodox triangle pattern.
• The break on the upside was also supported by expansion seen in Bollinger
Bands which further confirmed that after a non-trending move, a trending
move is probably about to start.
• The MACD line during the same period of early August 2011 moved above
the 0 level and crossed above the signal line, thereby providing a secondary
confirmation to the buy signal obtained by pattern breakout and reversal from
the 61.8% Fibonacci support level.
• The subsequent lows formed in the later phase of wave B’s formation were
near the level formed during the time-cycle low.
• There is a cluster of evidence that suggested that USDINR should start a
strong up move in early August 2011. The following methods provided a
200 Time cycles
In Figure 9.12, the Nifty daily chart shows a combination of various technical
analysis methods that can be combined to provide a high-conviction trade set-up.
The following are the important observations:
• The Nifty, during the period from March 2015 till February 2016, moved
precisely within the downward-sloping channel. The upper trend line of the
channel acted as strong resistance, and the lower trend line of the channel pro-
vided support to prices.
• The time-cycle average of 55 days showed that prices formed a low near this
cycle and reversed back on the upside. Per the Hurst standard, the cycle is 56
trading days, and the actual cycle of 55 days followed on the Nifty is in close
approximation to this standard cycle.
• An EMA of 70 days is selected as it acted as resistance on most of the occasions
and as support on a few occasions during the downtrend. Another EMA of 20
days is selected, which moves with the smaller swings, providing resistance or
support to prices.
• The ROC parameter is selected which is half to that of the cycle. So the ROC
parameter of 27 is taken which exhibits the probable 55-day cycle as the ROC
forms lows near the cycle dates.
• The entire fall since the March 2015 top near 9119 till the low at 6985 formed
in February 2016 exhibited a complex corrective pattern involving “X” waves.
Time cycles 201
FIGURE 9.12 Time cycles and Elliott Waves (Nifty daily chart). Created with Amibroker
of the entire fall and if that level is taken out then prices may travel towards
100% of the fall.
• It can be seen that prices indeed break above the channel and moved towards
61.8% retracement level.
• A trader had multiple positive confirmations on 1 March 2016 when the Nifty
closed near 7222 levels.
• Later prices moved above both the shorter and longer moving averages, and
there was a positive crossover between the averages as well.
• The MACD indicator also generated a buy signal in the first week of
March 2016 when MACD line moved above the signal line and later above
the 0 level.
• Thus, the Elliott Wave method, along with time cycles, helped in forecasting
the completion of trend, and indicators like the ROC, the MACD, and mov-
ing averages provided secondary confirmation. The channel and the trend line
continue to play a vital role in identifying the reversal areas. This shows how
forecasting methods like Elliott Waves and time cycles can be combined with
indicators and candlestick patterns.
9.7 Key takeaways
1 A trade, if not timed correctly, can result in a non-desirous outcome, and it is
therefore important to combine the price-forecasting tools with time cycles to
understand the major turning junctures.
2 One complete cycle is movement from trough to trough.
3 The important characteristics of cycles are amplitude, period, and phase.
4 If the peak is formed during the first half of the cycle, it is known being as
left-translated, and if the peak is formed in the second half, then the cycle is
called right-translated.
5 Cycles follow principles of summation, harmonicity, synchronicity, nominal-
ity, variation, proportionality, and commonality.
6 Cycle detection can be done by observational analysis, detrending the prices,
and envelopes.
7 Cycles are one of the important principles based from which the momentum
indicator values can be derived.
8 Combining time cycles with Elliott Waves provides a strong forecasting ability.
Note
1 Abramovitz, Moses. (1961, April 30). The nature and significance of Kuznets cycles. Eco-
nomic Development and Cultural Change, 9(3), 225–248, Essays in the Quantitative Study
of Economic Growth, Presented to Simon Kuznets on the Occasion of His Sixtieth
Birthday, by His Students and Friends. Retrieved May 6, 2020, from www.jstor.org/
stable/1151797, p. 1.
10
INTRODUCTION TO BACKTESTING
AND ALGORITHMIC TRADING
When mindless algorithms are able to teach, diagnose and design better than
humans, what will we do?
– Yuval Noah Harari1
10.1 Introduction
The generation of trading signals and execution of orders based on a set of pre-
defined instructions to the computing system is referred to as algorithmic trading.
Algorithmic trading refers to the automation of the trading process, whereby the
generation of buy or sell signals and the execution of such signals as trades happens
on the basis of programmed instructions or algorithms. This chapter takes up the
backtesting of technical analysis strategies and its use in algorithmic trading. We
will use two of the most common tools used by algorithmic traders: Microsoft
Excel and Python.
While there are a plethora of resources available online on algorithmic trading, a
conceptual clarity of algorithmic trading remains a fuzzy area. Algorithmic trading
is simply the automation of a trading strategy. As traders, we know too well how
greed and fear impact our trades. We have a winning strategy, but we are too afraid
to stick to it or, lured by seemingly favourable markets, do not implement the exit.
While we know it is crucial to be disciplined traders, we are driven by emotions
in the market. If we could have our own trading robot to trade strictly on the basis
of a particular strategy and test if the strategy is followed, how would we fare in
the market? All this is possible with an algorithmic trading system. Algorithmic
trading is therefore simply a set of instructions given to the computing system on
the trading strategy which generates and executes the trading signals automatically.
Algorithmic trading may be based on either fundamental or technical analysis or
both. In this chapter, we focus on the trading algorithms based on technical analy-
sis, given the purview of the book.
204 Backtesting and algorithmic trading
• Formation of the pseudo code: For any trading strategy the formation of
pseudo code or an ‘informal high level description of the operating principal
of a computer program or algorithm’ (Pruitt, 2016, p. 5) is essential. The
pseudo code basically transforms the strategy from the language-based descrip-
tion to a structure which can be coded for the computer to understand. For
example, one of the most basic of technical trading strategies is the double
crossover technique, explained in Chapter 5. This strategy says an uptrend is
denoted by the shorter-run EMA, µ1 , crossing the longer-run EMA, µ2 , from
below, and a downtrend will be indicated by the shorter-run EMA, µ1 , cross-
ing the longer-run EMA, µ2 , from above. In this case, the pseudo code can be
written as follows:
1 2
EMAt∝ > EMAt∝ + 1(Long ) (1a)
Backtesting and algorithmic trading 205
1 2
EMAt∝ < EMAt∝ − 1(Short ) (1b)
• Backtesting the strategy: Once we have the pseudo code for the strategy,
one of the most essential steps in algorithmic trading comes in backtesting our
strategies. Backtesting is the process of applying your strategy on historical data
to evaluate its performance. It is useful to remember one thing here which suave
algorithmic traders know: backtesting a strategy tells us, historically, how that
strategy would have performed but is by no means an indicator of its future
performance (Link, 2003; Chan, 2009). This point cannot be over-emphasized
as a strategy with a stellar performance on all time frames can still end up as a
losing trade in the future. However, backtesting gives traders the confidence to
put in the trades and weeds out strategies which have the least chances of making
money. It also allows you to have a fair idea of which strategies would have per-
formed well in past if you have several competing strategies to choose from. Let
us suppose you have two or more strategies based on the RSI indicator discussed
in Chapter 6. Backtesting these will help you identify the ones to trade on and
code your algorithm. Moreover, you can optimize the parameters of the strategy.
• Choice of software for backtesting: Before embarking on the process of
backtesting, you need to select your tool for backtesting and coding algorithms
as well as the data source for both. While there are several options available
today to the trader for backtesting, we focus on two which rank high in terms
of utility and simplicity: Excel and Python:
a Excel is a highly adaptable and powerful backtesting platform as we will
see later in this chapter. The utility of Excel comes from its ability to
‘show’ our mistakes. MS Excel allows us to immediately identify the mis-
takes in any of our code in Excel given that ‘what you see is what you
get’ or WYSIWYG (Chan, 2009). Excel also enables the combination
of backtesting and live trade signal generation. Drawbacks of working
with Excel include the inability to handle large amounts of data and the
slowing down of spreadsheets when connected to live data access for an
automated trading process.
b Python, developed under an OSI (Open Systems Interconnection)–
approved open-source licence, is a powerful tool for backtesting of strat-
egies. The problems of handling large data sets and complex trading
strategies in MS Excel are addressed easily in Python. In fact, the potential
applications of Python of financial analysis are immense.
• Choice of database
The choice of the database to access live and historical data is very crucial. For
historical data, free databases available include Yahoo! Finance (https://in.finance.
yahoo.com/), Google Finance (www.google.com/finance), and stock exchange
websites like the NSE (www.nseindia.com/products/content/equities/indices/
historical_index_data.htm) the BSE (www.bseindia.com/market_data.html).
206 Backtesting and algorithmic trading
Databases like Thomson Reuters Eikon, used in some examples of this book,
have to be subscribed to and are comprehensive in nature.
• Live signal generation and building the automated trading system
The final part comes after we have backtested the strategy and want to set
up an automated trading system. The automated system will access the live
data from the database you prefer, generates trade signals according to the
coded algorithm, and finally submit the orders to a broker for execution. The
automated trading system should enable you to connect to a broker using
application programming interface (API) key. In the case of a fully automated
system, the trades are generated in a loop without any human intervention.
Chan (2009) points out that with high-frequency trading, a fully automated
system is essential as any human intervention will lag the system and com-
promise its performance. A semi-automated system means that trading signals
are generated, but those are not automatically executed, and you have human
intervention in choosing the trades to execute. In this chapter, we stick to
the first part of the semi-automated system, namely backtesting the trading
strategies and generation of signals.
• Avoiding look-ahead bias and data-snooping bias
The two most common problems in backtesting are look-ahead and data-
snooping bias (Chan, 2009). Look- ahead bias comes from incorporating in
the present period any information not already available. For example, if clos-
ing prices are used to calculate moving averages, signals generated by the dou-
ble crossover method in any period are based on the closing prices of the same
period. The signal generated by the double crossover strategy would necessar-
ily be available after the end of the period. Transactions on the signal therefore
can happen only after the current period is over, that is in the next period.
For calculating the transaction prices then, taking the close price of the same
period would lead to ‘look-ahead’ bias. Instead, the next period’s open or aver-
age should be taken. Look-ahead bias can also come from poor time-stamping
of data so that the actual real-world delays associated with data receiving and
its analysis are overlooked (Tulchinsky, 2019).
• Data-snooping bias is ‘finding pattern[s] in the data that do not exist’ (Lo 1994,
p. 60). In backtesting, it comes from the over-optimization of the parameters
of a model so that performance of a trading strategy looks better than it actu-
ally is (Chan, 2009). As there are numerous decision points in backtesting, it is
fairly common that as we try to optimize a trading strategy, data-snooping bias
creeps in. One of the most commonly used methods to address data-snooping
bias is to have sufficient sample size given the number of free parameters you
want to optimize. Chan (2009), based on his experience, suggested that the
number of data points must be 252 times the number of free parameters. In
scenarios where controlled experiments are not possible and a limited amount
of independent data is available, data-snooping bias can lead to serious difficul-
ties (Lo, 1994; Chan, 2009).
Backtesting and algorithmic trading 207
10.3.2.2 Mathematical functions
The mathematical functions that we will mostly need for backtesting are as follows:
A B C D E
10.3.2.3 Logical functions
One of the most powerful tools in Excel is the logical function which makes Excel
suitable for specification of criteria for backtesting. An important point to note is
that while using logical functions, the specifications given to the Excel must be
unambiguous. All the components of any logical function must be understood
correctly before coding the trading strategy.
The most common logical functions are as follow:
IF function
The IF function is given as = IF (logical test, value if true, value if false)
In the preceding example, we can now structure an IF function to know to
which country the exports in a month were higher, country A or country B, or
if exports to both countries were the same. The IF function would be formulated
as = IF (B2>A2, “Country A”, IF (A2>B2, “COUNTRY B”, “Both”)). In this case,
we have an additional IF function built into the primary IF function, a nested IF
condition so that all three the conditions can be checked simultaneously. A nested
IF function can be used anytime more than two conditions are possible.
either of the two countries is above the previous month’s exports. In this case, if
any of the previously mentioned three conditions are satisfied, the OR condition
holds. In this case, the OR function would be given as
A B C D E
up, they will cross the moving average after a lag, signifying a crossover towards an
uptrend. Thus, when the price goes above the moving average, we go long, and
when the price goes below the moving average, we go short.
If we have two moving averages, the shorter-period average follows the mar-
ket closely while the longer-period is the smoother indicator. Thus, when the
trend changes, the shorter-period average (following market action closely) will
turn earlier than the longer-period average. This means that the shorter-period
average will cross the delayed longer-period average from above, signifying a
downtrend.
In the example given here, we use 5-, 10-, and 20-period EMAs for the gen-
eration of signals. As the calculation of EMA requires the SMA, at the outset, the
SMA columns are created. Table 10.3 shows the calculation of a 5-period SMA,
SMA5 (in column G) and EMA5 (in column H). Column F shows the average of
open, high, low, and close. (Colum F). For the fifth observation, SMA = EMA.
Thereafter, the EMA of t-th period is calculated using the formula
where weight equals 2/(n + 1) and n is the number of observations, here 5. Given
that the B column has close prices, we therefore have EMA7= =B7*(2/6) +H6*(1–
2/6). Similarly, EMA10 and EMA20 can be calculated.
Column M calculates log returns as Log (Pt/Pt − 1). In Excel, Log returns =LN
(B3/B2), where column B gives closing prices.
The file ‘Ch_10_2’ gives the calculation of average prices (column F); SMA
5, 10, 20 (columns G, I, and K, respectively); EMA 5, 10, 20 (columns H, J, and
L, respectively), and Log Returns (column M). Please note the 5-period SMA
and EMA will start in the sixth row in the Excel sheet. Similarly, the 10-period
SMA and EMA start in the 11th row while 20-period moving averages start in
the 21st row.
F G H
2 =AVERAGE(B2:C2)
3 =AVERAGE(B3:C3)
4 =AVERAGE(B4:C4)
5 =AVERAGE(B5:C5)
6 =AVERAGE(B6:C6) =AVERAGE(B2:B6) =G6
7 =AVERAGE(B7:C7) =AVERAGE(B3:B7) =B7*(2/6)+H6*(1-2/6)
Where column B gives close prices and C gives open prices
Source: Author
212 Backtesting and algorithmic trading
The coding of this crossover strategy entails that if the price is greater than the
EMA, a buy decision is made, and if the price is smaller than the EMA a sell
decision is made. As can be seen in Excel file ‘Ch_10_2’, the Excel code in
this case would be =IF (C20>L19, 1,-1), where the open price is recorded in
column C, 1 represents a long or ‘buy’ position, and –1 indicates a short or ‘sell’
position.
Sell when
Let us code the crossover between 10- and 20-period EMA in row 22 of Excel
sheet ‘Ch10_2’ (Double Cross Signal 2) and Table 10.4.
The formula in Excel for generating a signal in row 22 is as follows:
IF (AND(J21<L21,J22>L22), “buy”, IF(AND(J21>L21,J22<L22), “sell”,“”)),
where EMA 10 and EMA 20 are measured in columns J and L, respectively.
The crossover between EMA 5 and EMA 10 (Double Cross Signal 1) will be
coded as
IF (AND(H21<J21,H22>J22), “buy”, IF(AND(H21>J21,H22<J22), “sell”, “”)),
where EMA 5 and EMA 10 are measured in columns H and J, respectively.
TABLE 10.4 EMA 10, 20, and the double crossover signal*
J L Q R
Return calculation
In this example, we calculate returns assuming a buy position is held till the next
sell signal, and the position is short till the next buy signal. In other words, a trader
will remain long on a strategy till he gets an opportunity to sell, and similarly, he
will remain short till he gets an opportunity to buy back the security.
For buy decision,
TPt
Rt = 1 − (5a)
TPt −1
And for sell decision,
TPt
Rt = − 1 (5b)
TPt −1
This is shown in Table 10.5.
The performance metrics for the two strategies are shown in Table 10.6.
R S
TRANSP1 RETURNS 2
10.3.3.2 RSI strategy
The RSI indicator forms the basis of the next two strategies. The RSI, like any
other momentum indicator, gives the strength of the trend in the market. This may
be contrasted to moving average indicators which give the direction of the trend in
the market. The RSI is given by
100
RSI a 100 , (6)
1 RS
where RS equals up closes/down closes over a period of α periods. Using standard
market convention, we take α = 14 periods.
If prices in a said period are greater than the last period, an up close is marked,
and if the price in a said period is lower than the last period, a down close is marked.
If the RS is equal to 1, that is up closes are exactly equal to the down closes, suggest-
ing the lack of a definite trend, the RSI will take the value of 50. The midpoint line
for this indicator is therefore given by 50. If up closes are more than down closes, the
RS will be more than 1, and therefore, the RSI will have a value more than 50. An
RSI value above 50 suggests an upward trend and therefore a buy signal. Similarly, if
the RSI goes below 50, it suggests a downward trend and a sell signal.
As discussed in Chapter 6, the RS will show higher values if there are more up
closes than down closes. The greater the value of the RS, the smaller is the second
term on the right-hand side of the equation 6 and the higher the value for the RSI.
Commonly, values over 70 for the RSI are interpreted as an overbought condition
in the market, implying that markets are overheated. You may note that for an RSI
to be above 70, the up closes must be at least 2.33 times the down closes, and simi-
larly, the RSI will below 30 if down closes are 2.33 times the up closes. The market
moving up by more than twice the downward moves suggests undoubtedly an
unsustainable momentum or overbought regions. Similarly, as RS falls in value, the
RSI also reflects the same. Values of RSI below 30 are represented as oversold con-
ditions in the market. The market moving down by more than twice the upward
moves suggests an oversold region. The RSI calculation is shown in Table 10.7.
In this backtesting example, we use a trading strategy based on the Relative
Strength Index to introduce some more performance metrics (Excel file ‘Ch10_3’).
In this case, we define ‘take-profit’ and ‘stop-loss’ levels using the ATR. As earlier,
the first six columns give the date and price variable (close, open, high, and low).
In the next seven columns (Table 10.7), we calculate the RSI. In column G, we
216
B G H I J K L M
N T
19 =IF(AND(M18<50,M19>50),1,0) =IF(N18<>0,F19,T18)
20 =IF(AND(M19<50,M20>50),1,0) =IF(N19<>0,F20,T19)
21 =IF(AND(M20<50,M21>50),1,0) =IF(N20<>0,F21,T20)
22 =IF(AND(M21<50,M22>50),1,0) =IF(N21<>0,F22,T21)
Source: Author.
* Column M shows the RSI.
218 Backtesting and algorithmic trading
O P Q R S
period), then we take the average price of that period as the transaction price or
continue with the previous transaction price as shown in column T of Table 10.8.
Now we can calculate the take-profit and stop-loss levels using the ATR values.
ATR, being an excellent indicator of range or volatility of the market, can be effec-
tive in setting stop-loss and take-profits levels (Kaufman, 2013). However, before
doing this we need to decide on our optimum risk-to-reward ratio which will
determine the potential gains and losses for us. The reward–risk ratio is one of the
most important things which a trader must consider. It helps in the preservation of
capital. The take-profit or stop-loss factor is used in keeping with the reward-to-
risk ratio we want (Chan, 2010).
Assuming a reward-to-risk ratio of 3, we can take-profit factor and stop-loss fac-
tor to be 6 and 2, respectively. The take-profit level is obtained by adding ATR * 6
to the entry price, and stop-loss level is obtained by subtracting the ATR * 2 from
the entry price. The Excel formula for the same is shown in Table 10.10. We
use the IF function to see if there has been a trade signal in the previous period
(Table 10.10).
Now we come to column W of Excel sheet ‘Ch10_3’ for the calculation of trade
running. We want to see if the trade, taken on the basis of a certain trading signal,
is to be continued or not. The trade-running code in Excel uses a nested IF func-
tion, with the logic that if there is a trade earlier and the high of the period does
not cross the take-profit level or the low does not fall below the stop-loss level,
we keep the trade running. We now generate a signal for take-profit and stop-loss
levels being reached as shown in Table 10.11. We use the open price of the day to
decide on whether the take-profit level or the stop-loss level is hit. In this case, we
compare the open price of this period (here, day) with the take-profit level and
stop-loss level in the previous period. As the take-profit and stop-loss levels are
generated only by the end of the day, the price in the next period can be used for
signal generation in this case.
We next calculate the exit price for the trade, based on whether take-profit or
stop-loss level was hit and, thereafter, calculate the profit or loss from that particu-
lar trade (Table 10.12). The trading strategy may now be evaluated based on the
Backtesting and algorithmic trading 219
T U V
TABLE 10.11 Calculation of trade running, profit-target hit, and stop-loss hit*
W X Y
Z AA
19 =IF(Y19<>0,E19,IF(X19<>0,D =IF(OR(Y19<>0,X19<>0),
19,T18)) Z19/Z18-1,0)
20 =IF(Y20<>0,E20,IF(X20<>0,D =IF(OR(Y20<>0,X20<>0),
20,T19)) Z20/Z19-1,0)
Source: Author.
* Where column D gives the high, column E gives the low, column T gives the entry price, column X
gives the profit-target hit, and column Y gives the stop-loss hit.
220 Backtesting and algorithmic trading
metrics like total gross wins, total gross losses, the profit factor, number of winning
and losing trades, and percentage of profitable trades as shown in Table 10.13.
We have till now backtested the long strategy only for simplicity. In reality, the
long and short strategies will both be tested and evaluated. In this case, using RSI
values, we go short in the case of the RSI falling below 50. Accordingly, the take-
profit and stop-loss (SL) levels as also the signals for take-profit hit and stop-loss hit
are calculated as shown in ‘Ch10_3’ (Excel link).
As shown in the Excel file, the metrics for both the long and short trades can
now be calculated (Table 10.14).
You will remember that initially, we have assigned a factor of 2% to the stop
loss and 6% to the take profit. We can now change these levels and analyse how it
impacts the gains and losses from our strategy. Using the scenario manager (avail-
able under Tab Data) in Excel, we can change the risk–reward ratio and evaluate
how our strategy would have performed.
The algorithmic trading system can now be built based on the backtesting
results. If we are satisfied with the performance of the strategy, we would like to
create an automated trading system. In Excel, this can be done by linking the Excel
file with a database. The chosen strategy is coded and a link established to the data
source. This will lead to the generation of automatic signals during trading hours.
Figure 10.1 shows the access of data from the Thomson Reuters Eikon database.
Y Z
The Excel sheet would now be connected to live data. As data are imported
into the system automatically, live signals will be generated based on the trading
strategy coded in Excel.
As new data come at every time frame, the Excel sheet will generate the trading
signals automatically. More complex backtesting strategies are coded and given in
the Excel file eResource for this chapter. Strategies on the Heiken Ashi Stochastic,
discussed in Chapter 6, are provided in the Excel sheet ‘Ch10_4’ in the eResource.
10.4 Introduction to Python
Python is developed under an OSI-approved open-source license. Open-source
software is software that can be freely accessed, used, changed, and shared (in a
modified or unmodified form) by anyone. Importantly, all open-source software
can be used for commercial purpose as well, and the open-source definition guar-
antees this.3 Python’s license is administered by the Python Software Foundation.
While many integrated development environments (IDEs)4 can be used for Python,
we recommend the Jupyter Note Book from open-source Anaconda distribution.
Anaconda distribution is flexible in terms of managing libraries and environments
and works with Linux, Windows, and Mac OS X. It provides IDEs and downloads
other important libraries needed for backtesting like numpy, pandas, and matplotlib
at one go. Python uses object-oriented programming, which is a problem-solving
approach with computation done by using objects, as opposed to procedural pro-
gramming, which uses a list of instructions to do computation step by step.
Downloading Anaconda: For downloading the resources from Anaconda, go to
www.anaconda.com/distribution/.
This will take you through steps similar to the flow in Figure 10.2.
For the purpose of this book, we will be using Python 3, and hence, it is recom-
mended that you download the Python 3 version. As shown in Figure 10.2, from
the site download Python 3.7 and follow the step-by-step instructions to install.
Run Anaconda Navigator from the Programmes list on the Start menu to get a
Home page and launch Jupyter. Now Jupyter dashboard will open in a browser.
The Jupyter dashboard will have options to Open New File, Close, or Rename
the file.
The notebook files used in this book can be found in the eResource ‘Ch10 Note-
books’. Download the zip file, unzip it, and extract the files: extension .ipynb (Python
Notebook). The files should be now accessible from the Jupyter Home tab in the
respective folder. For example, if you have extracted them in Desktop ‘New files’, from
222 Backtesting and algorithmic trading
the Home tab you can click on Desktop and then ‘New files’ to access the notebooks.
The notebook contains cells which, again, have input fields. When inputting com-
mands in Python, the edit mode at the top right is activated. After entering the input,
press Shift + Enter to get the output. Each time a new command is executed, a new cell
is created. The tabs in the Jupyter notebook have multiple options and functions, and
it is recommended that you get familiar with the notebook before proceeding further.
If you have no background in Python, we recommend going through the basics
of using Python for financial analysis from Hilpisch (2018). However, the basics of
Python required for the backtesting are covered in this chapter before we move on.
10.4.1 Basics in Python
Let us look at the basic syntax in Python. In the eResources, the file for this section
is named ‘Ch10_NB1’.
Putting Comments: To put comments in Python, start with a hash, #, and write
down the comment. It will not be treated as an input. Comments are helpful for
making notes and observation about any code we write in Python. Python is a
dynamically written language, unlike others, like C, which are static.
• Print: In Python 3, the print command is always given within the parentheses.
For example,
[In]: print (‘Hello World’)
[Out]: Hello World
[In]: x=90
x
[Out]: 90
[In]: x=1
x
[Out]: 1
Backtesting and algorithmic trading 223
Indexing of elements
Python follows a zero-based numbering scheme (Hilpisch, 2018). Indexing allows
us to extract one item from among many in either a variable or a defined set. For
example, if I wanted to extract the letter P from the word Python, I would write
[In]: x= “Python”
[In]: x[0]
[Out]: P
[In]: x[6]
[Out]: n
The square brackets are used in this case and the count is from zero, not 1.
Indexing can also be done from the last letter, taken as -1.
[In]: x= “Python”
[In]: x[-1]
[Out]: n
[In]: x[-6]
[Out]: P
Variable type
The variable types in Python include numbers, Booleans, and strings. The groups
in which we can put variables are lists, dictionaries, and tuples, described later.
The notebook Pythonbasics shows arithmetic operations as well as data types in
Python. Numbers may be int (integer) or float (real numbers) format or strings
(text values). Booleans values represent True or False values. Strings are text val-
ues with a sequence of characters. The command for knowing the type of vari-
able is type().
+ Addition 6+3 9
– Subtraction 6–3 3
* Multiplication 6*3 18
/ Division 6/3 2
// Integer division (shows quotient) 7/3 2
% Modulus (shows remainder) 7/3 1
** Exponent 7**3 343
Source: Author.
224 Backtesting and algorithmic trading
[In]: 5 != 7
[Out]: True
Logical operators
Logical operators (And, or, not) are Boolean operators and check whether a certain
condition or conditions are satisfied. ‘And’ checks if both conditions are satisfied,
and ‘Or’ checks if one of the conditions are satisfied. ‘Not’ leads to the opposite
of the given statement. The order of precedence is ‘Not’, ‘And’, and ‘Or’. For
example,
For the preceding input to be executed, we must first consider ‘Not’. ‘Not
True’= False, so the statement becomes False or False and True. Next, ‘And’ will be
considered and ‘False and True’= False as both conditions cannot hold true. Now
we have ‘False or False’ which yields False as any condition is satisfied. The order
of importance of these three operators is that ‘Not’ comes first; then, we have ‘and’
and then ‘or’.
once declared. Tuples are written in parentheses, lists are put in square brackets, and
dictionaries in curly brackets.
Objects of type lists are very powerful, and being mutable, we can append,
extend, or remove items from the list easily. This makes them very suitable for
financial analysis, say like creating a set of stocks for a portfolio or set of price
quotes. The following example shows defining a list, appending to it, and creat-
ing a list which includes another list. Finally, using the indexing, we can retrieve
particular elements from the list.
function body
The function then must be called as shown in the following examples. In example
2, the return command can also be used as we do not want the function to merely
print something but convert the input provided into output. The return command
returns the value of the function. Alternatively, we can write in the second line
of the code (example 3), print (x*10), denoting what is to be printed. Please note
while the parameter is x, the argument is 4.
[In]: first ()
[Out]:my_function
[In]: def multiply_ten(x):
print (x*10)
[In]: multiply_ten (4)
[Out]:40
Indentation is very crucial for proper coding. When defining a function and using
the Print operation, using the right indentation matters. The definitions of func-
tion and print use clearly distinguishable blocks of code or commands.
Once defined, we can check the code by giving a specific number to check:
It is important to note the indentation in the second and third line and the use
of colons at the end of the conditional statements. Also note if the number given
was 18, the output would be blank, as we have not specified what is to be printed
if the number is not divisible by 5. To improve on this condition, we introduce the
Else statement.
Introducing the Else statement, we can write,
Once defined, we can check the code by giving a specific number to check:
Once defined, we can check the code by giving a specific number to check:
[In]: Compare_to_1000(1000)
[Out]: Y is equal to 1000
for loops
The ‘for’ loop allows us to iterate through a given sequence and execute actions for
every element in the sequence. In the next example, we give the input to find the
square (exponential to the power 2) of every number in the sequence.
While loops
The While loop is for codes that should continue to execute while the condition
is true. For example,
[In]: x = 1
while x <= 10:
print (x),
[Out]: x= x + 2
1
3
5
7
9
228 Backtesting and algorithmic trading
Range()
The range function generates a sequence or list of integers and is called a generator.
We can then iterate through the list. For example, let us suppose for every factor of
20 below 100, we want to find the square of the number. We can input
You may have noted for the range function we can specify the step as well,
here 20.
Lambda expressions
• By adding in arguments, we can have functions doing more tasks for us. We
can use the return function to get the result of the operation. Let us have a
function ‘square’, which return the square of any number.
The preceding function can be written as a lambda expression. The lambda will
not have a function name, nor will it require a return. The lambda expression for
the previous function ‘square’ is
Lambda functions are especially useful when using maps and filters as we will
see in the following subsection.
Lambdas can be used effectively with filters. For example, for the earlier defined
sequence, if we want to get only the values divisible by 2, we can write
The basic operations explained here are given in the eResources notebook File
Ch10_NB1, and working with arrays is covered in Ch10_NB2.
import numpy
Or
import numpy as np
230 Backtesting and algorithmic trading
In the second case, we can now use np to call the numpy function.
[In]: import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import datetime as dt
import pandas_datareader as web
In this case, there will not be any output displayed. The % matplotlib inline
imported here is a very useful command in Python. IPython, when used as a
kernel, can show rich output like image, sounds, and animation, if the front end
supports it. With this back end of %matplotlib, the output of plotting commands
is displayed inline within front ends, like the Jupyter notebook, directly below the
code cell that produced it. The resulting plots will then also be stored in the note-
book document.
[Out]:
The first three lines tell Python that we will import data through pandas_datar-
eader of State Bank of India stock (ticker: SBIN.NS) from Yahoo! for the period 14
Backtesting and algorithmic trading 231
January 2014 to the 14 January 2020. Using the datetime option to define start and
end is useful as the Date column will be defined as datetime objects. The fourth
line asks a part of the data (head) to be shown. We could have surely asked for the
entire data to be shown, but since this would be quite a lot of data, Python will show
a part, specifying the full data available in columns and rows (see ‘Ch10_NB3a’).
We can also round it off to two decimal places with the round function. We can, of
course, retrieve data for more than one series (say, Apple stock prices), as shown in
the ‘Ch10_NB3a’.
We can also import data from a data source with the specific API key from
the data source. For example, alpha_advatage is an excellent source of share price
data. To access the API key, visit the source’s website https://alpha-vantage.
readthedocs.io/ and click on the ‘Get your free API key today’ and follow the
instructions given. This key will help you now to access the data as shown below:
We have used the API key6 to retrieve APPL (Ticker symbol of Apple Inc.)
intra-day data and asked for the output to be a pandas dataframe. A Dataframe in
pandas is a two-dimensional size-mutable, potentially heterogeneous tabular data
structure with labelled axes (rows and columns), and arithmetic operations align
on both row and column labels. The interval chosen is 1 minute, and the output
size asked for is the full or entire available data set.
[Out]:
[Out]:
If you can import a particular sheet (say, the sheet named ‘DATA’ from the Excel
file ‘inr’),
[In]: new=pd.read_excel(‘D:inrsec.xls’,’DATA’)
new.head()
[Out]:
Timestamp Close
0 2017–01–02 68.1389
1 2017–01–03 68.2529
2 2017–01–04 67.8755
3 2017–01–05 67.7325
4 2017–01–06 68.0900
In this case, select the columns to be retrieved from a Excel file (say, the three
columns, ‘Timestamp’, ‘Open’, and ‘Close’),
[In]: new1=pd.read_excel(‘D:inrsec.xls’,’DATA1’,usecols=
[‘Timestamp’,’Open’,’Close’])
new.head()
[Out]:
[In]:data2=pd.read_csv(‘D:/inr.csv’)
data2.head()
[Out]:
[In]: inr=pd.read_excel(‘D:inr.xlsx’)
inr.info()
[Out]:
<class ‘pandas.core.frame.DataFrame’>
RangeIndex: 537 entries, 0 to 536
Data columns (total 5 columns):
Timestamp 537 non-null datetime64[ns]
Close 537 non-null float64
Open 537 non-null float64
High 537 non-null float64
Low 537 non-null float64
dtypes: datetime64[ns](1), float64(4)
memory usage: 21.1 KB
[Out]:
[Out]:
[In]: new2=pd.read_excel(‘D:inrsec.xls’,’Sheet1’)
new2
[Out]:
Date Unnamed: 1
0 1st Jan 2019 12
1 2nd Jan 2019 14
2 4th Jan 2019 19
3 10th Jan 2019 21
4 2019–01–11 00:00:00 22
Backtesting and algorithmic trading 235
Date Unnamed: 1
5 2019–01–12 00:00:00 30
6 2019–01–13 00:00:00 31
7 2019–01–14 00:00:00 34
8 2019–01–15 00:00:00 35
9 2019–01–16 00:00:00 36
[In]: new2.info()
[Out]:
<class ‘pandas.core.frame.DataFrame’>
RangeIndex: 10 entries, 0 to 9
Data columns (total 2 columns):
Date 10 non-null object
Unnamed: 1 10 non-null int64
dtypes: int64(1), object(1)
memory usage: 240.0+ bytes
Now we use the names option in pd.read to name the columns. Then we use
the to_datetime command to convert into datetime objects and format string val-
ues to dates using the dt.strftime option. Finally we set the date column as index
as shown:
[In]:
new2=pd.read_excel(‘D:inrsec.xls’,’Sheet1’,header=0,names=[‘
Date’,’Values’])
new2[‘Date’] = pd.to_datetime(new2.Date)
new2[‘Date’] = new2[‘Date’].dt.strftime(‘%Y-%m-%d:%H:%M’)
new2.set_index(‘Date’,inplace=True)
new2.head(10)
[Out]:
Date Values
2019-01-01:00:00 12
2019-01-02:00:00 14
2019-01-04:00:00 19
2019-01-10:00:00 21
2019-01-11:00:00 22
2019-01-12:00:00 30
2019-01-13:00:00 31
2019-01-14:00:00 34
2019-01-15:00:00 35
2019-01-16:00:00 36
236 Backtesting and algorithmic trading
The data in Python can be saved in Excel or CSV format in the following way.
The code to save in. CSV format in this case will be
[In]:
my_data1.to_csv(‘C:/Users/Smita Roy/Desktop/chapter10/New_
files/example_1.csv’)
my_data1.to_excel (‘C:/Users/Smita Roy/Desktop/chapter10/
New_files/example_1.xlsx’)
[In]:
inr[‘Open’].plot(y=‘Open’,figsize=(12,8),title=‘inr’,color=
‘black’,label=‘Open’)
plt.legend()
plt.ylabel(‘Open’)
plt.xlabel(‘Time’)
plt.savefig (‘D:inr’,dpi=‘figure’)
[Out]:
We can also import data for a number of stocks together in one Dataframe and
analyse their performance. This is especially useful if we think of a portfolio of
several stocks and are keen to see the portfolio metrics. The basic financial analysis
Backtesting and algorithmic trading 237
in such cases and the derivation of the efficient portfolio frontier are covered in
‘Ch10_NB3b’ in the eResources.
[In]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import datetime as datetime
import pandas_datareader as web
[In]:
start=datetime.datetime(2014,3,1)
end=datetime.datetime(2020,4,5)
hdfc=web.DataReader(‘HDFCBANK.NS’,’yahoo’,start,end)
round(hdfc.head(),2)
[Out]:
[In]:
hdfc[‘Adj Close’].plot(label=‘Adj Close’,figsize=(12,4),title
=‘hdfc’,c=‘black’)
hdfc[‘Open’].plot(label=‘Open’,c=‘black’,ls=‘--’)
plt.legend()
238 Backtesting and algorithmic trading
[Out]:
b. We calculate the log returns of the series to be used later on. We also specify
that the values of the Dataframe are to be rounded off to three decimal places with
the round function.
[In]:
hdfc[‘log_returns’]=np.log(hdfc[‘Adj Close’]/hdfc[‘Adj
Close’].shift(1))
round(hdfc.head(),3)
[Out]:
Date
2014–03–03 336.000 331.600 332.60 333.100 1839216.0 306.615 NaN
2014–03–04 336.925 332.125 333.00 335.850 3221934.0 309.147 0.008
2014–03–05 337.500 331.250 336.75 334.875 2003492.0 308.249 -0.003
2014–03–06 338.850 334.050 336.50 337.800 2474340.0 310.942 0.009
2014–03–07 357.450 338.100 339.80 355.725 11383784.0 327.441 0.052
c. We calculate the SMA and the EMA. For the SMA, we use the np.rolling
function, and for the EMA, we use the np.ewm function. We specify only part of
the Dataframe to be presented as a table in the last line of the Input code.
[In]:
hdfc[‘SMA30’]=hdfc[‘Adj Close’].rolling(30).mean()
hdfc[‘SMA40’]=hdfc[‘Adj Close’].rolling(40).mean()
hdfc[‘EMA30’]=hdfc[‘Adj Close’].ewm(span=30,min_periods=30).
mean()
hdfc[‘EMA40’]=hdfc[‘Adj Close’].ewm(span=40,min_periods=40).
mean()
round(hdfc[[‘AdjClose’,’log_returns’,’SMA30’,’SMA40’,’EMA30’,
’EMA40’]].tail(10),3)
[Out]:
Backtesting and algorithmic trading 239
Date
2020-03-20 882.85 -0.014 1142.418 1163.845 1104.280 1131.207
2020-03-23 771.55 -0.135 1126.810 1152.013 1082.813 1113.663
2020-03-24 767.70 -0.005 1110.993 1140.091 1062.484 1096.787
2020-03-25 856.75 0.110 1098.208 1131.180 1049.210 1085.078
2020-03-26 901.10 0.050 1086.892 1123.128 1039.655 1076.103
2020-03-27 904.45 0.004 1075.407 1114.843 1030.932 1067.730
2020-03-30 831.65 -0.084 1061.748 1104.983 1018.075 1056.214
2020-03-31 861.90 0.036 1049.833 1095.873 1007.999 1046.735
2020-04-01 829.65 -0.038 1036.917 1086.794 996.493 1036.146
2020-04-03 813.85 -0.019 1023.603 1076.395 984.709 1025.302
d. We visualize the moving averages using matplotlib. Note the use of line style
(‘ls’) option in the example.
[In]:
hdfc[‘EMA30’].plot(label=‘EMA30’,figsize=(12,4),title=‘hdfc’
,c=‘black’)
hdfc[‘EMA40’].plot(label=‘EMA40’,c=‘black’,ls=‘--’)
hdfc[‘Adj Close’].plot(label=‘Adj Close’,c=‘black’,ls=‘:’)
plt.legend()
[Out]:
FIGURE 10.5 Python output (HDFC adjusted close, EMA 30, EMA 40)
Source: Author
We may want to see a part of the data, in which case we can specify the location
from which the data are to plotted using loc function:
[In]:
hdfc[‘EMA30’].loc[’2019–01–01’:].plot(label=‘EMA30’,figsize=(
12,4),title=‘hdfc’,c=‘black’)
hdfc[‘EMA40’].loc[’2019–01–01’:].plot(label=‘EMA40’,c=‘blac
k’,ls=‘--’)
plt.legend ()
240 Backtesting and algorithmic trading
[Out]:
FIGURE 10.6 Python output (HDFC adjusted close, EMA 30, EMA 40 using loc)
Source: Author
e. We can code the moving average double crossover strategy in many ways. In the
Python Notebook ‘Ch10_NB4’, we have shown the coding of the moving average
strategy in different ways. First, we can use a np.where condition to differentiate the
uptrend from the downtrend. We assume, we go long throughout the uptrend and
short during the downtrend. For EMA 30 and EMA 40, it means that we have buy
signals if EMA 30 > EMA 40 and sell if EMA 30 < EMA 40. This is coded as:
[In]:
hdfc[‘signal1’]=np.where(hdfc[‘EMA30’]>hdfc[‘EMA40’],1,(np.
where(hdfc[‘EMA30’]<hdfc[‘EMA40’],-1,0)))
round(hdfc[[‘SMA30’,’SMA40’,’EMA30’, ‘EMA40’,’signal2’]].
describe(),2)
[Out]:
points, we use nested np.where and ‘&’ condition. Note that each condition which
is to be satisfied together are coded in parentheses. Moreover, shift function has
been used to denote the variable at t − 1 period.
[In]:
hdfc['signal2']=np.where((hdfc['EMA30']>hdfc['EMA40'])&
(hdfc['EMA30'].shift(1)<hdfc['EMA40'].shift(1)),1,(np.
where((hdfc['EMA30']<hdfc['EMA40'])& (hdfc['EMA30'].
shift(1)>hdfc['EMA40'].shift(1)),-1,0)))
round(hdfc[['SMA30','SMA40','EMA30', 'EMA40','signal2']].
describe(),2)
[Out]:
[In]:
hdfc[‘b_signal’]= np.where(hdfc[‘EMA30’]>hdfc[‘EMA40’],1,0)
hdfc[‘signal3’]= hdfc[‘b_signal’].diff()
The output would be the same as for signal 2 as shown in
Ch10_NB4.
We see the number of signals using value_count option
[In]:
hdfc[‘signal1’].value_counts()
[Out]:
1 1112
–1 344
0 39
Name: signal, dtype: int64
[In]:
hdfc[‘signal2’].value_counts()
242 Backtesting and algorithmic trading
[Out]:
0 1475
–1 10
1 10
Name: signal2, dtype: int64
[In]:
hdfc[‘st1_returns’]=hdfc[‘log_returns’]
*hdfc[‘signal1’].shift(1)
hdfc[‘st2_returns’]=hdfc[‘log_returns’]
*hdfc[‘signal2’].shift(1)
hdfc[‘st3_returns’]=hdfc[‘log_returns’]
*hdfc[‘signal3’].shift(1)
hdfc[[‘st1_returns’,’st2_returns’,’st3_returns’]].mean()
[Out]:
st1_returns 0.000974
st2_returns 0.000116
st3_returns 0.000116
dtype: float64
We can also calculate the standard deviation and annualized returns as shown in
the notebook file ‘Ch10_NB4’.
[In]:
sbi[‘close_diff’]=sbi[‘Adj Close’]-sbi[‘Adj Close’].shift(1)
sbi[‘pos_close_diff’]=np.where(sbi[‘close_diff’]>0,
sbi[‘close_diff’],0)
sbi[‘neg_close_diff’]=np.where(sbi[‘close_diff’]<0,
sbi[‘close_diff’],0)
sbi[‘neg_close_adiff’]=np.absolute(sbi[‘neg_close_diff’])
sbi[‘pos_diff_sum’]=sbi[‘pos_close_diff’].rolling(14).sum()
sbi[‘neg_diff_sum’]=sbi[‘neg_close_adiff’].rolling(14).sum()
sbi[‘rs’]=sbi[‘pos_diff_sum’]/sbi[‘neg_diff_sum’]
Backtesting and algorithmic trading 243
sbi[‘rsi’]=100-(100/(1+sbi[‘rs’]))
sbi[‘rsi’].describe()
[Out]:
count 1482.000000
mean 50.787076
std 17.513462
min 8.523747
25% 37.317499
50% 51.488720
75% 64.275535
max 94.538833
Name: rsi, dtype: float64
[In]:
sbi[‘signals_buy_rsi’]=np.where(sbi[‘rsi’]>50,1,0)
sbi[‘signals_sell_rsi’]=np.where(sbi[‘rsi’]<50,-1,0)
sbi[‘rsi_all’]=sbi[‘signals_buy_rsi’]+sbi[‘signals_sell_rsi’]
sbi[‘rsi_all’].describe()
[Out]:
count 537.000000
mean 0.001862
std 0.985906
min -1.000000
25% -1.000000
50% 0.000000
75% 1.000000
max 1.000000
Name: rsi_all, dtype: float64
[In]
sbi[‘rsi_all’].value_counts()
1 770
–1 709
0 16
Name: rsi_all, dtype: int64
d. Finally, we calculate the strategy returns and mean returns (annualized %):
[In]:
sbi[‘st3_returns’]=sbi[‘log_returns’]*sbi[‘rsi_all’].shift(1)
round(sbi[‘st3_returns’].mean()*252*100,2)
[Out]:
16.52
244 Backtesting and algorithmic trading
In this case, we annualize the returns and round them off to two decimal places
and express it in percentage terms.
The coding of an MACD strategy is given in Ch10_NB6. In this way, we can
code different strategies with a technical analysis indicator and see its performance
for a historical series.
10.5 Key takeaways
1 An algorithm is a series of steps or instructions which will ensure the input
generates consistently the intended output.
2 Algorithmic trading refers to the generation of automated buy and sell signals
based on a set of instructions given to the computing system and the execution
of such trades.
3 Both fundamental and technical trading strategies can be used for algorithmic
trading.
4 It is essential to backtest a strategy on the historical series to measure its per-
formance before using it for algorithmic trading.
5 Backtesting is the process of applying your strategy on historical data to evalu-
ate its performance.
Backtesting and algorithmic trading 245
Notes
1 Harari, Y. N. (2016). Homo Deus: A brief history of tomorrow (p. 319). London: Penguin
Random House.
2 For all such references, see eResource on this book’s page on the Routledge website:
www.routledge.com/9780367313555
3 https://opensource.org
4 An IDE is a software suite that consolidates basic tools required to write and test software.
Some IDEs are open source, while others are commercial offerings. An IDE can be a
standalone application, or it can be part of a larger package. https://realpython.com/
python-ides-code-editors-guide/
5 www.scipy.org/
6 https://alpha-vantage.readthedocs.io/
7 www.quantopian.com/home
11
CONCLUSION
FIGURE 11.1
Globalindices at a glance, 2009–2020 (monthly chart). Created with
Amibroker
declines seen in crude oil happened in March 2020, which coincided with the big-
gest monthly decline seen in the DJIA since 2009.
Figure 11.3, EUR/USD monthly chart also shows that it topped out in 2008
and has continued to move in the downtrend since. This indicates that there was a
major shift in the market structure for these assets in 2008 and that there is no res-
pite in them even now. EUR/USD did not show any major declines with the start
of 2020 but has shown a rise in volatility with wild gyrations again in March 2020
that embarked along with a big down move in the DJIA and crude oil. This brings
us to the fact that 2020 will be known in history for global market volatility, and
it is important for every technical analyst to keep a close track on how each of the
assets are behaving with respect to each other during this period.
Another interesting aspect seen with the augment of 2020 is that the market
moves in 2020 show an uncanny resemblance to that of the crash seen in 1987. We
can see this from Figure 11.4 of the DJIA in 1987 and the Nifty 50 in 2020.
The two charts reflect two different indices – the US major equity index, DJIA,
and the Indian major equity index, Nifty. There is an amazing similarity between
these two different indices as can be seen in the figures. The 1987 crash, or the
Black Monday (19 October 1987) crash, as it is popularly called, ended a five-year
bull run of the DJIA that marked a rise from 776 points in August 1982 to a high
of 2722.42 points in August 1987 (Itskevich, 2020). On that fateful day, the DJIA
declined by more than 22% in a single day, 19 October 1987. The decline in this
index started much earlier. From 25 August 1987 to 20 October 1987, the DJIA
FIGURE 11.4 The DJIA and the Nifty 50 (daily chart). Created with Amibroker
crashed by nearly 41% and took approximately eight weeks to move from highs of
2746 to lows of 1616 levels.
A very similar observation can be made about the Nifty index that had fallen by
nearly 40% and took nine weeks to move from highs of 12430 to the lows of 7511
during the period January 2020 to March 2020. One important difference being
the fall of 2020 is systemically spread over the period whereas during the correc-
tion in 1987, the majority of the fall was attributed towards one day of crash, 19
October 1987. Post 20 October 1987, the DJIA witnessed a time correction for
more than a year when prices drifted in a broad range, with a minor upside bias. It
will be important to see if the remainder of 2020 will follow a similar path or start
exhibiting a different pattern in comparison to the crash witnessed in 1987.
Figure 11.5 shows technical studies on the DJIA during 1987. The chart is
self-explanatory based on the various technical indicators: Dow Theory, chan-
nels, support and resistance, Elliott Waves, and moving averages discussed in ear-
lier chapters. The rise seen during the period prior to the fall completed wave
(5) as per the Elliott Wave pattern (shown by Robert Prechter, The Elliott Wave
Theorist – January 31, 2020) before the fall started. During the completion of
wave (5), momentum was waning, which can be seen from the negative divergence
between the RSI and prices. The resistance trend line of the channel halted the rise
from where prices reversed on the downside. Later, it went on to breach the sup-
port trend line and formed lower highs and lower lows that gave a classical negative
confirmation as per Dow Theory. This was further confirmed by negative moving
average crossover technique. The chart shows there was enough evidence as per
different technical studies.
Now, let us see the technical outlook on the DJIA before the crash of Febru-
ary 2020. Figure 11.6 shows technical studies on the DJIA during 2019–2020.
The rise seen during the period prior to the fall completed wave (5) as per Elliott
Wave pattern. During the completion of wave (5), momentum was waning that
250 Conclusion
FIGURE 11.5 The DJIA (daily chart) technical outlook before the crash of October 1987.
Created with Amibroker
can be seen from the negative divergence between the RSI and prices. The resist-
ance trend line halted the rise from where prices reversed on the downside. This
was further confirmed by the moving average crossover technique. Later, it went
on to breach the support trend line and formed lower highs and lower lows that
gave classical negative confirmation as per Dow Theory. This might look like a
repeat of what is mentioned in the earlier paragraph, and it indeed is a similar
technical picture! While 2020 is known for the COVID-19 pandemic, we can see
the pandemic has not been the only reason for the financial markets’ meltdown.
There were signals of impending correction that mimicked the technical studies
seen during 1987. As discussed earlier in various chapters, many of the major global
indices were already exhibiting a loss of momentum that was visible clearly on the
charts across the time frames – monthly, weekly, daily, and hourly. It was in Janu-
ary 2020–February 2020 that major world indices topped out and starting falling in
a synchronized fashion. Such a synchronized or systematic sell-off was earlier seen
during 2008 fall and the prior bear markets. Global markets were already limping,
and the pandemic acted as a trigger or catalyst to the already-weak market structure
that resulted in a crash comparable to that of 1987!
This reflects clearly that technical analysis as a study is applicable across time
frames and varied indices or assets. The similarity across different time-frame charts
Conclusion 251
FIGURE 11.6 DJIA (daily chart) technical outlook before the crash of February 2020.
Created with Amibroker
and different indices conforms to the fact that markets are fractal in nature and that
the basic emotions – greed, fear and hope – do not really change with technology
and news flows. All these things are reflected in the chart, and as a trader or inves-
tor, it becomes very important to apply the systematic ways of technical analysis
without relying only on the events or news flow which might be tinted due to the
lagging effect.
We take up next a sectoral analysis for both the US and Indian equity markets.
In Figure 11.7, different US sectors’ relative performance is shown along with the
main index, the DJIA. The chart reflects that during the entire decline, the sectors
that relatively outperformed the major index, the DJIA, have been health care and
consumer staples. Do note that these sectors did not give positive returns but out-
performed the major index, the DJIA. Financials was the worst-performing sector
which was followed by materials and consumer discretionary.
Interestingly, the sectors that are underperforming and outperforming right
now are similar to that seen during 2008. In Figure 11.8, we can see how the
various sectors have been performing as compared against the Nifty index. It is
interesting to see that since the top was formed in mid-January on the Nifty index,
the strongest sector that has emerged is the pharmaceutical sector. Now, this might
look like obvious given the ongoing pandemic. But if it is observed closely, it was
not until mid-March that the pharmaceutical sector really took off in compari-
son to the Nifty index. Also, this is accompanied by strong outperformance from
252 Conclusion
FIGURE 11.7
Relative performance of US sectors during 2008 fall. Created with
Amibroker
FIGURE 11.8 Relative
performance of Indian sectors during 2020 fall. Created with
Amibroker
Conclusion 253
fast-moving consumer goods sector. On the Nifty, auto, banks, and metal are the
worst-performing sectors in Indian equity markets. This relative performance is an
important way to identify the sectors gaining momentum. Stocks in the outper-
forming sectors can be considered from a momentum-trading perspective. Also,
this relative performance chart provides a base for forming pair-trading strategies.
This indicates that during the 2008 and the current 2020 bear markets, defensive
sectors like pharmaceuticals and consumer Staples show relative outperformance. It
is interesting that while the crash of 2008 and the fall seen in 2020 are perceived to
occur for different reasons, the sectors that are relatively underperforming/outper-
forming in Indian equity markets are mimicking the relative performance of sectors
seen in the US during the subprime crises.
The analysis suggests that in rough market periods, we can take charge of our
trading or investment decisions, and what can be a better way than to apply tech-
nical analysis on the charts. As the analysis over the 10 chapters of the book has
shown, understanding the intrinsic patterns in the market through technical analy-
sis is essential for effective trading. However, its utility is not restricted to trading
alone. For those interested and connected to financial markets, the patterns have
important implications: they give clues to how markets, or rather the individuals
who make up the markets, have thought and acted. The reaction and behaviour
of these individuals again form the basis of other economic decision-making every
day. The study of the markets and its patterns then create the way to a deeper
understanding of economic behaviour.
Note
1 Strevens, M. (2009). Bigger than chaos: Understanding complexity through probability (p. 3).
London: Harvard University Press.
REFERENCES
Abramovitz, M. (1961, April 30). The nature and significance of Kuznets cycles. Economic
Development and Cultural Change, 9(3), 225–248, Essays in the Quantitative Study of Eco-
nomic Growth, Presented to Simon Kuznets on the Occasion of His Sixtieth Birthday, by
His Students and Friends. Retrieved May 6, 2020, from www.jstor.org/stable/1151797
Allen, H. L., and Taylor, M. P. (1990). Charts, noise and fundamentals in the London For-
eign exchange market. Economic Journal, 100, 49–59.
Baker, H. K., Filbeck, G., and Harris, J. H. (2018). Commodities: An overview. In H. K.
Baker, G. Filbeck, and J. H. Harris (Eds.), Commodities: Markets, performance, and strategies
(p. 4). New York: Oxford University Press.
Balvers, R., Wu, Y., and Gilliland, E. (2000). Mean reversion across national stock markets
and parametric contrarian investment strategies. The Journal of Finance, LV(2), 745–772.
Bank of International Settlements. (2012). Data requirements for monitoring derivative transac-
tions. Irving Fisher Committee on Central Bank Statistics, IFC Bulletin, no 35, Proceed-
ings of the workshop organized by the People’s Bank of China and the Irving Fisher
Committee, Zhengzhou, 27–29 September 2010.
Bedford, L. (2012). Charting secrets: Stop reading start practicing. Hoboken, NJ: John Wiley &
Sons.
Bencivenga, V. R., and Smith, B. D. (1991). Financial intermediation and endogenous
growth. Review of Economics Studies, 58, 195–209.
Bessembinder, H. (1994). Bid-ask spreads in the interbank foreign exchange markets. Journal
of Financial Economics, 35, 317–348.
Bishop, G. (1961). Evolution of the Dow Theory. Financial Analysts Journal, 17(5), 23–26.
Bogle, J. (2015). John Bogle on investing: The first 50 years. Hoboken, NJ: John Wiley & Sons.
Bollinger, J. (2019). Bollinger band rules. Retrieved July 9, 2019, from https://www.bol
lingerbands.com/
Brock, W., Lakonishok, J., and LeBaron, B. (1992). Simple technical trading rules and the
stochastic properties of stock returns. Journal of Finance, 47, 1731.
CandleScanner. (2020). Bearish Engulfing. Retrieved March 12, 2020, from https://www.
candlescanner.com/candlestick-patterns/bearish-engulfing/
References 255
Chan, E. P. (2009). Quantitative trading: How to build your own algorithmic trading business, The
Wiley trading series. Hoboken, NJ: John Wiley & Sons.
Chan, E. P. (2013). Algorithmic trading: Winning strategies and their rationale. Hoboken, NJ:
John Wiley & Sons.
Chari, A. (2007). Heterogeneous market-making in foreign exchange markets: Evidence
from individual bank responses to central bank interventions. Journal of Money, Credit and
Banking, 39(5), 1131–1162.
Chen, J. (2010). Essentials of technical analysis for financial markets. John Wiley & Sons.
Cheung, Y.-W., and Chinn, M. D. (2001). Currency traders and exchange rate dynamics:
A survey of the US market. Journal of International Money and Finance, 20, 439–471.
Cheung, Y.-W., Chinn, M. D., and Marsh, I. (2004). How do U.K.-based foreign exchange
dealers think their market operates? International Journal of Finance and Economics, 9,
289–306.
Cheung, Y.-W., and Wong, C. Y.-P. (2000). A survey of market practitioners' views on
exchange rate dynamics. Journal of International Economics, 51(2), 401–419.
Debroy, B. (2018, January). First post (2nd ed.), Interview: Budget and Beyond. Retrieved
from www.firstpost.com/business/budget-and-beyond-i-want-everything-to-come-under-
gst-there-should-be-no-exemptions-bibek-debroy-tells-firstpost-4283895.html
Demirgüç-Kunt, A., and Levine, R. (1995). Stock market development and financial intermediar-
ies: Stylized facts. Policy Research Working Paper Series, no. 1462, pp. 1–52. The World
Bank. Retrieved March 27, 2009, from www.wds.worldbank.org.servlet.WDSCon
tentServer.WDSP.IB.(1995).05.01.000009265_3961019111757.Rendered.PDF.multi_
page.pdf
Dimson, E., and Mussavian, M. (1998, March). A brief history of market efficiency. Euro-
pean Financial Management, 4(1), 91–193.
Domingos, P. (2015). The master algorithm: How the quest for the ultimate learning machine will
remake our world. Basic Books.
Dormeier, B. P. (2011). Investing with volume analysis: Identify, follow, and profit from trends.
Upper Saddle River, NJ: FT Press.
Dow, C. (1990, December 14). Review and outlook, as cited in Dow, C., and Sether, L.
(2009). Dow theory unplugged: Charles Dow’s original editorials and their relevance today.
Greenville, SC: Traders Press.
Dreger, C., and Stadtmann, G. (2008). What drives heterogeneity in foreign exchange rate
expectations: Insights from a new survey. International Journal of Finance & Economics,
13(4), 360–367.
Duong, H. N., Kalev, P. S., and Tian, X. (2018, August 18). Short selling, trading activity and
volatility in corporate bond market. 31st Australasian Finance and Banking Conference 2018.
http://dx.doi.org/10.2139/ssrn.3234262
El-Erian, M. A. (2016). The only game in town: Central banks, instability, and avoiding the next
collapse. London: Yale University Press.
Encyclopaedia Britannica. (2020). Charles Henry Dow. Retrieved January 20, 2020, from
https://www.britannica.com/biography/Charles-Henry-Dow
Evans, M. D., and Lyons, R. K. (2002). Order flow and exchange rate dynamics. Journal of
Political Economy, 110(1), 170–180.
Evans, M. D., and Lyons, R. K. (2008). How is macro news transmitted to exchange rates?
Journal of Financial Economics, 88, 26–50.
Fama, E. F. (1970). Efficient capital markets: A review of theory and empirical work. The
Journal of Finance, 25(2), 383–417, Papers and Proceedings of the Twenty-Eighth Annual
Meeting of the American Finance Association New York, NY.
256 References
Fama, E. F., and Thaler, R. H. (2016). Discussion on market efficiency. Retrieved from https://
review.chicagobooth.edu/economics/2016/video/are-markets-efficient
Fleming, M. J., and Remolona, E. M. (1999). Price formation and liquidity in the U.S.
Treasury market: The response to public information. The Journal of Finance, 54(5),
1901–1915.
Frenkel, M., and Stadtmann, G. (2004). Trading rule profitability and central bank inter-
ventions in the Dollar-Deutsch mark market. Journal of Economics and Statistics, 224(6),
653–672.
Fuhrmann, R. C., and Lamba, A. S. (2011). Overview of equity securities. In M. G. McMil-
lan, J. E. Pinto, L. P. Wendy, and G. V. Venter (Eds.), Investments: Principles of portfolio and
equity analysis. Hoboken, NJ: John Wiley & Sons, Inc.
Galati, G. (2000). Trading volumes, volatility and spreads in Foreign exchange markets:
Evidence from emerging market countries, Bank for International Settlements. Retrieved
May 26, 2018, from www.bis.org/publ/work93.htm
Gehrig, T., and Menkhoff, L. (2006). Extended evidence on the use of technical analysis in
foreign exchange. International Journal of Finance & Economics, 11(4), 327–338.
Grafton, C. (2011). Mastering Hurst cycle analysis: A modern treatment of Hurst’s original system
of financial market analysis. Great Britain: Harriman House Limited.
Greenwood, J., and Jovanovic, B. (1990). Financial development, growth, and the distribu-
tion of income. Journal of Political Economy, 98, 1076–1107.
Harari, Y. N. (2016). Homo Deus: A brief history of tomorrow. London: Penguin Random
House.
Harris, L. (2002). Trading and exchanges: Market microstructure for practitioners. New York:
Oxford University Press.
Hellwig, M. F. (1982). Rational expectations equilibrium with conditioning on past prices:
A mean-variance example. Journal of Economic Theory, 26(2), 279–312.
Hilpisch, Y. (2018). Python for finance. Sebastopol, CA: O’Reilly.
Hsu, P.-H., Taylor, M. P., and Wang, Z. (2016). Technical trading: Is it still beating the For-
eign exchange market? Journal of International Economics, 102, 188–208.
Hurst, B., Ooi, Y. H., and Heje, L. (2017). A century of evidence on trend-following invest-
ing. Journal of Portfolio Management, 44(1), 15–29.
Hurst, J. (2000). The profit magic of stock transaction timing. Greenville, SC: Traders Press.
Itskevich, J. (2020). What caused the stock market crash of 1987? Retrieved March 2, 2020,
from https://historynewsnetwork.org/article/895
Jones, C. M., Kaul, G., and Lipson, M. L. (1994). Transactions, volume, and volatility. The
Review of Financial Studies, 7(4), 631–651. https://doi.org/10.1093/rfs/7.4.631
Kahneman, D. (2011). Thinking, fast and slow. London: Penguin.
Kaufman, P. J. (1995). Smarter trading: Improving performance in changing markets. New York:
McGraw Hill Professional.
Kaufman, P. J. (2013). Trading systems and methods. Hoboken, NJ: John Wiley & Sons.
Kirkpatrick II, C. D., and Dahlquist, J. A. (2011). Technical analysis: The complete resource for
financial market technicians. Upper Saddle River, NJ: Pearson Education, Inc.
Kuepper, J. (n.d.). Heikin-Ashi: A better candlestick. Retrieved July 5, 2019 from www.
investopedia.com
Kuznets, S. (1940, June). Schumpeter’s business cycles. The American Economic Review, 30(2),
Part 1, 257–271.
LeBaron, B. (1999). Technical trading rule profitability and foreign exchange intervention.
Journal of International Economics, 49(1), 125–143.
References 257
Levine, R. (2005). Finance and growth: Theory and evidence, handbook of economic
growth. In P. Aghion and S. Durlauf (Ed.), Handbook of economic growth (1 ed., Vol. 1,
chapter 12, pp. 865–934). Oxford, UK: Elsevier.
Levine, R., and Zervos, S. (1996). Stock market development and long-run growth. P olicy
Research Working Paper Series, 1582, Finance and Private Sector Development Divi-
sion, The World Bank, pp. 1–34. Retrieved March 23, 2011, from http:// ideas.repec.
org.p.wbk. wbrwps.1690.html
Lim, A. M. (2015). The handbook of technical analysis + test bank: The practitioner’s comprehensive
guide to technical analysis. Singapore: John Wiley & Sons.
Link, M. (2003). High-probability trading. McGraw-Hill Education.
Lo, A. (1994). Data-snooping biases in financial analysis. In H. Russell Fogler (Ed.), Blending
quantitative and traditional equity analysis (pp. 59–66). Charlottesville, VA: Association for
Investment Management and Research.
Makridakis, S. et al. (1983). The accuracy of major extrapolation (time series) methods. London:
Wiley (in press).
Makridakis, S., Andersen, A., Carbone, R., Fildes, R., Hibon, M., Lewandowski, R., New-
ton, J., Parzen, E., and Winkler, R. (1982). The accuracy of extrapolation (time series)
methods: Results of a forecasting competition. Journal of Forecasting, 1(2), 111–153.
Makridakis, S., and Winkler, R. L. (1983). Averages of forecasts: Some empirical results.
Management Science, 29(9), 987–996.
Meese, R., and Rogoff, K. (1983). Empirical exchange rate models of the seventies: Do they
fit out of sample? Journal of International Economics, 14, 3–24.
Menkhoff, L. (2010). The use of technical analysis by fund managers: International evi-
dence. Journal of Banking & Finance, 34(11), 2573–2586.
Menkhoff, L., and Schlumberger, M. (1995). Persistent profitability of technical analysis on
foreign exchange markets? Banca Nazionale del Lavoro Quarterly Review, 48(193), 189–215.
Menkhoff, L., and Taylor, M. P. (2007). The obstinate passion of Foreign exchange profes-
sionals: Technical analysis. Journal of Economic Literature, 45(4), 936–972.
Microsoft Office. (2020). https://www.microsoft.com
Miner, R. C. (2008). High probability trading strategies: Entry to exit tactics for the forex, futures,
and stock markets. Hoboken, NJ: Wiley.
Murphy, J. (1999). Technical analysis of financial markets. New York: Penguin Group.
Neely, C. J. (1998). Technical analysis and the profitability of U.S. Foreign exchange inter-
vention. Federal Reserve Bank of St. Louis Review, 80(4), 3–17.
Neely, C. J., and Weller, P. A. (2001). Technical analysis and central bank intervention. Jour-
nal of International Money and Finance, 20(7), 949–970.
Neely, C. J., Weller, P. A., and Dittmar, R. (1997). Is technical analysis in the foreign
exchange market profitable? A genetic programming approach. Journal of Financial and
Quantitative Analysis, 32, 405–426.
Neely, G. (1990). Mastering Elliott wave. New York: Elliott Wave Institute.
NEoWave™. (1995). Conference and Workshop. Retrieved from https://www.neowave.
com/glenn-neely-video.asp
Neo Wave Inc. (2005). What is a NEoWave diametric formation? Retrieved January 5, 2020,
from https://www.neowave.com/qow/qow-archive-3.asp
Nison, S. (1991). Japanese candlestick charting techniques: A contemporary guide to the ancient
investment techniques of the far east. New York: New York Institute of Finance.
Northington, K. (2009). Volatility-based technical analysis: Strategies for trading the invisible
(Vol. 396). Wiley Trading, Wiley & Sons.
258 References
Thaler, R. H. (2014). Response to the question, what scientific idea is ready for retirement?
Retrieved from www.edge.org/response-detail/25293
Thaler, R. H. (2015). Misbehaving: The making of behavioural economics. London: Penguin.
Thomsett, M. C. (2015). A technical approach to trend analysis: practical trade timing for enhanced
profits. FT Press.
Tudela, F. (2010). Trading triads: Unlocking the secrets of market structure and trading in any market.
West Sussex, UK: Wiley.
Tulchinsky, I. (2019). Finding alphas: A quantitative approach to building trading strategies. Corn-
wall, UK: John Wiley & Sons.
Vortelinos, D. I. (2015). The effect of macro news on volatility and jumps. Annals of Econom-
ics and Finance, 16(2), 425–447. Retrieved from www.maynardkeynes.org/keynes-the-
speculator.html
Web references
https://alpha-vantage.readthedocs.io/
https://docs.scipy.org
https://opensource.org
https://www.quantopian.com/home
INDEX
Note: Page numbers in italic indicate a figure and page numbers in bold indicate a table on
the corresponding page; Page numbers followed by ‘n’ refer to notes.
5th failure impulse 159, 160, 180 excel or a. csv file, importing 231 – 233;
data visualizing, matplotlib 236 – 237;
actual cycle 188, 189, 191, 196, 200 importing data to python notebook
adaptive moving average 99 230 – 236; ‘Index_col’ option in pd.read
advance block pattern 82 233 – 234; modules and packages,
algorithmic traders 203 – 205, 244 importing 229 – 230; moving average
algorithmic trading 203 – 218, 220, 244; strategy, coding 237 – 242; non-formatted
backtesting, choice of software 205; data, index setting 234 – 236; Quantopian
backtesting, strategy 205; choice of platform, using 244; RSI strategy, coding
database 205 – 206; concept of 204 – 206; 242 – 244; to_index option 234; web
excel for 207 – 221; look-ahead bias and using pandas_datareader 230 – 231
data-snooping bias 206; pseudo code bar chart 20
formation 204; signal generation and bar technique 39, 40
automated trading system 206 basic arithmetic operators 223
Allen, H. L. 3 basic excel functions 207 – 210; logical
amplitude 187 functions 209 – 210; mathematical
Anaconda 221, 222, 229 functions 208 – 209; reference cells 208;
AND function 209 relative and absolute references 208
ascending triangles 53, 54 basics in python 222 – 229; assigning values
assets 2 in 222; indexing of elements 223;
astute trader 113 putting comments 222
average prices 25, 26, 126, 211, 213, 214, bearish falling three methods 88, 93
218, 219 bearish tendencies 74, 76, 79, 81, 117
average true range (ATR) 136, 141 – 143, Belt Hold Lines (Yorikiri) 86
146, 147, 149, 215, 217 – 219 bid–ask spreads 13, 14
bigger cycle 187 – 191
backtesting 203 – 218, 220 – 222, 229, 237, Bollinger, John 138
242, 244, 245 Bollinger Bands 136 – 143, 146 – 148,
backtesting, python 229 – 244; arranging 199, 200
data and index setting 233; data from bond markets 183
Index 261
Bow-Tie Diametric pattern 173, 174 separating lines 90 – 92; triangles 53 – 55;
breakaway gaps 59 – 62, 64, 132 wedges 57 – 59; windows 88
Brock, W. 4 corrective pattern completion
brokers 11, 13 – 15, 206, 244, 245 confirmation 180
bullish rising three methods 88, 93 corrective patterns 151, 155, 160, 161, 164,
business cycles 119, 185 170, 175, 177, 180, 183, 184
corrective waves 151, 160, 164; flat
Candlestick Charting Techniques 67 correction pattern 164 – 169; triangle
candlesticks 23, 25 – 26, 67 – 80, 82 – 83, correction 170 – 172; zigzag correction
86, 90, 92, 125, 126; candles with both (5–3–5) 160 – 164
long upper and lower shadows 71; charts COVID-19 pandemic 42, 130 – 131,
23, 67, 68, 92; concept of 68 – 69; Doji 147, 250
candlesticks 71; long candlesticks 70; crossover technique 105 – 106, 108,
long lower shadows only 71; long upper 109, 113, 122, 204, 249, 250; double
shadows only 71; short candlesticks crossover 106 – 108; triple crossover
70 – 71 technique 108 – 109
candles with both long upper and lower currencies 2, 8 – 10, 13, 15, 16, 96, 105,
shadows 71 135, 207
capital markets 8, 15 Customer’s Afternoon Letter 26
Central bank intervention 6 cycles 185 – 193, 195 – 197, 199 – 202
centred moving average 102, 193
Chaikin Money Flow Index 143 – 145, 149 Dark Cloud Cover (Kabuse) 76
Chan, E. P. 206 DAX 246
channelling 179 – 183 dealers 11, 13, 135
channels 36, 39, 65, 179, 181, 184, 249 De Bondt 5
characteristic of cycles 186, 187 Debroy, Bibek 135
chart movements 4, 18, 19, 31 Deliberation Pattern 82
charts 2 – 4, 16 – 18, 20, 27, 40, 42, 65, 73, derivative markets 10, 16
130, 150, 250; bar chart 20; candlesticks descending triangles 53, 54, 54, 55
23; Heiken Ashi (HA) candlesticks detrending for cycle identification 192
23 – 26; line chart 20, 21; point and diametric pattern 173, 174, 179, 196, 201
figure charts 21 – 22; time frame of diametric pattern new patterns 173 – 178;
18 – 20 alternation 175; combination pattern
Cheung, Y.-W. 3, 4 175; triple combination or triple 3s
Chinn, M. D. 3 177 – 178
classical patterns 44, 64, 65, 92 Diamond-shaped Diametric 173, 174
classical technical analysis 42, 44, 86, divergences 73, 118 – 123, 127 – 131, 133,
109, 136 137, 144 – 145, 249
clearing-houses 11 – 12 Doji candlesticks 71, 72, 72, 73
clearing instructions 13, 15 Dojima Rice Exchange 67
close/closing prices 20, 23, 25, 26, 31, 69, double bottom 48 – 50
70, 114, 116, 125, 126, 142, 144, 149, double combination 176, 177
206, 211 – 214, 216, 217 double crossover 106 – 107, 109, 112, 204,
coding trading strategies 210 206, 210, 212 – 215, 240
commodity markets 10, 16, 42 double top 48 – 50, 62, 127, 128
commonality, principle of 189 double zigzag pattern 162, 163
common reversal patterns 66, 92 Dow, Charles Henry 26, 28
complex correction 162, 175 Dow Jones Industrial Average (DJIA) 35,
continuation 44 – 48, 52, 53, 56, 57, 59, 65, 40, 41, 54, 55, 58, 180 – 183, 191 – 193,
66, 68, 88, 90 246, 248 – 249, 251
continuation patterns 44 – 57, 66, 68; Dow theory 26, 28, 35, 40, 42, 44,
bearish falling three methods 88 – 90; 129, 249 – 250; main criticisms of
bullish rising three methods 88 – 90; 28 – 29; tenets of technical analysis
flags and pennants 56 – 57; gaps 59 – 65; 26 – 28
262 Index