75% found this document useful (4 votes)
2K views

Effective Trading in Financial Markets Using Technical Analysis

Uploaded by

sushil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
75% found this document useful (4 votes)
2K views

Effective Trading in Financial Markets Using Technical Analysis

Uploaded by

sushil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 295

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:

• Presenting in-depth coverage of technical analysis tools (including trade set-ups)


as well as backtesting and algorithmic trading
• Discussing advanced concepts such as Elliott Waves, time cycles and momentum, volume,
and volatility indicators from the perspective of the global markets and especially India
• Blending practical insights and research updates for professional trading, investments,
and financial market analyses
• Including detailed examples, case studies, comparisons, figures, and illustrations from
different asset classes and markets in simple language

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

‘This book is an amazing toolkit to understand trading/investing as a data-driven


science. The toughest act in money making is the art of keeping emotions aside,
and this book explains the calibrated techniques and tools in a simplified manner.’
– Kamlesh Jain, MRICS, CA, founder, Innovation India in
and the Attention Institute, and former executive director,
Nomura, head of Global Equities
‘The timing of this book’s publication – amid the global COVID-19 financial crisis
of 2020 – is perfect for introducing a new generation to the value of technical
analysis. The chapter on Elliott waves provides a solid review of the basic principles
of wave analysis using recent examples and easy-to-understand summaries of
important points. Long-term investors who read this book will be well prepared
for the next secular bear market. And short-term traders will gain a quick return
on the time invested in reading it.’
– Mark Galasiewski, chief equity analyst for Asia and
Emerging Markets, Elliott Wave International

‘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

Smita Roy Trivedi and


Ashish H. Kyal
First published 2021
by Routledge
2 Park Square, Milton Park, Abingdon, Oxon OX14 4RN
and by Routledge
52 Vanderbilt Avenue, New York, NY 10017
Routledge is an imprint of the Taylor & Francis Group, an informa business
© 2021 Smita Roy Trivedi and Ashish H. Kyal
The right of Smita Roy Trivedi and Ashish H. Kyal to be identified
as authors of this work has been asserted by them in accordance with
sections 77 and 78 of the Copyright, Designs and Patents Act 1988.
All rights reserved. No part of this book may be reprinted or reproduced or
utilised in any form or by any electronic, mechanical, or other means, now
known or hereafter invented, including photocopying and recording, or in
any information storage or retrieval system, without permission in writing
from the publishers.
Research, analyses, or other information contained in this book are for
educational purposes only, and do not constitute investment advice.
Authors have made every effort to provide accurate information and web
addresses but neither the authors or the publisher are responsible for any
errors or changes occurring after publication. Authors or the publisher
do not assume any responsibility for third-party websites or the content
therein.
Trademark notice: Product or corporate names may be trademarks or
registered trademarks, and are used only for identification and explanation
without intent to infringe.
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library
Library of Congress Cataloging-in-Publication Data
A catalog record for this book has been requested
ISBN: 978-0-367-31354-8 (hbk)
ISBN: 978-0-367-31355-5 (pbk)
ISBN: 978-0-429-31648-7 (ebk)
Typeset in Bembo
by Apex CoVantage, LLC
Visit the eResources: www.routledge.com/9780367313555
CONTENTS

List of figures xii


List of tables xviii
List of abbreviations xix
Prefacexx
Acknowledgementsxxv

1 Introduction to technical analysis 1


1.1 Technical analysis and trading in the financial markets 1
1.2 Evidence on the use of technical analysis 3
1.3 Technical analysis profitability and the efficient market
paradigm 4
1.4 What explains the profitability of technical analysis? 5
1.5 Financial markets: the trader’s playground 7
1.5.1 Functions of financial markets 7
1.5.2 Types of financial markets 8
1.5.3 Infrastructure of trading 10
1.6 Key takeaways 15

2 Basic principles of technical analysis 17


2.1 Introduction 17
2.2 Time frame of the chart 18
2.3 Types of charts 20
2.3.1 Bar chart 20
2.3.2 Line chart 20
2.3.3 Point and figure chart 21
viii Contents

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

3 Classical reversal and continuation patterns 44


3.1 Introduction 44
3.2 Reversal patterns 44
3.2.1 Head and Shoulders 45
3.2.2 Double Top and Bottom 48
3.2.3 Triple Tops and Bottoms 50
3.2.4 Saucers and spikes 51
3.3 Continuation patterns 52
3.3.1 Triangles 53
3.3.2 Flags and pennants 56
3.3.3 Wedges 57
3.4 Gaps 59
3.4.1 Breakaway Gaps 59
3.4.2 Runaway Gaps 59
3.4.3 Exhaustion Gaps 61
3.4.4 Island Reversals 61
3.4.5 Case studies: combining Gaps with other
patterns 63
3.5 Key takeaways 65

4 Candlesticks patterns and their use in trading strategies 67


4.1 Introduction 67
4.2 Concept of candlesticks 68
4.2.1 Long candlesticks 70
4.2.2 Short candlesticks 70
Contents ix

4.2.3 Doji candlesticks 71


4.2.4 Long upper shadows only 71
4.2.5 Long lower shadows only 71
4.2.6 Candles with both long upper and lower
shadows 71
4.3 Reversal patterns 73
4.3.1 Hanging Man and Hammer 73
4.3.2 Engulfing pattern (tsutsumi) 75
4.3.3 Dark cloud cover (kabuse) 76
4.3.4 Piercing line (kirikorni) 79
4.3.5 Evening Star and Morning Star 80
4.3.6 The Three Black Crows and the Three Advancing
White Soldiers 82
4.3.7 Harami pattern 82
4.3.8 Tweezers tops and bottoms 86
4.3.9 Belt Hold lines (yorikiri) 86
4.3.10 Three Mountains and Three Rivers 86
4.4 Continuation patterns 88
4.4.1 Windows 88
4.4.2 Bullish Rising Three Methods and the Bearish
Falling Three Methods 88
4.4.3 Separating lines 90
4.5 Key takeaways 92

5 Moving averages and their use for trading strategies 94


5.1 Introduction 94
5.2 Concept of moving averages 95
5.2.1 Types of moving averages 97
5.2.2 Choice of period 102
5.3 Using moving averages to understand the trend, support
and resistance 104
5.3.1 Which moving averages to use? 105
5.4 Crossover technique 106
5.4.1 Double crossover 106
5.4.2 Triple crossover technique 108
5.5 Case studies: using moving averages for trading 109
5.6 Key takeaways 111

6 Momentum indicators and stochastics 113


6.1 Introduction 113
6.2 Momentum and Rate of change 114
6.3 RSI 119
x Contents

6.4 MACD 122


6.5 Stochastics 124
6.6 HA Stochastic 125
6.7 Case studies: framing trading strategies with momentum
indicators 127
A. State Bank of India 127
B. Nifty 50 128
6.8 Key takeaways 133

7 Volatility and volume indicators 135


7.1 Introduction 135
7.2 Volatility indicators 137
7.2.1 Moving average envelopes 137
7.2.2 Bollinger Bands® 138
7.2.3 ATR 141
7.3 Volume-based indicators 143
7.3.1 Volume oscillators 143
7.3.2 The Chaikin Money Flow Index 144
7.4 Case studies: using volatility indicators for trading
decisions 146
A. Reliance industries 146
B. Nifty 50 147
7.5 Key takeaways 148

8 Elliott Wave Principles 150


8.1 Introduction 150
8.1.1 What is a ‘wave’? 151
8.2 The Fibonacci sequence 151
8.2.1 The golden ratio 151
8.3 Understanding impulse patterns 151
8.3.1 Rules of impulse patterns 152
8.3.2 Understanding degrees 154
8.3.3 Variations to the impulse pattern 154
8.4 Corrective waves 160
8.4.1 Zigzag correction (5–3–5) 160
8.4.2 Flat correction pattern 164
8.4.3 Triangle 170
8.4.4 Diametric pattern: new patterns discovered by
Glenn Neely (1995) of NEoWave 173
8.5 Channelling 179
8.6 Key takeaways 183
Contents xi

9 Time cycles 185


9.1 Introduction 185
9.2 Characteristic of cycles 186
9.2.1 Period 187
9.2.2 Amplitude 187
9.2.3 Phase 187
9.3 Left and right translation 187
9.4 Principles of cycles 188
9.4.1 Principle of summation 188
9.4.2 Principle of harmonicity 188
9.4.3 Principle of synchronicity 188
9.4.4 Principle of nominality 188
9.4.5 Principle of variation 189
9.4.6 Principle of proportionality 189
9.4.7 Principle of commonality 189
9.5 Detecting the cycles 190
9.5.1 Observational analysis 190
9.5.2 Selecting oscillator indicator parameters 192
9.5.3 Detrending for cycle identification 192
9.5.4 Envelopes 194
9.6 Combining time cycles with an Elliott Wave 196
9.7 Key takeaways 202

10 Introduction to backtesting and algorithmic trading 203


10.1 Introduction 203
10.2 Concept of algorithmic trading 204
10.3 Using Excel for algorithmic trading 207
10.3.1 Getting data for backtesting and live signal
generation 207
10.3.2 Basic Excel functions to know 207
10.3.3 Coding trading strategies 210
10.4 Introduction to Python 221
10.4.1 Basics in Python 222
10.4.2 Using Python for backtesting 229
10.5 Key takeaways 244

11 Conclusion 246

References254
Index260
FIGURES

2.1 GBP/USD movement, 2015–2019 (monthly chart). Created


with Eikon, Refinitiv 19
2.2 GBP/USD movement, 2019 (daily chart). Created with
Eikon, Refinitiv 19
2.3 Construction of a bar 20
2.4 Line chart of GBP/USD. Created with Eikon, Refinitiv21
2.5 Construction of candlesticks 23
2.6 Candlesticks chart of GBP/USD. Created with Eikon, Refinitiv 25
2.7 Heiken Ashi candlesticks chart of GBP/USD. Created with
Eikon, Refinitiv 26
2.8 Drawing the trend line 30
2.9 Tentative and valid trend line 31
2.10 Support and resistance 33
2.11 Support and resistance trend line in the Nifty (daily chart).
Created with Amibroker 33
2.12 Role reversal of support and resistances 34
2.13 Fan principle 35
2.14 Channel line 36
2.15 Channels in the Nifty (hourly chart). Created with Amibroker 36
2.16 DJIA daily chart analysis. Created with Amibroker 37
2.17 Fibonacci retracements on a Nifty daily chart. Created
with Amibroker 38
2.18 Bar technique on Altria Group Inc. daily chart. Created
with Amibroker 39
2.19 Analysis of crude oil futures in INR (continuous contract;
weekly chart). Created with Amibroker41
2.20 DJIA (daily chart). Created with Amibroker 41
Figures xiii

3.1 Head and Shoulders pattern 45


3.2 Head and Shoulder pattern on the Nifty (hourly chart). Created
with Amibroker 46
3.3 Inverse Head and Shoulder pattern on MCX crude oil (weekly
chart). Created with Amibroker 47
3.4 Inverse Head and Shoulder pattern on Alcoa Corp (weekly
chart). Created with Amibroker 48
3.5 Double Top pattern 49
3.6 Double Bottom formation on MMM (daily chart). Created
with Amibroker 49
3.7 Triple Top pattern 50
3.8 Triple Bottom pattern on EUR/USD (weekly chart). Created
with Amibroker 51
3.9 Saucer 52
3.10 Inverse ‘V’ spike at market top 52
3.11 Continuation pattern: Symmetrical Triangle 53
3.12 Ascending Triangle 54
3.13 Descending Triangle 54
3.14 Symmetrical Triangle pattern on USD/INR (daily chart).
Created with Amibroker 55
3.15 Descending Triangle pattern on the DJIA (daily chart). Created
with Amibroker 55
3.16 Continuation pattern: flags 56
3.17 Continuation pattern: pennants 56
3.18 Wedge 57
3.19 Wedge pattern on the Nifty Index (daily chart). Created with
Amibroker58
3.20 Flag, pennants, and wedge on the DJIA (daily chart). Created
with Amibroker 58
3.21 Breakaway Gap 60
3.22 Runaway Gap 60
3.23 Island Reversal 61
3.24 Runaway Gap, Exhaustion Gap, Island Reversal,
and Breakaway Gap 62
3.25 Gaps on Facebook (daily chart). Created with Amibroker 63
3.26 Gap, wedge, and flag on the Nifty (daily chart). Created
with Amibroker 64
3.27 Analysis of channels and gaps on Apple Inc. (daily chart).
Created with Amibroker 65
4.1 Candlesticks: the anatomy 68
4.2a Long-body candles 69
4.2b Marubozu candles 70
4.3 Short candlesticks (spinning tops) 71
4.4 Doji candlesticks 72
xiv Figures

4.5 Candles with long shadows 72


4.6 Doji on the Nifty (hourly chart). Created with Eikon, Refinitiv 73
4.7 Hammer and Hanging Man 75
4.8 Hanging Man and Hammer on EUR (weekly chart). Created
with Eikon, Refinitiv 75
4.9 Engulfing pattern 76
4.10 Bearish engulfing on HDFC Ltd. Created with Amibroker 77
4.11 Bullish engulfing on HDFC Bank. Created with Amibroker 77
4.12 Bullish and bearish engulfing on the Nifty (daily chart). Created
with Eikon, Refinitiv 78
4.13 Dark cloud cover 78
4.14 Piercing line 79
4.15 Piercing line on Hindustan Zinc (daily chart). Created with
Amibroker79
4.16 Evening Star 80
4.17 Morning Star 80
4.18 Evening Star on the Nifty (daily chart). Created with
Eikon, Refinitiv 81
4.19 Morning Star on AUD (daily chart). Created with Eikon, Refinitiv 82
4.20 Three Black Crows 83
4.21 Three White Soldiers 83
4.22 Three White Soldiers on Raymond. Created with Amibroker 84
4.23 Three Black Crows on Raymond. Created with Amibroker 84
4.24 Harami pattern on CAD. Created with Eikon, Refinitiv 85
4.25 Bearish Harami on Maruti. Created with Amibroker 85
4.26 Tweezers tops and bottoms 86
4.27 Belt Hold: bullish and bearish 87
4.28 Bullish Belt Hold and Evening Star on GBP (daily chart).
Created with Eikon, Refinitiv 87
4.29 Three Mountain Tops on GBP (weekly chart). Created with
Eikon, Refinitiv 87
4.30 Tasuki gaps 89
4.31 Rising Three Methods 89
4.32 Rising Three Methods on GBP (daily chart). Created with
Eikon, Refinitiv 90
4.33 Falling Three Methods 91
4.34 Separating lines 91
4.35 Separating lines on GBP (weekly chart). Created with
Eikon, Refinitiv 92
5.1a 30-period moving average on the Euro. Created with
Eikon, Refinitiv 96
5.1b 30- and 60-period moving averages on the Euro. Created with
Eikon, Refinitiv 96
5.2 SMA and EMA on the Euro. Created with Eikon, Refinitiv 99
Figures xv

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

  2.1 Price data for point and figure chart 22


  2.2 Intra-day point and figure (reversal size = 2) 22
  2.3 Intra-day point and figure (reversal = 1) 22
  2.4 Calculation of Heiken Ashi candlestick values 24
  5.1 Calculation of three-period moving average 95
  5.2 Calculation of SMA, EMA, and LWMA 97
  5.3 Calculation of KAMA 100
  5.4 Calculation of centred moving average 103
  6.1 Comparison of prices with three-period moving average and
momentum115
10.1 Relative references and absolute references 208
10.2 Data arrangement in Excel sheet ‘Ch10_2’ 210
10.3 Calculation of the average, SMA, and EMA 211
10.4 EMA 10, 20, and the double crossover signal 213
10.5 Transaction prices and returns 214
10.6 Performance metrics of double crossover signals 1 and 2 215
10.7 RSI calculation 216
10.8 Entry and transactions prices 217
10.9 ATR calculation 218
10.10 Calculation of take-profit and stop-loss levels 219
10.11 Calculation of trade running, profit-target hit, and stop-loss hit 219
10.12 Calculation of exit and profit/loss percentage in Excel 219
10.13 Calculation of performance metrics in Excel 220
10.14 Evaluation of the trading strategy 220
10.15 Operators in Python (in ascending order of precedence) 223
ABBREVIATIONS

AMA Adaptive moving average


ATR Average true range
AUD Australian dollar
CAD Canadian dollar
CMA Centred moving average
DJIA Dow Jones Industrial Average
EMA Exponential moving average
ETF Exchange-traded fund
EUR Euro
GBP Great Britain pound
HA Heiken Ashi
HASTOC Heiken Ashi Stochastic
IDE Integrated Development Environment
INR Indian rupee
LWMA Linearly weighted moving average
MACD Moving average convergence divergence
NSE National Stock Exchange
NZD New Zealand dollar
ROC Rate of Change
RSI Relative Strength Index
SMA Simple moving average
USD United States dollar
XLB Materials Select Sector SPDR
XLF Financial Select Sector SPDR Fund
XLP Consumer Staples Select Sect. SPDR
XLV Health Care SPDR
XLY Consumer Discretionary SPDR
PREFACE

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.

Structure of the book and resources


Technical analysis is a myriad collection of approaches to predict the future move-
ment in asset prices given the historical movement. We have structured the book
keeping in view this comprehensive approach to technical analysis. Again, the con-
cepts by themselves are not useful without case studies on their application. We
therefore strengthened the conceptual discussion with recent studies, also covering
the market movement in 2020 post the pandemic.
Chapter 1 sets the tone for the book by introducing the readers to a compre-
hensive view of the technical analysis paradigm. It places technical analysis in the
broader framework of trading in financial markets, presenting the rich empiri-
cal evidence on the use of technical analysis by professionals and research on the
profitability of technical analysis. The chapter also discusses the financial market
infrastructure required for trading and compares trading paths: fundamental and
technical analysis.
Chapter 2 takes up the building blocks of technical analysis with an understand-
ing of Dow Theory, the essential foundation on which the different approaches of
technical analysis rests. Technical analysis is based on the understanding of trends,
as the identification of reversals lies at the core of technical analysis. The chapter
xxii Preface

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.

Smita Roy Trivedi


I thank my institute, National Institute of Bank Management (NIBM), Pune,
which enabled an academic to develop a passion for and expertise in technical
analysis. I am grateful to Rajiv Abhyankar, former chief general manager, Bank of
Baroda, for his wonderful advice on the manuscript and detailed feedback on select
chapters. In writing the book, I have kept in mind my students at NIBM and the
professional dealers whose ideas, queries, and suggestions have shaped the structure
and flow of the book. I thank them for the continuous feedback and suggestions.
I thank my colleagues at NIBM who motivate me to lean in every day.
I owe greatly to the support of my spouse, Akshoy Trivedi, and daughter, Ashmi:
they are the ‘wind beneath my wings’. Through the demanding months of writing
of this book, it is their unwavering support, understanding and constant encour-
agement that sustained me. Thanks to Akshoy for sharing more than equal house-
hold responsibilities which enabled me to focus on the book. His keen feedback on
my writing, as also invaluable suggestions on the presentation is hugely appreciated.
Ashmi is our blessing and inspiration. Her thoughts and values make me see
the world anew each day. Discussing technical analysis with her and her witty
comments made the writing process easier than it would have been. Our family is
completed by two irrepressible canines: Momo, who appreciates books, and Popo,
who does not. Their lovable presence fills each day with the little joys that makes
writing enjoyable.
I will be always indebted to my mother, Subhra Roy, who passed away dur-
ing the writing of the book. To say she was a constant source of inspiration and
encouragement is an understatement. I am grateful for the presence of my father,
RN Roy, in our lives and his encouragement. Ma was, as always, excited about this
book making to print. I dedicate the book to her fond remembrance.
Acknowledgements xxvii

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

The Only Game in Town.


– Mohamed A. El-Erian1

1.1 Technical analysis and trading in the financial


markets
What is your game? The fascination of our times with the financial markets and
efforts to ‘beat the market’ makes trading no less than an adrenalin-pumping sport.
Trading is a game, played solo with the rest of the market! And technical analysis is
the much-needed skill to win consistently in the game of trading.
At the core of trading is the idea that assets are not valued correctly which makes
it possible to buy an undervalued asset (sell an overvalued one) and thereby reap
gains from the price rise (fall). If markets always determined the true value of a
security, as markets would do if they were ‘efficient’, it would be impossible to ‘beat
the markets’. However, the efficiency paradigm of the financial markets has largely
been questioned (Thaler, 2015), and astute traders know that while we cannot be
right in our valuation every time and ‘beat the market’, it is possible, with the right
strategy, to outwit the market and make profits.
Technical analysis is one of the essential strategies, which when rightly used,
can help traders to make profits and win in the trading game. The fascination
with technical analysis as a skill set for trading in markets is reflected in not only
the growing literature on technical analysis but also the copious advice that pours
through blogs and forums to traders. This book is all about using technical analysis
effectively to make our mark in trading.
What is technical analysis? Technical analysis encompasses several loosely held
paradigms, all of which are based on the analysis of a financial asset’s price and
volume data to predict its future movement. Depending on the technical analysis
2 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.

1.2 Evidence on the use of technical analysis


If you are a novice to trading or a student, you may have googled the term tech-
nical analysis and been flummoxed at the number of web resources available on
the subject: from books and articles to blogs, forums, and websites. If you are a
trader (retail or institutional), you must have had countless strategies discussed
and shared by peers on technical trading. And you know that technical analysis is
incredibly popular amongst traders, which is presumably also the reason you are
reading this book.
Is there a fascination that professional traders have for technical analysis? Yes
indeed, technical analysis remains an ‘obstinate passion’ (Menkhoff and Taylor,
2007) for trading professionals. One of the most intriguing areas of mainstream
finance is that this popularity of technical analyses among practitioners is despite
technical analysis not being anchored to any underlying economic or financial
theory (Hsu, Taylor, and Wang, 2016).
How important is technical analysis to traders? Allen and Taylor (1990) pre-
sented some of the earliest evidence on the use of technical analysis by profes-
sionals, in this case chief forex dealers in the London market. The paper showed
that chartism, or use of technical charts by market participants for forecasting,
dominated the short-term horizon predictions. Of respondents, 90% used charts
for forecasts for the short-term (intra-day to one-week) horizon. While for long-
term (one- and three-month) forecasts, the inclination to use fundamental analysis
increased, only 30% of respondents were depending ‘on pure fundamentals’. The
paper presented compelling evidence of the complementarity between technical
and fundamental analysis in the minds of traders.
While the evidence on the use of technical analysis brought forth interest in
why technical analysis can work, to which we will come later on, a series of studies
followed, lending support to the extensive use of technical analysis amongst traders
(Menkhoff and Taylor, 2007, 2010; Cheung, Chinn, and Marsh, 2004, Cheung
and Chinn, 2001; Oberlechner, 2001; Cheung and Wong, 2000; Hsu et al., 2016).
Cheung and Chinn (2001) reported that, in a survey of US dealers, technical trad-
ing best describes 30% of trading behaviour, a slightly greater proportion than
that attributed to fundamental analysis (25%), followed by customer-order-driven
(22%) or ‘jobbing’2 (23%).
Gehrig and Menkhoff (2006), in a survey covering forex dealers and fund man-
agers, showed that technical analysis has gained traction over time, being most
important in forex dealing and second in fund management. The recent evidence
on the use of technical analysis suggests that this trend has continued. Menkhoff
(2010) shows in a survey of 692 fund managers in five countries that not only do a
4 Introduction to technical analysis

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.

1.3 Technical analysis profitability and the efficient


market paradigm
The extensive evidence on the use of technical trading by professionals is not sur-
prising given the compelling evidence for the profitability of technical analysis. In
one of the major empirical studies on profitability of technical analysis indicators,
Brock, Lakonishok, and LeBaron (1992) showed, using technical analysis based on
filter techniques, that profit can be generated substantially in excess of buy-and-
hold returns. Other studies confirmed that technical analysis served as an important
tool in the hands of market practitioners in enabling effective trading decisions
(Pinches, 1970; Menkhoff and Taylor, 2007; Surajaras and Sweeney, 1992; Menk-
hoff and Schlumberger, 1995; Neely, Weller, and Dittmar, 1997; LeBaron, 1999;
Saacke, 2002). In a recent study, Hsu et al. (2016) used daily data from over 45 years
for 30 developed and emerging market currencies to examine the profitability of
more than 21,000 technical trading rules in the foreign exchange market. They
Introduction to technical analysis 5

find evidence of substantial predictability and excess profitability in both developed


and emerging currencies when measured against a variety of performance metrics.
The evidence on the profitability of technical analysis challenges the basis of the
EMH. Are financial markets efficient? The debate over the efficient market para-
digm is one of the most interesting deliberations in financial economics. The seeds
of efficiency paradigm were sown in Paul Samuelson’s analysis of random walk in
1965, but it is Fama’s seminal paper in 1970 which formalized the paradigm with its
theoretical and empirical evidence, iterating that the efficient market model, ‘but
with a few exceptions[,] . . . stands up well’ (Fama, 1970). In Fama’s construct,
an efficient market is a market in which prices always ‘fully reflect’ all available
information.
However, as evidence on stock market anomalies grew (Dimson and Mussavian,
1998), it became hard to believe that the anomalies are exceptions and prices do
indeed reflect ‘all information’. Soon the evidence on long-term mispricing in
equity markets, one of the strongest coming from De Bondt and Thaler in 1985,
challenged the core of the efficient market hypothesis. While the debate on the
efficiency of financial markets has continued for almost half a century now (see
the discussion in Fama and Thaler, 2016), stock market bubbles noted in the last
20 years add weight to the fact that stock prices do indeed ‘diverge to a significant
degree from their intrinsic value’ (Thaler, 2014).
If markets are efficient, prices at any given point of time, correctly estimate the
intrinsic value of an asset based on all information available till that point in time. If,
with new information coming, the changes in prices behave in a random manner
or are distributed independently as a random variable (Pinches, 1970; Meese and
Rogoff, 1983), the forecasting of future prices is largely ruled out. With random
walk holding in the financial markets, any technical analysis strategy cannot out-
perform a buy-and-hold strategy. Indeed, if markets are fully efficient, technical
analysis would be redundant. The evidence on the financial market being far from
efficient and the profitability of technical analysis may indeed be deeply connected.

1.4 What explains the profitability of technical analysis?3


What lies behind this evidence on the profitability of technical analysis? Menk-
hoff and Taylor (2007) point to the belief among traders that technical analysis
can represent changes in market psychology and provide information about ‘non-
fundamental influence’. If fundamental factors cannot reflect changes or swings in
sentiment, prices will not reflect all information. Prices may be overreacting or
underreacting to new information in the market. Gehrig and Menkhoff (2006)
show that market participants using technical trading are more concerned and
indeed better versed with the psychological influences that dominate the foreign
exchange market. Technical analysis is able to address these psychological forces
providing value to traders and investors.
Furthermore, financial markets may be characterized by limited arbitrage which
can explain why prices ‘diverge far from fundamental value’ (Shleifer and Vishny,
6 Introduction to technical analysis

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.

1.5 Financial markets: the trader’s playground

1.5.1 Functions of financial markets


Before we take up the core of technical trading, let us briefly consider the trading
infrastructure in financial markets. An understanding of this infrastructure is essen-
tial before we can effectively apply the technical analysis skill. Financial markets are
the trader’s playground. It is where traders can test their skills against others to make
profits. In this section, we take you through the maze of markets, picking up pieces
to have a comprehensive view of the trading infrastructure of financial markets.
We focus here only on those aspects of financial market infrastructure essential for
understanding trading, as a comprehensive discussion on financial markets is out-
side the purview of this book.
Financial markets are where financial assets trade. They exist to enable the
smooth flow of financial capital5 between those who save and those who need
access to financial capital. Financial intermediation is one of the crucial pro-
ductive activities in an economy by which funds are channelled from lenders
to borrowers. Financial intermediation involves an institutional unit incurring
liabilities on its own account for the purpose of acquiring financial assets by
engaging in financial transactions on the market (OECD, 2019). Economic liter-
ature supports a strong positive correlation between long-run economic growth
and financial intermediation as also between long-run growth and stock market
development (Levine, 2005; Demirgüç-Kunt and Levine, 1995; Levine and Zer-
vos, 1996).

What do financial markets do?


Mobilization of savings: Mobilization or pooling of savings is the most crucial
function of financial intermediaries (Levine, 2005). Intermediaries perform the
costly task of pooling the savings of diverse savers for investment. To ensure sav-
ers are interested in the process, transaction costs must be low, and contractual
arrangements should exist to reinforce the trust of savers in the intermediary. Thus,
mobilization may involve multiple bilateral contracts between productive units rais-
ing capital and agents with surplus funds. The joint-stock company (where many
individuals invest in a new legal entity, the firm) represents a prime example of
multiple bilateral mobilizations (Levine, Ibid).
Reducing the cost of external finance to firms: Financial intermediaries reduce
the cost of external finance to firms. It is not surprising, therefore, that industrial
sectors requiring external finance develop disproportionately faster in countries
with more-developed financial markets (Rajan and Zingales, 1998).
8 Introduction to technical analysis

Provision of information: Information provision and production are important


functions of intermediaries. Financial intermediaries affect economic growth by
lowering information costs and sifting capital towards more efficient investment
opportunities. Intermediaries play an important role in collecting and analysing
information which, in turn, facilitate the transfer of funds to the areas of highest
social return (Greenwood and Jovanovic, 1990). Financial intermediaries, includ-
ing credit bureaus, financial newspapers, check guarantee services, investment
bankers, and accounting firms, are created to produce information on firms and
sell this information to savers (Ramakrishnan and Thakor, 1984).
Provision of liquidity: Financial intermediaries help individuals to reduce the
risk associated with their liquidity needs (Bencivenga and Smith, 1991). Finan-
cial intermediation prevents the misallocations of invested capital due to liquidity
needs.

1.5.2 Types of financial markets


Finance thus acts as the lubricant for the rest of the economy, and financial mar-
kets offer the playground for the valuation of financial assets. These financial assets
include stocks (equity), bonds (debt), commodities, currencies, and derivatives.
While the microstructures of the different financial markets differ, they share cer-
tain characteristics with reference to trading. Broadly, financial markets are catego-
rized into the following types:

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).

BOX 1.1 TYPES AND CHARACTERISTICS OF


EQUITY SECURITIES

Common stock/ordinary shares represent the final residual claims on assets on


liquidation. Common stockholders have voting rights and receive dividends.
Preference shares (or preferred stocks) rank above common shares for
payment of dividends and the distribution of the company’s net assets if liq-
uidated. However, unless specifically allowed at issuance, preference share-
holders may not have any voting rights.
Equity shares with deferential rights are issued with disproportionate
rights with regard to crucial issues, including voting and dividends.
Private equity securities are equity securities issued via non-public offer-
ings or private placements to select entities and therefore are not listed on
public exchanges.

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).

BOX 1.2 FOREX QUOTE

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

Brokers and dealers


The distinction between brokers and dealers is a crucial one. While foreign
exchange markets have both dealers and brokers, the equity market is a broker-
driven market.
Brokers are agents who fill orders for their clients by bringing together buyers
and sellers. However, they do not trade with their clients or take positions them-
selves. Brokers try to find counterparties who would take the other side of their
clients’ orders, which reduces the client’s costs of finding counterparties for trading
(Fuhrmann and Lamba, 2011).
Dealers act as counterparties to their clients (Fuhrmann and Lamba, Ibid). Deal-
ers thus provide liquidity to the market by trading with their clients and taking
positions on their own books. Dealers try to reverse the positions taken for provid-
ing clients with liquidity by trading with another client on the other side of the
market. Profits are made when they buy at prices that on average are lower than
the prices at which they sell. Thus, dealers provide liquidity by connecting buyers
and sellers who have come to the financial market at different points in time while
brokers connect buyers and sellers at the same point in time.
While dealers can act as brokers and brokers can deal with their clients (broker–
dealer), a conflict of interest arises with respect to how they fill their customers’
orders. Brokers should try to get the best price for their customers’ orders, that
is the lowest price for a buy order and highest for a sell order. However, a dealer
would want the highest buy price while selling to their clients and the lowest sell
price for buying from their clients. A special category of dealers is primary deal-
ers, with whom central banks trade (in bills, notes, and bonds) when conducting
monetary policy.

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).

BOX 1.3 MACROECONOMIC NEWS


ANNOUNCEMENTS AND FINANCIAL MARKET
VOLATILITY

Bid–ask spreads are seen as indicators of market volatility in economic litera-


ture. Macroeconomic announcements have the greatest impact on market
volatility (in the form of the bid–ask spreads) in the shortest time frames
(Fleming and Remolona, 1999). In microstructure theory, bid–ask spreads
represent inventory carrying costs, order-processing costs, and asymmet-
ric information costs (Bessembinder, 1994). Inventory carrying costs arise
because the act of market 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 (Bessembinder, Ibid).
14 Introduction to technical analysis

Asymmetric information reflects the widening of spreads as participants face


more ‘informed’ traders. The presence of a more informed trader with insider
information will lead to a rise in bid–ask spreads by existing participants to
protect against the lack of information (Fleming and Remolona, 1999). The
order-processing costs reflect the time and money spent in processing a trade,
including trading, clearing and settlements fees, and back-office costs, typi-
cally small in foreign exchange markets (Galati, 2000).

Execution instructions may also specify conditions on size. All-or-nothing


orders can only trade if their entire size offered for trade can be traded. Traders can
similarly specify minimum-fill sizes (minimum-fill orders).
Exposure instructions tell the broker whether and to what extent the order’s
details would be exposed to the counterparty. Hidden orders are not known to
counterparties (but exposed to the brokers or exchanges that fill the order). Hid-
den orders are used when traders are in the market with a big volume and want
the information to be hidden from counterparties, as it is possible that the market
may move against them if the size of the order is known to counterparties. Iceberg
orders (or display-specific size) have a specific portion displayed to the counterparty.

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

immediately available. As it happens with the market order, there is no certainty


for the trader of getting that particular price. If the trader is not willing to accept
a buy or sell order at a price above or below a certain limit, a limit order may be
put with the stop loss. In the preceding example, for the buy order, let us suppose
the limit is put at 111 and stop at 110. This tells the broker that above 110, the
buy–stop-loss order is activated, and therefore, the broker should try to get the best
possible buy price but not exceeding 111. Similarly, for the sell order, the limit is
put at 97 and stop loss at 98. This tells the broker that below 98, the sell–stop-loss
order is activated; therefore, the broker should try to get the best possible buy price
but not less than 97.

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:

First, market action incorporates all information or discounts everything. As


underlined by technical analysts, the idea that market action represents every
possible information about a security is the most important notion in tech-
nical analysis. It is the cornerstone of technical analysis. What it says is that
anything which can impact prices, fundamentally or otherwise, is reflected
in the way the price moves in the market along with the change in volume.
This implies that for understanding the market or factors behind market
movement, it is enough to study the price and volume. Price and volume
movements represent intrinsic changes in demand and supply which work
behind the price action so that, as John Murphy (1999) says, the technical
analysts is indirectly studying fundamentals.
18 Basic principles of technical analysis

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.

2.2 Time frame of the chart


The period that the chart is looking at is one of the most important things that the
technical analysts must consider. For example, a price movement that looks like an
uptrend or downtrend in a daily framework may be part of a correction or consoli-
dation when we see the movement over a longer period, say, in the monthly chart.
Therefore, the first thing that needs to be considered when we look at charts is a
time frame they are representing.
The importance of time frame cannot be over-emphasized when we talk about
trend and price movements. Figure 2.1 and Figure 2.2 clarify this important point
for the GBP/USD pair. As you can see, Figure 2.1 shows the chart movement on a
Basic principles of technical analysis 19

FIGURE 2.1 GBP/USD movement, 2015–2019 (monthly chart). Created with Eikon,


Refinitiv

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.

FIGURE 2.3 Construction of a bar


Source: Author
Basic principles of technical analysis 21

FIGURE 2.4 Line chart of GBP/USD. Created with Eikon, Refinitiv

2.3.3 Point and figure chart


Point and figure charts show the market action in a condensed manner with
‘X’ columns showing rising prices and ‘O’ columns reflecting declining prices.
Thus, a continuous column of ‘X’ reflects prices have increased over that entire
duration of time as reflected by the column height. A column of Os similarly
reflects declining prices. Each chart has a setting called the box size, which
defines the price range for each box. When would we move from an X to an
O column? This is determined by the reversal amount. The reversal amount
determines the amount that market has to move in the opposite direction to
allow the plotting of a new X or O. Table 2.1 gives price data for two days, and
Tables 2.2 and 2.3 shows the intra-day point and figure plotting for two dif-
ferent reversal sizes for the said price data. Whenever the reversal threshold is
crossed, a new column is started right next to the previous one, only moving in
the opposite direction.
We see that, in the example given in Table 2.2, for the two days (19 and 20
January 2019), seven observations (prices) are given which are represented on the
point and figure chart without any reference to the time frame. As each box rep-
resents 0.05 (box size), a reversal of 2 means only move in prices equal to or more
than 0.05 * 2 = 0.1 will be recorded. The first price point is taken in the point and
figure chart as a dot in the box corresponding to 68.75, representing the starting
point. The next observation, 68.80 is the first observation recorded on the chart
as a cross. The next price point we see is 68.60. The box size is 0.05 and reversal
point is 2, so the move from 68.80 to 68.60 is a move down by two boxes; it is
represented by a series of Os down till the box corresponding to 68.60. The next
22 Basic principles of technical analysis

TABLE 2.1 Price data for point and figure chart

Date Prices

19/1/2019 68.75 68.80 68.60 68.65 68.50 68.60 68.55


20/1/2019 68.70 68.60 68.55 68.60 68.55 68.60 68.75
Source: Author.

TABLE 2.2 Intra-day point and figure (reversal size = 2)

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.

TABLE 2.3 Intra-day point and figure (reversal = 1)

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.

2.3.5 Heinken Ashi candlestick


A variant of the Japanese candlesticks, Heiken Ashi (HA) candlesticks have become
very popular in recent years. HA uses a form of averaging to smooth out the move-
ment in the market. As with the traditional candlestick pattern, HA also uses the
open, high, low, and close prices. However, in the HA candlesticks, this informa-
tion is reflected in a different way. The calculation formula (Kuepper, n.d.) for the
HA candle for any period is given as follows:

Close = (Open Price + High + Low +Close) / 4


Open = Average of Open Price and Close Price of the previous period 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)

FIGURE 2.5 Construction of candlesticks


Source: Author
TABLE 2.4 Calculation of Heiken Ashi candlestick values

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.6 Candlesticks chart of GBP/USD. Created with Eikon, Refinitiv


26 Basic principles of technical analysis

FIGURE 2.7 Heiken Ashi candlesticks chart of GBP/USD. Created with Eikon, Refinitiv

with regular candlesticks, there is no explicit identification of trend. When we


incorporate HA candlesticks, as seen in Figure 2.7, we can clearly define the trend
for major periods from the continuous black and white candles appearing. It must
be underlined that in the HA chart, a continued black or white candle pattern
would appear only when on the average prices are rising or falling.

2.4 Dow Theory and its application


Technical analysis owes its foundations to the writings of Charles Henry Dow, the
pioneering journalist who co-founded the first US index, the Dow Jones Averages.
Dow Theory is based loosely on his writings for the Wall Street Journal when he
was its editor (1889–1902). The columns which form the basis of Dow Theory as
we see today were identified by George D. Bishop in his 1960 work Charles H Dow
and the Dow Theory (Bishop, 1961; Dow, 2009).
Charles Dow (along with Edward Jones) started the DJIA. The first DJIA index
comprised the closing prices of 11 stocks, which Dow published on 3 July 1884. Dow,
working for the Customer’s Afternoon Letter, a daily financial news bulletin, ensured his
index reflected the rising industries of that era, the first stock market average com-
posed of nine railroad companies and two manufacturing firms. Later on, Dow cre-
ated a 12-stock industry and a 20-stock railroad index (Murphy, 1999; Dow, Ibid).

2.4.1 Basic tenets of technical analysis


The crux of Dow’s observations (Dow, 2009; Murphy, 1999) can be summed up as
presented in the following subsections.
Basic principles of technical analysis 27

2.4.1.1 Averages discount everything


The fact that averages discount everything is the very cornerstone of technical
analysis. Technical analysts believe everything that can influence prices is reflected
in market action. The market quickly assimilates all the information, including
that of new events, reflecting them in the price action. As all the factors impacting
any price movement are reflected in the charts, the charts would be showing us
whether these factors are going to take the market up or down or sideways. This
forms the basis for recognition of trends. However, charts, as we see it, often reflect
a zigzag movement. In other words, the market movement is always reflected
through a peak and trough progression. A trend therefore can be defined as the
period in which prices move in an irregular but persistent direction (Pring, 2014).
It is the general direction of the market that is reflected in the zigzag movement
across the chart.

2.4.1.2 The primary trend, secondary reaction,


and daily fluctuations
Following Dow, we generally identify three major trends in a market: the primary
trend lasting over a suitable longer period reflects the market perceptions towards
the fundamental factors. Generally, a period from over nine months to a year is
taken to be the long-term or primary trend in major markets. The intermediate
trend according to most technical analysts last from anything between two months
to less than a year and reflect the counter-cyclical trends that affect the primary
trend. Short-term trends covering a span of a month or a few months, at most,
reflect the immediate movement in the market as shaped by the short-term market
information.
It may be underlined here that any trend is applicable only with respect to a
particular time frame. What appears to be an uptrend in the short term, say, over
a month, may simply be a consolidation if the longer-term or yearly time frame is
seen. The trend in the longer time frame affects the character of the intermediate
and short-term trends as well.
Murphy (1999) presents the underpinnings behind the three distinct phases of
a trend: the accumulation phase, the public participation phase, and the distribu-
tion phase. Let us understand these concepts with the example of an uptrend. The
accumulation phase signifies the onset of a trend, whereby the astute or ‘informed’
investors have entered the market and are buying before other market partici-
pants, anticipating the bull movement. What makes these informed investors step
in to buy before others? The informed or astute investors have recognized that the
market has already assimilated the bad news of the previous phase and that there
is going to be a reversal from the downside to the upside. This forms the basis of
their buying decisions.
The public participation phase reflects the inclusion of trend-following trad-
ers in the buying spree (Murphy, 1999). Following the few astute investors who
28 Basic principles of technical analysis

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.

2.4.1.3. The averages must confirm


Charles Dow, when talking about averages, referred to the industrial and rail aver-
ages which formed his two major indexes (Murphy, 1999; Dow, 1990, as cited in
Dow and Sether, 2009). Dow iterated that no important uptrend or downtrend
could be in place unless both averages were giving the same signal, thereby con-
firming each other. It was not necessary that the signals happen simultaneously,
but the indication should be in a similar direction. For example, for an uptrend to
be confirmed, both the averages must exceed a previous peak. Divergences of the
indices signal that reversal may occur.
Dow recognized the volume as an important factor confirming price signals
(Dow, 1990, as cited in Dow and Sether, 2009). For price signals to be confirmed,
volume must expand in the direction of the major trend. This means that for an
uptrend to be confirmed, volumes should go up as prices move higher. However,
high volume in the later phases of a bull market indicates speculative fever, as much
as low volume in final stages of a bear market signified the lack of buying interest
(Dow, Ibid).
As will be seen later, volume going down while the market is moving up is the
major signal that the market may head for a trend reversal in the case of an uptrend.
Volumes play a vital role during an uptrend. With the up move, we need more and
more participation for a sustainable rise. Markets can fall due to a lack of buying as
well. So volume confirmation is more important on the upside. Nevertheless, if a
downtrend is associated with heavy volumes, it increases the bearish implications.
The technical analyst is interested in identifying this reversal before anyone in
the market does. In the preceding terms, it is the recognition of the trend reversal
before other market participants that can make a trader an astute trader. However,
this is often the most difficult task for a chartist, as it is often easy to confuse a
correction in an existing trend and the beginning of a new trend in the opposite
direction. Again, as reversal and continuation indicators are subjective, chartists
may differ on a reversal signal in a market.

2.4.2 Main criticisms of Dow Theory


A major criticism of Dow Theory is that it may miss 20% to 25% of a move before
generating a signal. In fact, as with any trend-following technical analysis indicator,
Basic principles of technical analysis 29

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.

2.5.2 Drawing trend lines


Drawing a trend line is one of the most subjective elements of technical analysis. As
trend analysis is a major principle of technical analysis, and traders very commonly
use trend-following indicators; it is very important to understand how to properly
draw a trend line.

2.5.2.1 Tentative trend line


The very first thing to note in the case of drawing a trend line is that there must be
at least two points giving evidence of a trend. As seen in Figure 2.8(a), the trend line
shows an uptrend, joining reaction lows or troughs at points A, B, and C. The trend
line in Figure 2.8(b) is invalid as it fails to touch the reaction lows. This means that in
an uptrend, we must get at least two reaction lows to connect, and for evidence of a
downtrend, we must get two reaction highs to connect. Trend lines cannot be drawn
30 Basic principles of technical analysis

FIGURE 2.8 Drawing the trend line


Source: Author

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.

2.5.2.2 Tentative and valid trend line


Very often while drawing a trend line, we realize that the first trend line drawn
has been overpowered by another trend appearing in the chart. For example, in
Basic principles of technical analysis 31

FIGURE 2.9 Tentative and valid trend line


Source: Author

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.

2.5.2.3 Including all prices


An important factor to consider when drawing a trend line is which prices to con-
sider. In bar charts and candlestick patterns, where both open and close prices, as
well as highs and lows, are given, it is to be decided which of these prices should
be taken while drawing the trend line. Some technical analysts prefer taking clos-
ing prices, since a close is considered more important than the intra-day highs and
lows. However, experts like John Murphy (1999) suggest that the trend line should
include all price action. It makes more sense to take the entire price action, as the
trend line becomes more representative of how the market movement has been for
that time frame.

2.5.2.4 Violation of the trend line


Traders often have their own viewpoints on what is a valid violation of the trend
line and therefore reversal. During any period, the original trend line may be vio-
lated, but the price will close within the trend by the end of the period. In such
cases, the trend line can be treated to be valid.
The decisions on understanding a valid trend-line break can be aided by taking
a filter. Traders use both price and time filters for judging intra-period penetra-
tions. In the first case, the trend line would be considered as violated if prices move
in the opposite direction for more than a certain percentage, say, for example,
3% or 5%. In the second case, the trade requires a two- or three-period move in
the other direction (without a re-enter into the trend line) for a confirmation.
32 Basic principles of technical analysis

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.

2.5.3 Support and resistance


The major building block of understanding trends is to recognize the support and
resistance patterns in the market. Pring (2014) refers to a support as representing
a concentration of demand while a resistance represents a concentration of supply.
Murphy (1999) defines support as a level or area on the chart under the market
where buying interest is sufficiently strong to overcome selling pressure. Resistance
represents a price-level area over the market, where selling pressure overcomes buy-
ing pressure so that a price advance is turned back.
As we can see the basic characteristics of a support is that it represents the power
of the bulls over the bears, as buying pressure has overcome selling pressure. What
does this imply? As underlined by Murphy (Ibid), when prices tend to rise from
a support area, the people who have bought in direction of the trend or the bulls,
are happy to perceive the movement in the direction of the trend. Those who have
missed the opportunity to capture this trend movement would wait patiently for
the dip back to the support level. As prices dip the next time, there would be an
increased buying pressure strong enough to overcome the selling pressure. A sup-
port is thus characterized by the reaction lows or troughs. On the other hand, the
resistance is marked by the strength of the bears over the bulls as selling pressure
overcomes buying pressure. It is characterized by market highs or peaks. To recog-
nize supports and resistances in the market, it is useful to remember that the previ-
ous peak or low frequently acts as a potential resistance or support. The dynamic
support and resistance are marked in Figure 2.10, and the dynamic support and
resistance on the Nifty3 are shown in Figure 2.11.

2.5.4 Potential support and resistance patterns


While deciding the support and resistance levels, it is good to remember that previ-
ous highs and lows are as important as resistances or supports. Market psychology
suggests when a previous high or low is reached, traders hold on to such levels.
A key reason for this is the perception centred on such levels.
The more time support and resistance hold, the greater importance they are
assigned to by the market. A support or resistance level tested many times and
still found to hold is likely to be more important than others are. Similarly, sup-
ports or resistances on a higher volume are more important than others (Lim,
2015).
Importantly, frequently support and resistance reverse roles (Murphy, 1999).
Look at Figure 2.12; the support holds for some time, and then as a break happens
in the downward direction in the next phase (marked by points A), the support
level acts as a resistance for the downtrend.
Basic principles of technical analysis 33

FIGURE 2.10 Support and resistance


Source: Author

FIGURE 2.11 Support and resistance trend line in the Nifty (daily chart). Created with
Amibroker
34 Basic principles of technical analysis

FIGURE 2.12 Role reversal of support and resistances


Source: Author

2.6 Use of trend analysis in trading


Any chart study begins with an understanding of what is the general direction of
the market or the trend. The concept of trend lines has several uses to the technical
analyst besides the understanding of trend reversal. The significance of a trend line
depends on two important factors: the number of times it has been touched (and
held valid) and the steepness of the line. The number of times a trend line has been
tested contributes to its importance and authority. However, sometimes, a trend
line that has been valid for a long time may also reverse its role. For example, an
uptrend line can act as the resistance for the downward movement in prices. Just
like the support and resistance, the trend line may also reverse roles. The slope of
the trend line must not be too steep or too flat. If it is too steep, the price rise or fall
may not be sustainable; if it is too flat, it may be a consolidation and not an upward
or downward movement. Usually, chartists prefer a 45-degree line as a trend line.
While market movement may not always lead to such a trend line, one should be
careful of a too steep or too flat trend line.
Let us look at two patterns which reinforce these basics in trend analysis, before
moving on the retracement of a trend.

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

FIGURE 2.13 Fan principle


Source: Author

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

FIGURE 2.14 Channel line


Source: Author

FIGURE 2.15 Channels in the Nifty (hourly chart). Created with Amibroker

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

FIGURE 2.16 DJIA daily chart analysis. Created with Amibroker

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:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610 . . .

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

FIGURE 2.17 Fibonacci retracements on a Nifty daily chart. Created with Amibroker


Basic principles of technical analysis 39

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

Trend analysis using the bar technique


In the following example, we use the outside and inside bar technique. The outside
bar is formed when the high and low of the day are above the high and below the
low of the previous day. The outside bar therefore engulfs one or more preceding
bars (Lim, 2015). The inside bar is formed when the high and the low of the day
are within the high and the low of the previous day. An inside bar indicates a pause
in the ongoing trend. Figure 2.18 shows Altria group stock price movement dur-
ing the period of January to early April 2019. As we can see from the chart, stock
prices showed movement between the support and the resistance trend line during
the period. An important observation is that during a strong uptrend, prices tend to
protect the lows of the prior day on closing basis. There has been a breach of prior

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.

Using retracements levels and trend lines to understand support


or resistance
Using retracements and trend-line levels as support or resistance can lead to help
in forecasting the market movement better. We use two examples to highlight
how charts can help us predict better price movement irrespective of sharp market
movements post any market shock. The recent pandemic has led to sharp move-
ments in most asset classes. However, the basics of chart analysis remain the same
as we will see here.
First, we take the example of crude oil futures in INR (continuous contract)
weekly chart, as shown in Figure 2.19. Prices topped out in October 2018, and
there was a sharp decline from the higher levels of 5669 to the low made on 28
December 2019 at 2993 levels. Post that, there was a retracement of the fall, and
prices moved towards the Fibonacci retracement level of 61.8%. This level acted as
a strong resistance three times, and prices eventually gave up in the second week of
January 2020. This coincided with the first death case reported due to a novel coro-
navirus in China on 11 January 2020. It is interesting to see a reversal in crude oil
prices from the Fibonacci retracement level of 61.8% and a sharp decline even before
the novel coronavirus was declared as an epidemic or a pandemic. This highlights
the importance of technical analysis and charts even during such an eventful period.
The lower trend line that was acting as support was later broken in Febru-
ary 2020. This same trend line acted as resistance that prices retested before starting
the decline again towards 1550 levels. As per Dow Theory, there is a clear lower
highs and lower lows formation that confirms the medium-term trend as negative
unless higher highs and higher lows are witnessed. A trader, by combining Dow
Theory with support and resistance trend lines and Fibonacci retracement levels,
can make an informed trading or investment decision even during a time of pan-
demic, such as the COVID-19 outbreak in 2020.
Second, we will take the example of the DJIA shown in Figure 2.20 to under-
line the robustness of basic trend analysis. As we can see, the DJIA shows a sharp
Basic principles of technical analysis 41

FIGURE 2.19 Analysisof crude oil futures in INR (continuous contract; weekly chart).
Created with Amibroker

FIGURE 2.20 DJIA (daily chart). Created with Amibroker


42 Basic principles of technical analysis

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

The clash of the cultures in investing: Complexity versus Simplicity.


– John C. Bogle1

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.

3.2.1 Head and Shoulders


Considered to be one of the most reliable of price patterns, Head and Shoulders
can appear both at tops and bottoms (Inverse Head and Shoulders), signifying trend
reversal to downtrend and uptrend, respectively. Figure 3.1 shows the classic Head
and Shoulders pattern. It consists of three rallies: the middle one being above the
other two so that the formation of a head with two shoulders appears on the chart.
Markets must be rallying or in an uptrend before the Head and Shoulders pattern
can signify a reversal. For example, in Figure 3.1, the rally creates a high as shown
by S in the figure and AB′ is the trend line drawn. Post this, prices make a new high
at H. Thereafter, as prices fall it breaks the existing trend line AB at C, giving the
first sign that a trend reversal may take place. Prices rise further to S′, fail to make
a new high, and make a high lower in height compared to H, giving the second
important signal that the reversal is going to happen as it forms a lower high. The
line DD’ is called the neckline.

FIGURE 3.1 Head and Shoulders pattern


Source: Author
46 Classical reversal & continuation 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.

3.2.2 Double Top and Bottom


The Double Top or Bottom is a very commonly observed reversal pattern. The
Double Top pattern is the culmination of an uptrend in two easily noticeable peaks
or rallies. As shown in Figure 3.5, initially prices rise and a rally is made at A on
high volume. Prices drop down to B, and then, when the new rally is made to
point C, it is in a significantly lower volume. The close below point D on much
higher volume confirms the reversal. Similarly, for a Double Bottom, the reversal
on the upside must be accompanied by significantly higher volumes. The Double
Top frequently looks like an M while the Double Bottom resembles a W. In the
case of a Double Top formation, the pattern target is derived by measuring the
Classical reversal & continuation patterns 49

FIGURE 3.5 Double Top pattern


Source: Author

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.

3.2.3 Triple Tops and Bottoms


Similar to the Double Top and Bottom formations, but the Triple Top or Bottom
formation is not often seen in markets, although it is easy to discern on a chart, as
shown in Figure 3.7 (Triple Top). The Triple Top and Bottom are often easily con-
fused with the Head and Shoulders Pattern if the head and shoulders are of similar
heights. It must be remembered that volume must be lower with each successive
peak or trough and the reversal must happen on significantly higher volumes. Pat-
tern targets are derived in a similar way to that of a Double Top or Double Bottom
formation. In the case of a Triple Top, the height of the peak is measured from the
lows of the pattern and projected on the downside from the neckline that connects
the lows of the pattern. For a Triple Bottom, the height of the trough is measured
from the high point of the pattern and projected on the upside from the neckline.
In Figure 3.8, the euro (EUR/USD) formed a Triple Bottom formation dur-
ing the period of 2015 to 2017. It is important to note that the three bottoms will

FIGURE 3.7 Triple Top pattern


Source: Author
Classical reversal & continuation patterns 51

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.

3.2.4 Saucers and spikes


Saucers are noted generally at the bottom when prices, over a considerable period,
follow a gradual turn from down to up. Saucers often take a long time to build up.
Spikes, on the other hand, happen very quickly and sharply in the market, with
the reversal on heavy volume, but are more difficult to spot. At market bottoms,
saucers will frequently look like flattened U-bottoms (see Figure 3.9). Spikes take
the appearance of sharp Vs in the chart. On a probable top, they take the appear-
ance of an upturned V as shown in Figure 3.10.
52 Classical reversal & continuation patterns

FIGURE 3.9 Saucer

Source: Author

FIGURE 3.10 Inverse ‘V’ spike at market top


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

FIGURE 3.11 Continuation pattern: Symmetrical Triangle


Source: Author
54 Classical reversal & continuation patterns

FIGURE 3.12 Ascending Triangle


Source: Author

FIGURE 3.13 Descending Triangle


Source: Author

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.14 Symmetrical Triangle pattern on USD/INR (daily chart). Created with


Amibroker

FIGURE 3.15 
Descending Triangle pattern on the DJIA (daily chart). Created with
Amibroker

thereby forming a Descending Triangle pattern. A conservative pattern target is


derived by measuring the widest leg of the triangle and projecting it on the upside
from the area where the last down move within the pattern was complete, as shown
in the figure. Prices confirmed the pattern completion after giving a breakout
above the upper trend line and moving towards the target level.
56 Classical reversal & continuation patterns

3.3.2 Flags and pennants


Flags and pennants represent other commonly seen continuation patterns. They
are short term price patterns. They represent brief pauses in market activity before
the prior trend is resumed. In the case of a flag, the sideways move happens either
in a downward or upward drifting rectangle, as shown in Figure 3.16. In the case
of a pennant, it is represented by a very small symmetrical triangle, as shown in
Figure 3.17. In an uptrend, flags generally have a slight downward slope, while in

FIGURE 3.16 Continuation pattern: flags


Source: Author

FIGURE 3.17 Continuation pattern: pennants


Source: Author
Classical reversal & continuation patterns 57

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

FIGURE 3.21 Breakaway Gap


Source: Author

FIGURE 3.22 Runaway Gap


Source: Author
Classical reversal & continuation patterns 61

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.23 Island Reversal


Source: Author
62 Classical reversal & continuation patterns

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.25 Gaps on Facebook (daily chart). Created with Amibroker

3.4.5 Case studies: combining Gaps with other patterns


One of the important applications of technical analysis comes from combining
analysis of different patterns on live charts. We use two examples in this section to
underline how such analysis can be used for trading decisions. The first example
uses the Nifty daily chart to show a combined analysis of gap, wedge, and flag pat-
terns. Figure 3.26 shows gap, wedge, and flag patterns on the Nifty chart. There
was a big gap area created during the period of May. This upper and lower end
of the gap normally acts as supports. The successive declines can be seen finding
support near the upper area of gap. Post that, there was a wedge formation with
converging trend lines on the upside. This wedge resulted in a temporary halt of
the down move, and a break below the same was a strong indication that the down-
trend was resuming. For a trader, a break below the lower trend line of the wedge
provided a very good opportunity to enter in the short direction. The breakout
from the wedge area resulted in a strong downtrend that filled the gap, and prices
found support near the lower end of the gap.
Prices after support near the lower gap area moved higher in a flag pattern.
Close below the lower trend line of the flag provided another opportunity for a
trade to be placed on the short side with the high of the flag as stop loss and the
conservative target. The target for a flag pattern is that prices will travel at least half
the size of the pole. The breakout below the flag resulted in achieving the con-
servative downside target.
64 Classical reversal & continuation patterns

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

Candlestick charts are unmatched in their capacity to be used alone or joined


with any other technical tool.
– Steve Nison1

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

FIGURE 4.1 Candlesticks: the anatomy


Source: Author
Candlesticks patterns 69

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.

FIGURE 4.2A Long-body candles


Source: Author
70 Candlesticks patterns

FIGURE 4.2B Marubozu candles


Source: Author

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

FIGURE 4.3 Short candlesticks (spinning tops)


Source: Author

after a prolonged uptrend or downtrend usually imply a change in the ongoing


trend but require confirmation. For example, the Shooting Star is a topping pat-
tern. The price action shows a small body and a long upper shadow.

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).

4.2.4 Long upper shadows only


Candlesticks with long upper shadows are more bearish than bullish, reflecting that
the bulls tried to take the price upwards but these gains were short-lived.

4.2.5 Long lower shadows only


Candlesticks with long lower shadows are more bullish than bearish, reflecting that
the bears tried to take the price downwards but price bounced back from those levels.

4.2.6 Candles with both long upper and lower shadows


Candles with both long upper and lower shadows reflect usually indecision in
the market as buyers and sellers have tried to move markets in both directions
and failed. It is important to consider what has been happening just before such a
candle to understand the implications for price movement. Figure 4.5 gives longer
candlesticks with shadows.
72 Candlesticks patterns

FIGURE 4.4 Doji candlesticks


Source: Author

FIGURE 4.5 Candles with long shadows


Source: Author
Candlesticks patterns 73

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.

4.3.1 Hanging Man and Hammer


Two of the most fascinating candlestick patterns are Hanging Man and Hammer
which are individual candlestick patterns and reflect bearish or bullish sentiments
74 Candlesticks patterns

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.7 Hammer and Hanging Man


Source: Author

FIGURE 4.8 Hanging Man and Hammer on EUR (weekly chart). Created with Eikon,
Refinitiv

4.3.2 Engulfing pattern (tsutsumi)


The engulfing pattern is a multiple candlestick pattern, and it represents reversal
signals. The Japanese word used to refer to the art of packaging is tsutsumi, a term
that literally means package and derives from a verb whose meaning is ‘to envelop’
(CandleScanner, 2020). Engulfing patterns may either be bullish or bearish and
are made up of two candlesticks. The bullish engulfing pattern will have the first
candle as a small black candle engulfed by the second white one. It is important that
the second candle covers the entire body of the first one. The bullish engulfing pat-
tern must come after a prior downtrend. A bearish engulfing pattern has the small
white candle as the first candle, which is overshadowed by the next black candle
76 Candlesticks patterns

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.

4.3.3 Dark cloud cover (kabuse)


This pattern implies bearish tendencies just like overcast conditions. It is a two-
tier reversal pattern, with the first day having a long white candle and the second

FIGURE 4.9 Engulfing pattern


Source: Author
Candlesticks patterns 77

FIGURE 4.10 Bearish engulfing on HDFC Ltd. Created with Amibroker

FIGURE 4.11 Bullish engulfing on HDFC Bank. Created with Amibroker

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

FIGURE 4.13 Dark cloud cover


Source: Author

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

4.3.4 Piercing line (kirikorni)


It is the opposite of dark cloud cover, representing a reversal to the upside. The
piercing line must have a long black candle followed by a long white candle as seen
in Figure 4.14. The piercing pattern thus consists of two candlesticks in a down-
trend. The first long black candle shows the strength of the bears in the market.
The second candle opens sharply lower to the first one’s low, reinforcing the bear-
ish tendencies. However, before long, the market picks up, penetrating well above
50% of the first candle’s black body. The second candle must close somewhat above
the midpoint of the previous day’s real body. Just as in the dark cloud cover, the
50% or more penetration is taken to be good confirmation of the bullish reversal.
It is interesting to note here that the piercing into the prior candle’s body is more
important for the piercing pattern than for the dark cloud cover. The white can-
dlestick must push more than halfway into the black candlestick’s real body (Nison,
1991). One thing that would help with appreciating this difference is that it usually
takes more strength to take the markets trend up than down. Figure 4.15 shows the
piercing line reversal for Hindustan Zinc.

FIGURE 4.14 Piercing line


Source: Author

FIGURE 4.15 Piercing line on Hindustan Zinc (daily chart). Created with Amibroker
80 Candlesticks patterns

4.3.5 Evening Star and Morning Star


The Evening and Morning Star patterns (Figures 4.16 and 4.17) represent reversals
on the downside and upside, respectively. The Evening Star has a long white candle
on the first day, which confirms the present uptrend. On the second day, prices must
open with a gap above the body of the first candle. The second candle is a small one
representing indecision in the market. On the third day, a black candle comes with
the opening of the gap below the body of the star and a close below the midpoint
of the first day. It represents a trend reversal to the downside. The Morning Star has
a long black candle on the first day, confirming the downtrend. On the second day,
prices must open with a gap below the body of the first candle. As in the earlier
Evening Star, the second candle is a small one representing indecision in the market.
On the third day, a white candle comes with the opening of the gap above the body

FIGURE 4.16 Evening Star


Source: Author

FIGURE 4.17 Morning Star


Source: Author
Candlesticks patterns 81

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.6 The Three Black Crows and the


Three Advancing White Soldiers
The Three Black Crows consist of three declining black candlesticks, clearly heading
towards lower prices. Each session shows that prices closed at or near the session low,
for each of these candles the real body must open higher to the previous days close,
but during the trading session, prices should fall well below the previous day’s close.
The image associated with this pattern is that of three black crows (sitting on a tall
tree, the uptrend), and are sometimes called the Three-Winged Crows, coming from
the Japanese expression ‘bad news has wings’ (Nison, 1991). For this formation to
hold, each of the three lines should close near their low or not have too-long lower
shadows. Figure 4.20 shows the ideal candlestick pattern for Three Black Crows.
The Three Advancing White Soldiers pattern, Figure 4.21, as the opposite of
the Three Black Crows pattern, are a group of three white candles with consecu-
tively higher closes. If the pattern appears after a period of stable price rise, it shows
strength in the market and a resumption of a prior uptrend. Each of the candlesticks
should close at or near the highs. If they appear near to a stable price belt, they
represent a continuation of a trend in the bullish direction. If the second or third
candlestick show signs of weakening, it is called an Advance Block Pattern (Nison,
1991) and signifies a weakening of the trend. Smaller white bodies or relatively
longer upper shadows are signs of a weakening trend. If the last two candlesticks are
long white ones that make a new high which is followed by a small white candle, it
is called a Stalled Pattern or Deliberation Pattern, which means the bullish tendencies
are exhausted. Figures 4.22 and 4.23 shows the reversing Three White Soldiers and
Three Black Crows on the Raymond stock chart.

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

FIGURE 4.20 Three Black Crows


Source: Author

FIGURE 4.21 Three White Soldiers


Source: Author

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

FIGURE 4.22 Three White Soldiers on Raymond. Created with Amibroker

FIGURE 4.23 Three Black Crows on Raymond. Created with Amibroker


Candlesticks patterns 85

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.24 Harami pattern on CAD. Created with Eikon, Refinitiv

FIGURE 4.25 Bearish Harami on Maruti. Created with Amibroker


86 Candlesticks patterns

4.3.8 Tweezers tops and bottoms


These patterns (Figure 4.26) represent candlesticks which have matching highs or
lows, which may be full bodies or the shadows. In an uptrend, the tops are formed
when the highs match while in a downtrend, the bottom is formed when the lows
match. While Tweezers by themselves may not be very strong reversal signal, they
would have more impact when they appear after an extended move or if there are
other reversal candlesticks with them.

4.3.9 Belt Hold lines (yorikiri)


Belt Hold is a single candlestick pattern which may be bullish or bearish. The bullish
Belt Hold has a strong white candlestick when the low of the trading session does
not fall below the open, and it moves up subsequently during the trading session.
This is also referred to as a white shaven bottom (Nison, 1991). The appearance of
bullish Belt Hold in a downtrend or at a probable low will forecast a rally. The bear-
ish Belt Hold has a long black candlestick, which has been as the high of the day,
representing the strong bearish tendencies as prices have gone down from the open
and continued to remain down through the rest of the trading session. On a probable
top, a bearish Belt Hold will signal a reversal to the downtrend. It is also referred to
as a black shaven head (Nison, 1991). The longer the height of Belt Hold lines, the
more significant they are in predicting a reversal. Figure 4.27 shows the Belt Hold
(bullish and bearish), and Figure 4.28 shows the near-perfect bullish Belt Hold at
the end of a downtrend.

4.3.10 Three Mountains and Three Rivers


These are analogous to the Triple Top and Bottom formation of classical technical
analysis and have many variants of their names, including the Three Buddha Tops,
Inverted Three Buddhas, Dumpling Tops, Fry Pan Bottoms, Tower Tops and Bot-
toms. The mountain is a combination of three tops, shown in Figure 4.29, with the
third top signifying the end of the rally. It shows that markets have tried to cross the

FIGURE 4.26 Tweezers tops and bottoms


Source: Author
Candlesticks patterns 87

FIGURE 4.27 Belt Hold: bullish and bearish


Source: Author

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.

4.4.2 Bullish Rising Three Methods and the Bearish Falling


Three Methods
The Rising Three Methods (Figure 4.31) is a bullish candle pattern, which must
happen in an uptrend and reflects that the move uptrend will continue. The Falling
Three Methods similarly has to occur in a downtrend. The Rising Three Methods
has a long white candle on the first day. Over the next three days, we have three
small body candles trending downwards. It is important to note that these small
candles should remain within the first day’s long white body and that at least two
Candlesticks patterns 89

FIGURE 4.30 Tasuki gaps


Source: Author

FIGURE 4.31 Rising Three Methods


Source: Author
90 Candlesticks patterns

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.33 Falling Three Methods


Source: Author

FIGURE 4.34 Separating lines


Source: Author
92 Candlesticks patterns

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.

5.2 Concept of moving averages


The mean or average, representative of all observations, is statistically expressed as
the sum of observations divided by the number of observations. Simple moving
averages (SMAs) are averages that move ahead with time, with the newest observa-
tion added on and the oldest one dropped each time. The fascination of the trad-
ing community with the moving average stems from the fact that it is one of the
most useful of technical analysis indicators. 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. It is here that the moving average
can play an important role. If the trend is to be your friend, it is the moving average
which signals it most effectively.
Basically, an n-period moving average presents the summation of last n periods
of data divided by n. As the n-period moving average will have n constant, a move
ahead in time necessarily requires the last data to be dropped. Each new datum
taken leads to the dropping of the oldest datum. Thus, every time in calculating
the moving average, the newest period is added and the oldest deleted to get the
moving average. Table 5.1 shows the moving average is calculated for three peri-
ods. The moving average corresponding to the period 18 August is given by prices
averaged over the first three periods, that is 16 August to 18 August. As we can
see, the three-period moving average will necessarily require three previous values,
and therefore, we cannot get any moving average for the first two periods. The
second moving average corresponding to the period 19 August is given by prices
averaged over the next three periods, that is 17 August to 19 August. In this case,
the observation corresponding to 16 August is dropped and the observation cor-
responding to 19 August is added. In this way, the rest of the series is derived by
adding a new observation each time and dropping the oldest observation so that
the average ‘moves ahead in time’.
Moving averages cut out the noise in the price series and help to recognize the
trend, removing the irregular fluctuations in data. The efficacy of using simple and

TABLE 5.1 Calculation of three-period moving average

D E F

1 Date Price of security X Moving Average


2 16/08/19 117
3 17/08/19 116
4 18/08/19 115 =AVERAGE(E2:E4)
5 19/08/19 115.1 =AVERAGE(E3:E5)
6 22/08/19 116.1 =AVERAGE(E4:E6)
Source: Author.
96 Moving averages

weighted (including exponential) moving averages for forecasts is borne by empirical


studies (Makridakis et al., 1982; Makridakis and Winkler, 1983). Moving averages
help smooth out the data and are especially useful in financial markets with a lot
of noise camouflaging the exact movement in the prices. It is trend-following and
helps with understanding whether a new trend has begun or a reversal is suggested.
The number of periods for which the moving average is calculated is very impor-
tant. The greater the number of periods used for calculating the moving average, the
smoother will be the moving average. Similarly, the shorter the time frame of the
moving average, the more the line will follow closely the actual price movement.
To understand how moving averages help show the trend and cut out the noise
in a series, let us consider Figure 5.1a. The figure shows the prices movement for
EUR/USD and the 30-period moving average. All technical analysis software sys-
tems will cover moving averages for different time frames. As we can see, the mov-
ing average line gives the direction of movement of the currency. We know from the
moving average line the trend in EUR against USD has been largely down, suggest-
ing a depreciation in EUR against USD over time. What happens if we increase the

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 Types of moving averages


Let us understand the commonly used moving average in some details.

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.

5.2.1.2 Linearly weighted moving average (LWMA)


The practice of giving equal weightage to all observations may not be good for
taking effective trading decisions. For example, if following a news shock, there
is a sharp movement in price today, it is likely to influence the market for some
time to come. For trading tomorrow, we must assign adequate weightage to the
sharp movement today, as it would probably have the greatest influence on prices
tomorrow, assuming no other news shock. In this case, therefore while we average
the data over a period of time, we assign the greatest weightage to the most recent

TABLE 5.2 Calculation of SMA, EMA, and LWMA

1 K L M N O

2 Timestamp Close 5-period SMA 5-period LWMA 5-period EMA


3 2/28/2019 70.85
4 3/1/2019 71.01
5 3/4/2019 70.92
6 3/5/2019 70.494
7 3/6/2019 70.09 =AVERAGE(L3:L7) =(L7*5+L6*4+L5*3+L4* =M7
2+L3*1)/15
8 3/7/2019 70.138 =AVERAGE(L4:L8) =(L8*5+L7*4+L6*3+L5* =L8*(1/3)+
2+L4*1)/15 O7*(2/3)
9 3/8/2019 70.028 =AVERAGE(L5:L9) =(L9*5+L8*4+L7*3+L6* =L9*(1/3)+
2+L5*1)/15 O8*(2/3)
Source: Author.
98 Moving averages

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.

5.2.1.3 Exponential moving average


The exponential moving average (EMA) also gives more weightage to the recent
data, with the weights reducing exponentially from the most recent to the first
observation. The EMA does not abruptly drop the data of past but gives it less
weightage. The EMA is derived as follows:

Current EMA = [(Price (current) – previous EMA) * multiplier] + previous


EMA, or
Current EMA = [Price (current) * multiplier] + [previous EMA(1 − w)], or

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.

5.2.1.4 Adaptive moving average


The adaptive moving average (AMA), developed by Perry Kaufman, creates a
balance between the tasks of smoothening price series and incorporating swings.
Kaufman (1995) points out that the moving average must be slow when markets
are sideways and fast in swinging markets. The idea then is to have a moving aver-
age that ‘speeds up’ when markets are moving fast and ‘does nothing’ when market
trudges sideways (Kaufman, 1995). The moving average is calculated using the
Efficiency Ratio (ER) and Adapting Smoothing Factor (SC).
The ER, or Fractal Efficiency, represents price adjusted for volatility and is given by

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

2 Timestamp Ask Close ABS change ER SC KAMA


100 Moving averages

3 4/20/2018 10:30 66.0325


4 4/20/2018 11:30 66 =ABS(C4-C3)
5 4/20/2018 12:30 66.0325 =ABS(C5-C4)
6 4/20/2018 13:30 66.055 =ABS(C6-C5)
7 4/20/2018 14:30 66.0625 =ABS(C7-C6)
8 4/20/2018 15:30 66.0425 =ABS(C8-C7)
9 4/20/2018 16:30 66.0425 =ABS(C9-C8)
10 4/20/2018 17:30 66.13 =ABS(C10-C9)
11 4/20/2018 18:30 66.14 =ABS(C11-C10)
12 4/20/2018 21:30 66.17 =ABS(C12-C11)
13 4/21/2018 1:30 66.22 =ABS(C13-C12) =ABS(C13-C4)/ =(E13*(2/3–2/31)+2/31)^2 =M13
SUM(D4:D13)
14 4/23/2018 9:30 66.22 =ABS(C14-C13) =ABS(C14-C5)/ =(E14*(2/3–2/31)+2/31)^2 =G13+(F14*
SUM(D5:D14) (C14-G13))
15 4/23/2018 10:30 66.2025 =ABS(C15-C14) =ABS(C15-C6)/ =(E15*(2/3–2/31)+2/31)^2 =G14+(F15*
SUM(D6:D15) (C15-G14))
16 4/20/2018 10:30 66.215 =ABS(C16-C15) =ABS(C16-C7)/ =(E16*(2/3–2/31)+2/31)^2 =G15+(F16*
SUM(D7:D16) (C16-G15))
Source: Author.
Moving averages 101

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:

SC = [ ERt ( alpha f − alphas ) − alphas ]2 ,(3)

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

KAMAt = KAMAt −1 + SC ( Pt − KAMAt −1 ) .(4)

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.1.5 Centred moving average


Moving averages may be centred by putting the value corresponding to the midpoint
of the series. The calculation of the centred moving average is shown in Table 5.4. The
calculation of centred moving average would not pose a problem for an odd number
of observations as each time we average the value corresponding to the middle of the
series. For example, the average value for the first five observation is written corre-
sponding to the third observation and so on. The problem arises when the number of
periods for which the moving average being calculated is even. In this case, a two-step
approach is followed. The first series of moving averages is determined by placing
them between the two relevant midpoint observations. For example, for a four-period
moving average, the first average will be placed between the two midpoint observa-
tions, that is between the second and third observations. However, in this case, as we
have no average mapped to a particular period, we average the previously obtained
moving averages once again. So, for the earlier example, the moving average cor-
responding to the midpoint of second and third observations and that corresponding
to the midpoint of third and fourth are averaged together to get a new value which
would then correspond to the third observation. In this way, the centred moving
averages derived lies in the middle of the price line, as can be seen from Figure 5.5.

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

Timestamp Ask Close 5 period centred 4 period centred

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.

5.3 Using moving averages to understand the trend,


support and resistance
It would probably not be wrong to call moving averages the most underutilized of
technical analysis indicators. The moving average can be a powerful tool in the hand
of the right trader who has learnt to pay heed to its subtle yet powerful indications.
The moving average reflects the trend better than any other indicator – by averaging
the data continuously as it moves ahead in the series – the moving average gives the
Moving averages 105

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.

5.3.1 Which moving averages to use?


As detailed earlier, there is a wide choice in the kind of moving average we use for
the trading signal generation and just like the choice of time span, it is crucial to
get the right moving average for effective trading.
Figure 5.5 compares the EMA, the AMA, and the centred moving average. As
you can see, the EMA and AMA both reflect the price movements very closely.
The centred moving average lies within the price line completely following the
price action and therefore is not suitable to be used for the crossover methodology.
Comparing the AMA and the EMA, we can see that while major swings are repre-
sented in both moving averages, for sideways markets, the AMA slows down more
appropriately than does the EMA. The AMA gives the perfect balance between
incorporating swings in the market while also smoothing the fluctuations in the
data. The AMA thus gives a better picture of the broad direction of the market
without paying undue importance to the most recent observation. This makes the
AMA especially suitable in the representation of the trend and therefore as a sup-
port or resistance for the price movement. However, the EMA is more suitable for
the crossover technique we discuss in the next section, as it is the fastest and rep-
resents smaller swings in price leading to optimum signal generation. The EMA,
106 Moving averages

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.

5.4.2 Triple crossover technique


The triple crossover method employs three moving averages. For example, 9-, 14-,
and 21-period moving averages can be used for the triple crossover method. Of the
three moving averages, it is clear that the 9-period moving average will follow the
prices most closely, followed by the 14-period and finally the 21-period moving
averages. In a downtrend, the 9-period average will lie below the 14-period aver-
age, which again will lie below the 21-period average. The buy alert happens when
the 9-period average crosses above the 14-period and 21-period averages from
below. Confirmation is obtained when the 14-period average crosses the 21-period

FIGURE 5.8 Triple crossover. Created with Eikon, Refinitiv


Moving averages 109

average from below. Similarly, for a move from an uptrend to a downtrend to be


confirmed, the shortest and most sensitive 9-period average crosses the 14-period
and 21-period averages from above, followed by the 14-period average crossing the
21-period average from above.
The triple crossover technique is used for confirmation of signals and gives
more robust signals than the double crossover method. In Figure 5.8, we have three
moving averages plotted onto the price – the 30-period, 40-period and 50-period
moving averages. The 30-period moving average will be the fastest-moving aver-
age, while the 50-period moving average will be the slowest-moving average.
In Figure 5.8, the first signal is given by point 1, the 30-period moving average
crosses the 40-period moving average from above to below, suggesting the trend
will reverse to the downside. The confirmation of this signal is obtained at point
2, where the 40-period moving average cuts the 50-period moving average from
above. At this point, we note that the 30-period moving average remains below
both the 40- and 50-period average. So the reversal signal obtained at point 1 is
confirmed by the signal obtained at point 2.
Similarly, the uptrend reversal signal is given at point 3, with the 30-period moving
average cutting the 40-period moving average from below, and a confirmation of this
signal is obtained at point 4, where the 40-period moving average cuts the 50-period
moving average from below. Again, at this point, we must confirm that the 30-period
moving average lies above the other two moving averages. Thus, in a triple crossover
method, the signal obtained from the double crossover is confirmed by another cross-
over signal. This leads to more robust signals and confirmed trading decisions. The
shortcoming of the triple crossover method is the greater delay in signals compared
to even the double crossover technique, resulting in a loss of trading opportunities.

5.5 Case studies: using moving averages for trading


In this chapter, we considered the moving average indicators, which are based
on mathematical or statistical tools and hence give objective signals to the trader.
Because they are quantifiable and based on statistical indicators, they take subjectiv-
ity out of technical analysis. This is especially useful for the new traders who are
not yet adept at the visual chart analysis required for classical technical analysis and
candlestick patterns. We use two examples to underline the use of moving averages
for forecasting future price trends.
Let us consider the EUR/USD given in Figure 5.9.
Let us consider the crossover analysis in the light of Figure 5.9 which shows the
price movement in EUR/USD in 2017–2018. At point 1, prices move above all
the three moving averages. The fastest-moving average remains above the other
moving averages. Prices form higher highs and higher lows above the moving
averages, confirming that the trend under consideration has reversed on the upside.
Interestingly at the mature phase of the uptrend, when prices start moving side-
ways, price moves below the moving average at times. However, the moving aver-
ages move parallel with no crossovers, suggesting that the trend has not yet been
reversed. It is at point 2 that we obtain a bear crossover and a sell signal. Thus, the
110 Moving averages

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

FIGURE 5.10 Gold futures in INR (daily chart). Created with Amibroker

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

Irrational exuberance is not that crazy.1


− Robert J. Shiller

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.

6.2 Momentum and Rate of change


Momentum refers to the extent of change in prices in a market. A momentum
indicator considers the price differences or price changes over a particular time
interval as opposed to taking the price movement alone. For example, we can con-
struct a simple momentum indicator M given by the difference between closing
prices today and closing prices, say, n periods back.
Thus,

M = V −V * ,(1)

where V is the closing price at time t and


V* is the closing price at time t − n.

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

Date Price of security X Three-period moving average Three-period 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

Price of security X Three period Moving average


Three period Momentum

FIGURE 6.1 Movement of prices reflected by moving average and momentum


Source: Author.

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

ROC = 100 * (V / Vx ) ,(2)

where V is the closing price at time t and


V* is the closing price at time t − n.

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:

RSI  100  100 / 1  RS *   (3)

*Where RS is the average of x period’s up closes/average of x period’s down closes.


Usually, X is taken to be 14 periods, the default time span recommended by
Wilder, on the basis of the 28-day lunar cycle. While the default 14 periods works
well for most markets, technical analysis experts have questioned the default selec-
tion of the 14-period span (Kaufman, 1995; Pring, 2014). If the primary trend of
the particular market follows the 4-year business cycle or a 28-day monthly cycle,
the 14-day period would be a good choice. Again, for intra-day data, a market that
follows the 24-hour cycle can effectively use the 14-period RSI. In the case of the
dominant cycle in the market being different from the 28-period cycle, the RSI
120 Momentum indicators and stochastics

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

FIGURE 6.3 RSI: negative divergence. Created with Eikon, Refinitiv

FIGURE 6.4 RSI: positive divergence. Created with Eikon, Refinitiv


122 Momentum indicators and stochastics

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

FIGURE 6.5 MACD. Created with Eikon, Refinitiv


124 Momentum indicators and stochastics

FIGURE 6.6 MACD with MACD forest. Created with Eikon, Refinitiv

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:

%K = 100[Close − Low]/[High − Low],  (4)

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

The calculation formula for an HA candle, discussed earlier in Chapter 2, is as fol-


lows (Kuepper, n.d.):

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 )

where Dt is the difference between the HA open and the HA close.


For a detailed discussion on the stochastic and the results of the backtesting, you
can refer to this article.4
Momentum indicators and stochastics 127

6.7 Case studies: framing trading strategies with


momentum indicators
We now use the indicators discussed in this chapter for analysis of the recent market
developments using two case studies.

A. State Bank of India


In a chart of the State Bank of India (SBI; Figure 6.8), the following are the
important observations: in July 2019, the SBI showed a Double Top pattern. The
neckline of the pattern is at 350 levels. Prices were moving in the upward-sloping
channel and broke below the lower trend line at 358 on 19 July. It was later fol-
lowed by a break below the neckline near 350 which provided confirmation that
the up move was over and the trend was changing to the downside. A trader can
enter the position on the break below the neckline which was also associated by
multiple other factors stated in the following.
The Double Top formation was with negative divergence seen clearly on the
RSI. It indicated that the SBI formed higher highs but that the RSI formed lower
highs, thereby confirming that the up move was with slower momentum com-
pared to past, and it acted as a leading warning sign. Always remember it is not
wise to short or sell by simply looking at negative divergence but to wait for

FIGURE 6.8 SBI combined analysis. Created with Amibroker


128 Momentum indicators and stochastics

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.9 Nifty 50 index (monthly chart). Created with Eikon, Refinitiv

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.11 Nifty 50 Index (weekly chart). Created with Amibroker


Momentum indicators and stochastics 131

wedge-pattern breakout. This is an expected outcome post the pattern completion


that we witnessed here. An EMA of 100 days and 20 days were both broken, along
with the break of the lower trend line of the pattern that further confirmed the
validity of change in medium-term trend from up to down. The selection of these
moving averages is done on the basis that it provided support during the rise from
minor and intermediate trends.
The RSI indicator also showed a range shift. Earlier, during the rise from 2013
onwards till mid-2018, the RSI reading was seen as fluctuating between 78 and 38.
After the sharp decline in 2020, the RSI touched the reading of 16, which had not been
seen since 2008. It was after 12 years that there was such low reading on weekly RSI
that indicated a change in market sentiment and probably an onset of a bear market.
In Figure 6.12, Nifty daily chart (from November 2019–April 2020) also reflects
slower momentum and a negative divergence between prices and RSI. There were
a series of negative divergences across the weekly and daily time frames which
were exhibited much before the onset of COVID-19 pandemic, as we saw in Fig-
ure 6.11 and 6.12. Post the break below the lower trend line of the pattern, there
was an attempt to retest the same trend line which later acted as resistance. Prices
then started collapsing sharply and formed lower highs and lower lows. There were
enough negative confirmations using simple technical analysis methods for a trader
or investor to take trading or investments decisions accordingly.

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.

FIGURE 6.13 Nifty 50 Index (hourly chart). Created with Amibroker


Momentum indicators and stochastics 133

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

2 An MACD histogram is denoted as MACD Forest in the Eikon, Refinitiv charting


system.
3 Roy Trivedi, S (2020b), Technical analysis using Heiken Ashi Stochastic (HASTOC): To
catch a trend, use a HASTOC, International Journal of Finance and Economics.(Forthcoming)
4 Roy Trivedi, S (2020b), Technical analysis using Heiken Ashi Stochastic (HASTOC): To
catch a trend, use a HASTOC, International Journal of Finance and Economics. (Forthcoming)
7
VOLATILITY AND VOLUME
INDICATORS

When an investor focuses on short-term investments, he or she is observing the


variability of the portfolio, not the returns – in short, being fooled by randomness.
– Nassim Nicholas Taleb1

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

of holding liquid inventory (Bessembinder, Ibid). The inventory carrying costs,


in this model, explain to a large extent the variation in exchange rate with news.
Asymmetric information reflects the widening of spreads as participants face
more ‘informed’ traders. The presence of a more informed trader with insider
information will lead to a rise in bid–ask spreads by existing participants to protect
against the lack of information (Fleming and Remolona, 1999)
Fleming and Remolona (1999) mark the two stages of adjustment to macroeco-
nomic news – the release of new information leads to widening of spreads as the
market makers look at inventory costs. This change is sharp and instantaneous and
leads to a fall in trading volume as market makers withdraw from trading. In stage
two, trading increases, with volatility remaining high as there is ‘residual disagree-
ment among investors about what the just released information means for prices’
(Fleming and Remolona, 1999).
The preceding point is corroborated by studies on market volatility. For exam-
ple, market participants may have an imprecise estimate of fundamentals, so that
exchange rate expectations will differ across market participants (Dreger and
Stadtmann, 2008; Evans and Lyons, 2002). Heterogeneity comes from the use
of different models or different provisions in the same model and different inter-
pretations of fundamental and technical indicators (Dreger and Stadtmann, 2008;
Chari, 2007).
Classical technical analysis suggests that traders should try to trade in the direc-
tion of the trend and avoid sideways-moving markets. While moving averages can
help us to understand the trend and oscillators the force in the trend, traders often
are flummoxed when they encounter a range-bound market with high volatility.
As most markets demonstrate considerable periods of range-bound activity, it is
also not possible for the trader today to completely avoid trading in the sideways
markets. In this case, we need to understand more about volatility in the market
and how to make use of volatility in trading decisions. In this chapter, we look at
the volatility indicators most popularly used in the market, namely Bollinger Bands
and ATR.
We combine this with the knowledge of how to use volume for technical analy-
sis. Till now, we only considered the price action and not the volume of trades.
Why combine the study of volume and volatility? The reason for doing so goes
back to the empirical debate on volume and volatility in financial markets. While
a clear consensus is yet to emerge, there is strong support to the belief that volume
and volatility are likely positively correlated (Schwert, 1989; Duong and Kalev,
2018). In formal models exploring the volume–volatility relationship, the pres-
ence of asymmetric information means that the size of trades or volume of the
trades of informed agents is positively related to the quality of their information. In
other words, the quality (or precision) of information possessed by informed trad-
ers should have a positive relation with the size of trades or volume (see Jones et al.,
1994, for a discussion). Technical analysis has traditionally given more attention to
volume, along with price movements. In classical technical patterns, for example,
volume plays an important role in defining both continuation and reversal patterns,
Volatility and volume indicators 137

discussed in chapter 3. Here, we take up volume-based indicators which can help


us to refine the trading decisions.

7.2 Volatility indicators

7.2.1 Moving average envelopes


Moving average envelopes are the simplest measure of the volatility of price move-
ment. In Chapter 5, we saw how moving averages can act as dynamic support and
resistance. Constructed over a longer time, the support and resistance levels given
by the moving averages become relevant. Moving average envelopes extend on this
principle by constructing envelopes or symmetrical parallel lines around moving
average (Pring, 2014). The moving average represents the trend and the envelopes
are the divergences around the trend. Usually moving average envelopes are con-
structed at ±5%, 10%, or 20% around the moving averages. It may be noted that
the two bands of the envelopes are equidistant from the central moving average
line. This is shown in Figure 7.1.
How to use moving average envelopes? The upper and lower bands can act as
resistance and support levels, respectively, and any cross above the moving average
towards the upper band shows the extent of the market into the overbought region.
Similarly, the move down towards the lower band suggests the entry to the over-
sold region. However, the moving average envelopes by themselves are not very
good indicators for trading. You may have noted that the bands remain unchanged
whether the market displays high volatility or low volatility. These moving average
envelopes are only to give an additional divergence range to the moving average
and help in discerning the dynamic support and resistance. The concept of using
divergences from moving average is perfected through the use of Bollinger Bands
which we take up next.

FIGURE 7.1 Moving average envelopes. Created with Eikon, Refinitiv


138 Volatility and volume indicators

7.2.2 Bollinger Bands®


This technique developed by John Bollinger uses the very popular concept of
standard deviation to identify trading bands around price movement. Standard
deviation is the dispersion or deviation of a series around its mean. Two trading
bands are placed around a suitable moving average, at ±2 standard deviations of
the series. If the series is assumed to follow the standard normal distribution,2 ±2
standard deviations of the series encompasses 95% of the market data. Bollinger
Bands plot the upper and lower ranges for price movement based on the volatility
of the series. The upper and lower bands are constructed at ±2 standard deviations
around the mean (MA) as follows:

(  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

is increased, the number of standard deviations also needs to be increased. Similarly,


if the average period is reduced, the number of standard deviations can be reduced.
How are Bollinger Bands used to make trading decisions? First, if the market
prices cross the centre or mean line and reach the upper band, the market is con-
sidered to be overextended on the upside or overbought. Similarly, if prices reach
the lower band, it is considered to be overextended on the downside or oversold.
The crossing of the moving average line at the centre, however, should not be taken
as a sign of trend reversal. The average line is more an indicator of the intermedi-
ate-term trend (Bollinger, 2019) and may not be the best one for understanding
crossovers.
The alternating periods of volatility are shown remarkable well by the Bollinger
Bands. When bands narrow, it is expected that prices will change sharply very
soon with an increase in volatility. Therefore, the narrowing of the bands indicates
squeeze, and this is then followed by a period of expansion of the bands. Therefore,
after a squeeze in the bands, if we start seeing an expansion, it suggests that a trend
is emerging in that direction, and this can be used to recognize a breakout in the
direction of the new trend.
The prices which have moved outside of the bands are taken to be outliers; in
this case, the momentum is very high in the market. As we mentioned with the
use of stochastics and oscillators in Chapter 6, the mere entry into an overbought
or oversold region need not be a signal to sell or buy, respectively. As can be seen in
Figure 7.2, when prices reach the upper band or lower band, they tend to remain
there for some time before crossing back into the band, as shown by point 1 in
Figure 7.2. In this case, a confirmation from a break of the trend line or the price
pattern is helpful for understanding when the trend reversal happens.
The problem with using the moving average line as a crossover and upper and
lower bands as price targets are shown in Figure 7.2. For example, if prices cross

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

FIGURE 7.4 Bollinger Bands (Nifty daily chart). Created with Amibroker

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).

The true range (TR) is

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):

ATRt = (( ATRt −1 *13) + Max ( D1 , D2 , D3 )) / 14 .(4)

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

FIGURE 7.5 ATR (EUR hourly chart). Created with Eikon, Refinitiv


Volatility and volume indicators 143

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:

Volume (Current Period ) − Volume ( n periods back )


Thus,Volume Rate of Change = . ( 5)
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.

7.3.2 The Chaikin Money Flow Index


Chaikin Money Flow Index compares the closing price to the daily high–low
range to determine what is the volume that flows in or out for securities trade.
This volume is then compared to the total volume. The indicator is based on the
principle that strength in the market usually sees price closing in the upper half of
their daily high–low range with increased volume. In other words, rising prices
should be accompanied by expanding volume and vice versa. If the momentum is
lower in the market, prices typically close in the lower half in the daily high-low
range with increased volume.
Volatility and volume indicators 145

The formula is as follows:

CMF = SUM ( AD, n ) / SUM (VOl , n ) , (6)

where n is the number of periods and


AD equals Volume (VOL) * (Close – Open)/(High – Low),
where AD is accumulation distribution.

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

7.4 Case studies: using volatility indicators


for trading decisions
Let us discuss the use of volatility indicators to make trading decisions using the
following cases.

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,

FIGURE 7.8 Reliance industries (daily chart). Created with Amibroker


Volatility and volume indicators 147

as expected, which provided secondary confirmation and increased the validity of


the positive trend emerging.
A trader can take long positions on the breakout as it was confirmed by Bol-
linger Bands, volume, and the ATR. By using multiple techniques, the conviction
to take the trade increases and ensures objectivity. The ATR can also be used in
order to derive stop loss for the position and to trail the stop for riding the trend.
As the ATR tracks volatility, it is best to use it for systematically deriving the stop
levels. A trailing stop can be kept at two times the ATR value. This will ensure
that with a rise in volatility, the stop is placed sufficiently far away to avoid getting
whipsawed during the day.
In Figure 7.8 of reliance industries, we can see the ATR value around 25 on 18
January. Two times the ATR gives 50. This value is subtracted from the close of 18
January, which was at 1184. Thus, an ideal stop will be at 1184 – 50 = 1134. This
is also just below the low of 18 January, which was at 1135. Thus, 1134 becomes
an ideal stop based on volatility and below the lowest point of the day. A trailing
stop will keep changing with prices and volatility movement.
By simply following the preceding method of ATR and keeping a trailing stop
loss, one can ensure to ride the trend using a systematic method of a volatility-
based stop. Bollinger Bands, pattern breakout, and ATR can thereby be combined
to derive a high-conviction trade set-up.

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

FIGURE 7.9 Nifty 50 (daily chart). Created with Amibroker

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

4 Narrowing of the bands indicates squeeze and is followed by period of expan-


sion in volatility.
5 During range-bound market, the upper and lower bands provide resistance
and support to prices, respectively.
6 The ATR looks at the range between high and low prices to arrive at an esti-
mate of volatility.
7 The volume ROC is the percentage change between current period’s volume
and the volume n periods back.
8 The Chaikin Money Flow Index compares the closing price to the daily high–
low range to determine what is the volume that flows in or out for securities
trades.

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.

8.2 The Fibonacci sequence


Elliott Wave Theory emphasizes on certain numbers that are derived using the
Fibonacci sequence. Fibonacci numbers are derived by adding each number to the
previous number.
Following are the Fibonacci numbers – 1, 1, 2, 3, 5, 8, 13, 21, 34, 55,
89, 144, . . .
An Elliott Wave has five waves forward and three waves backward. Both five and
three are Fibonacci numbers, and the complete cycle is composed of eight waves,
which is also a Fibonacci number.

8.2.1 The golden ratio


Moving ahead in the sequence of Fibonacci numbers by dividing one number by
the previous number gives the ratio which is 1.618. This is known as the golden
ratio. This golden ratio is seen across many architectural marvels, and the pyramid is
a classic example. It is believed that buildings built with this ratio are pleasing to the
eye of the observer. Stock markets also follow the golden ratio and the derivatives
of it in many ways. Especially, the ratio of 0.618 usually acts as important support
or resistance to prices.

8.3 Understanding impulse patterns


An impulse pattern is composed of five waves and is labelled with numbers. A. J.
Frost and Robert R. Prechter (Prechter and Frost, 2005)2 explained that the major
movements in the form of wave 1, wave 3 and wave 5 are categorized as impulse
waves. The impulse wave is divided into five sub-waves. Impulse waves travel in
the direction of one higher-degree wave. Wave 1, wave 3, and wave 5 move in the
direction of the trend, and wave 2 and wave 4 move in a counter-trend.
Figure 8.1 shows an impulse wave that consists of wave 1 through wave 5 and
the corrective waves that are labelled as wave a–b–c. Within the impulse pattern as
well, wave 2 corrects the preceding wave 1, and wave 4 corrects the preceding wave
3. So wave 2 and wave 4 are themselves corrective patterns as they are correcting
152 Elliott Wave Principles

FIGURE 8.1 The basic pattern


Source: Author

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.

8.3.1 Rules of impulse patterns


Following are the three rules that have to be followed for a valid normal impulse
pattern:

• 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.

FIGURE 8.2A Wave 2 completely retraced wave 1: not allowed


Source: Author

FIGURE 8.2B Wave 3 is the shortest among impulse waves: not allowed


Source: Author
154 Elliott Wave Principles

FIGURE 8.2C Wave 4 enters the territory of wave 1: not allowed


Source: Author

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:

• Smaller-degree waves combine to form higher-degree waves.


• A trend consists of five waves which follow in the direction of the longer trend.
• A correction path consists of three waves.
• The most common Fibonacci retracements are 61.8% (the golden ratio) and
38.2%.

8.3.3 Variations to the impulse pattern


Extension: It is common to see one of the impulse waves extended. An extension
is an elongated movement in comparison to the other impulse waves. An extended
Elliott Wave Principles 155

FIGURE 8.3 Degrees of waves


Source: Author

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

FIGURE 8.4 Wave 3 extended and subdivided


Source: Author

FIGURE 8.5 Impulse pattern (Nifty hourly chart). Created with Amibroker

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

Wave 2 will not completely retrace wave 1.


Wave 3 will not be the shortest among the impulse waves.

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.6 Ending diagonal pattern


Source: Author
158 Elliott Wave Principles

From a trading perspective, an ending diagonal pattern provides a very good


trading opportunity. In the case of an upward-sloping pattern, a break below the
2–4 trend line indicates a high probability that a top is in place and we will see a
reversal move towards the start of wave 4, and the high of wave 5 can be maintained
as a stop loss.
In the case of a downward-drifting ending diagonal pattern, a break above
the 2–4 trend line will confirm the completion of the pattern, and we can then
expect a move on the upside towards the start of wave 4, with the low of wave 5
as stop loss.
Figure 8.7 is a classic example of an ending diagonal pattern along with the
post-pattern implication. Nifty Index (India) formed a very important top in Janu-
ary 2008. Following are the important observations for a trader or investor:

• Wave 5 formed an ending diagonal pattern that completed a higher-degree


wave (5) as well.
• Wave 4 overlapped with wave 1, and there was a minor throw-over above the
upper trend line to complete minor-degree wave 5.
• A reversal on the downside, post completion of wave 5, was dramatic and
resulted in a price move below the start of ending diagonal pattern.

FIGURE 8.7 Ending diagonal pattern (Nifty daily chart). Created with Amibroker
Elliott Wave Principles 159

Fifth failure pattern


On a few occasions, wave 5 fails to move beyond the end of wave 3. Elliott called
this a ‘failure’ as normally wave 5 moves beyond the end of wave 3. It is important
that wave 5 of a failed pattern should follow the impulse wave rules. Another vari-
ation is that wave 5 forms an ending diagonal pattern and fails to move beyond
the end of wave 3, as shown in Figure 8.8. The post-pattern implication of a fifth
failure pattern is similar to that of an ending diagonal pattern.
Figure 8.9 shows the impulse rise in the stock of Maruti Ltd. It follows all the
rules of the impulse pattern and shows a fifth failure in the final leg. Following are
important observations:

• 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.

Post completion of wave 5, there is a dramatic reversal on the downside which is


typical characteristics and post-pattern implication of a fifth failure.

FIGURE 8.8 Fifth failure pattern


Source: Author
160 Elliott Wave Principles

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.

8.4.1 Zigzag correction (5–3–5)


The zigzag corrective pattern is a three-legged correction and labelled as a–b–c.
In this pattern, wave A and wave C are impulse waves which should follow all the
impulse rules. Wave B corrects wave A in the opposite direction, and therefore, it
can be any correction itself. A zigzag correction is composed of 5–3–5 sub-waves.
In a bull market, a zigzag correction takes prices on the downside, and in the
case of a bear correction, it takes prices on the upside. In Figure 8.10, a zigzag
pattern labelled as (A)–(B)–(C) is shown. Here, wave A and wave C are impulse
Elliott Wave Principles 161

FIGURE 8.10 Zigzag pattern


Source: Author

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

FIGURE 8.11 Zigzag pattern (Nifty daily chart). Created with Amibroker

• 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.

8.4.1.1 Double and triple zigzag correction


On occasion, a zigzag will occur more than once, thereby forming a complex
corrective pattern. A complex correction pattern involves “x” waves. Two zigzag
patterns are separated by a corrective three in between which forms a double zig-
zag formation. On occasion, there are three consecutive zigzag patterns which are
separated by wave x, and it is then known as a triple zigzag pattern. It is common
to see a zigzag pattern in wave 2.
See Figure 8.12 for a double zigzag pattern. Also note that wave X is of one
higher degree compared to the prior standard zigzag pattern. Robert Prechter has
labelled this first set of standard correction as wave W and the next as wave Y. So
the entire pattern is labelled as a–b–c–X–a–b–c and can also be labelled as W–X–Y.
See Figure 8.13 for a triple zigzag pattern. This pattern can be labelled as (A)–
(B)–(C)–X–(A)–(B)–(C)–X–(A)–(B)–(C). Alternatively, it can also be labelled as
W–X–Y–X–Z. In the case of a complex correction, there can be maximum of two
Elliott Wave Principles 163

FIGURE 8.12 Double zigzag pattern


Source: Author

FIGURE 8.13 Triple zigzag pattern


Source: Author
164 Elliott Wave Principles

“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.2 Flat correction pattern


A flat correction is composed of 3–3–5 sub-waves. This means that wave A is cor-
rective, which is followed by corrective wave B and then impulse wave C. Wave C
can form a normal impulse or an ending diagonal impulse. In a flat correction, wave
B will terminate near the start of wave A. Flat corrections are further categorized
into a regular flat pattern, an irregular flat pattern, and a running flat correction.

8.4.2.1 Regular flat correction


In a regular flat correction, wave B retraces near the start of wave A. Here it is
observed that wave C will travel beyond the end point of wave A as there is not
much strength in wave B. Figure 8.14 shows a regular flat correction. Also note
that wave A is a corrective pattern, which is different than zigzag where wave A is
an impulse pattern. If wave C fails to go beyond the end point of wave A, it is
known as a C failure regular flat pattern. It is also known as a double failure pattern
since wave B fails to go beyond the starting point of wave A and wave C fails to go
beyond the ending point of wave A.
On occasion, wave C measures approximately 1.618 times wave A, which is
known as an elongated flat pattern.

FIGURE 8.14A Flat pattern correcting up move


Source: Author
Elliott Wave Principles 165

FIGURE 8.14B Flat pattern correcting down move


Source: Author

8.4.2.2 Irregular flat correction


In irregular flat correction wave B has a tendency to move beyond the end of wave
A and so it is named as an irregular flat pattern. Figure 8.15 shows an irregular flat
pattern. It is normally found that wave B travels anywhere from 100% to 138.2%
of wave A, although this is only a guideline. Chances of a C failure is higher in
the case of an irregular flat pattern as compared to a regular flat pattern as wave B
travels beyond the end point of wave A, thereby resulting in a weaker wave C. So
the stronger wave B, the chances of a wave C failure increases.

8.4.2.3 Running flat correction


In an upward-sloping running flat correction, wave B ends well above the begin-
ning of wave A and wave C fails to travel towards the end of wave A. The move
on the upside is strong, and so it results in a pattern skewed in the direction of the
bigger-degree trend. In the case of a bull correction, post completion of the run-
ning flat pattern, there is a very strong rise that covers the maximum distance in
minimal time. Figure 8.16 shows a running flat pattern during a bull trend. A move
that opens up after the completion of wave C will be strong. A running flat cor-
rection can also occur during a bear trend. Wave C, in the case of a running flat
correction, will still be an impulse pattern.
166 Elliott Wave Principles

FIGURE 8.15A Irregular flat correcting up move


Source: Author

FIGURE 8.15B Irregular flat correcting down move


Source: Author
Elliott Wave Principles 167

FIGURE 8.16 Running flat correction


Source: Author

8.4.2.4 Double and triple flat correction


Like a zigzag that can occur more than once, there are patterns where a flat cor-
rection also occurs more than once to form a double flat involving one X wave. If
two X waves separate the flat patterns, it is named a triple flat. Wave X can con-
nect any of the flat patterns like a regular flat–X–irregular flat. This can be seen
in Figure 8.17a. A few variations of a flat pattern involving wave x can be seen in
Figure 8.17b.
Double flat corrections are also labelled as A–B–C-(X)–A–B–C or (W)–(X)–
(Y), and similarly, triple flat corrections are labelled as A–B–C–(X)–A–B–C–
(X)–A–B–C or (W)–(X)–(Y)–(X)–(Z), as shown in Figure 8.17c. There can be a
maximum of two X waves involved.
In Figure 8.18, we can see a double zigzag correction which is labelled as (W)–
(X)–(Y). The following are important observations:

• Waves A and C are clearly impulsive.


• Wave (X) connected two zigzag patterns.
• The entire fall is within the channel, thereby providing indications of reversal
areas.
• Trades can be taken on reversals from the channel resistance for riding wave C
on the downside as the major trend for the forex pair remained negative.
• Wave C tends towards equality with wave A in the case of a zigzag correction
where wave B has retraced a significant portion of wave A, thereby giving the
downside targets.
168 Elliott Wave Principles

FIGURE 8.17A Double flat correction


Source: Author

FIGURE 8.17B Double flat correction


Source: Author
Elliott Wave Principles 169

FIGURE 8.17C Triple flat correction


Source: Author

FIGURE 8.18 Double zigzag correction (EUR/USD weekly chart). Created with


Amibroker
170 Elliott Wave Principles

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.

Irregular wave B triangle


Many times, it is wave b that forms the widest part of the triangle, not wave a. This
results in an irregular wave b triangle which is shown in Figure 8.20a. The pattern

FIGURE 8.19 Triangular pattern


Source: Author
Elliott Wave Principles 171

FIGURE 8.20A Triangular pattern with an irregular wave B


Source: Author

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.20B Irregular triangle pattern in a bear market


Source: Author

FIGURE 8.21 Triangle pattern (ICICI Bank weekly chart). Created with Amibroker
Elliott Wave Principles 173

8.4.4 Diametric pattern: new patterns discovered by Glenn


Neely3 (1995) of NEoWave
In addition to the standard corrective patterns mentioned earlier, Glenn Neely,
founder of NEoWave, discovered a pattern which is commonly seen across the
asset classes. A seven-legged corrective pattern known as Diametric is found often.
There are two variations to Diametric pattern – Bow-Tie Diametric, shown in
Figure 8.22a, and Diamond-shaped Diametric, shown in Figure 8.22b. This
pattern is labelled as a–b–c–d–e–f–g, and the sub-waves are 3–3–3–3–3–3–3. In
this pattern, it is often seen that wave b consumes less time compared to wave
a. Also, there is a tendency for wave g to be equal to wave a in terms of price/
time, wave f to be tending towards equality with wave b, and wave e to be tending
towards equality with wave c. A Diametric pattern can drift on the upside or the
downside, thereby resulting in a running Diametric pattern.
In Figure 8.23, we can see Facebook exhibited a big fall from the top in the form
of a Bow-Tie Diametric pattern. The following are the important observations:

• Wave E tends towards equality with wave C.


• Wave G is tending towards 61.8% of wave A.
• Wave F is trending towards equality with wave B.

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.22A Bow-Tie Diametric pattern in a bear market


Source: Author
174 Elliott Wave Principles

FIGURE 8.22B Diamond-shaped Diametric pattern in a bull market


Source: Author

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.

FIGURE 8.24 Alternation between wave 2 and wave 4


Source: Author
176 Elliott Wave Principles

Double combination or double 3s

FIGURE 8.25A Double combination pattern


Source: Author

FIGURE 8.25B Double combination pattern


Source: Author
Elliott Wave Principles 177

Triple combination or triple 3s


It is common to see a combination of different corrections, but usually, it is in the
order of zigzag, flat, and triangle. It is rare to see a triangle followed by flat which
is later followed by a zigzag combination. A zigzag is supposed to be a powerful
correction; that is it results in more price retracement of the prior move as com-
pared to a flat and a triangle. On the other hand, triangles are more time corrective
pattern rather than price. Therefore, it is normal to see the combinations in the
order of zigzag, flat, and triangle and not the other way around. Post completion
of double or triple corrective patterns, the higher-degree trend resumes. As men-
tioned earlier, there cannot be more than two X waves in a complex corrective
pattern. A double combination pattern is also known as double threes and a triple
combination pattern is also known as triple threes.

FIGURE 8.26A Triple combination pattern


Source: Author

FIGURE 8.26B Triple combination pattern


Source: Author
178 Elliott Wave Principles

FIGURE 8.26C Triple combination pattern


Source: Author

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

Triple zigzag pattern 4,800

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 trendline 5,500


5,326.65
5,000

2 4,500

4,000

3,500

3,000

2017 2018 2019 2020


Created with AmiBroker - advanced charting and technical analysis software. http:/www.amibroker.com

FIGURE 8.28 Channels (Maruti weekly chart). Created with Amibroker

^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

2009 2010 2011 2012 2013 2014 2015 2016


Created with AmiBroker - advanced charting and technical analysis software. http:/www.amibroker.com

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.

A trader should be looking forward to buying opportunities in the index as per


the Elliott Wave pattern and the concept of higher highs and higher lows.
In a continuation of Figure 8.29, Figure 8.30 shows that there is a clear rise in
the form of wave 5 as per the Elliott Wave chart of the DJIA. This rise completed
one bigger-degree wave (3), post which there was a correction in the form of wave
(4). Robert Prechter (The Elliott Wave Theorist – January 31, 2020) pointed out,

[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

FIGURE 8.30 Impulse pattern (DJIA weekly chart). Created with Amibroker


Elliott Wave Principles 183

He further went on to add:

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

• It is common to see wave X connecting different corrective patterns together.


• Alternation is an important guideline and is a common occurrence between
wave 2 and wave 4.
• It is crucial to apply channels on a chart while doing the wave counts.

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.

9.3 Left and right translation


As there are multiple cycles acting on market price at any given point of time, there
is a possibility that instead of forming a peak at the centre of the cycle, a peak is
formed either in the first half or the second half of the cycle. If the peak is formed
during the first half of the cycle, it is known as being left-translated, and if the
peak is formed in the second half, then the cycle is called right-translated. When
the prices peak out during the first half of the cycle itself, it indicates that a bigger
cycle has topped out, so prices started moving lower in the first half of the cur-
rent cycle. For example, assuming there are only two cycles of 20 days and 40 days
acting on the prices. If we see prices peak out in only 5 days of the 20-day cycle,

FIGURE 9.1 Characteristic of cycles


Source: Author
188 Time 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

FIGURE 9.2 Nested cycles


Source: Author

9.5 Detecting the 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

FIGURE 9.3 Time cycles (Nifty daily chart). Created with Amibroker

• 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.4 Cyclicality (DJIA weekly chart). Created with Amibroker

is in close approximation to this cycle. It is better to use the 170-week cycle as


it is able to capture important lows, including the one made in the last week of
December 2018. With the crash in 2020, the low made in December 2018 stands
broken, thereby indicating that the top is formed in February 2020 which might
not be taken out until March 2022 cycle low is in place. If prices break back above
29568 before this period, it will be an indication of cycle contraction resulting out
of steepness of fall.

9.5.2 Selecting oscillator indicator parameters


Cycles are one of the important principles based on which the momentum indica-
tor values can be derived. For example, as DJIA is following a cycle of 170 weeks,
it is better to use an ROC indicator having a value of half of 170 weeks as it will
measure one complete cycle from lows to highs and back to lows. In Figure 9.5, the
momentum indicator, ROC (%), is able to reflect the cyclicality of the prices clearly.

9.5.3 Detrending for cycle identification


Moving average is normally used to reflect the trend of the underlying price. As
per Hurst (2000), moving average should be plotted at the mean of the average and
not at the end, as the moving average averages not only prices but also the time
under consideration. This is known as the centred moving average. The concept
Time cycles 193

FIGURE 9.5 Cyclicality with momentum indicator (DJIA weekly chart). Created with
Amibroker

of a centred moving average was explained in Chapter 5. So, a 21-week mov-


ing average should be plotted halfway through the average, which is at 11 weeks.
Detrending can be done by dividing the current prices with the centred moving
average of those prices. This will result in an oscillator which will remove the trend
and highlight the cycle under consideration. The lows will normally coincide with
the lows of the cycle.
In the previous charts, we have cited that the DJIA is following a 39-month
cycle. The principle of harmonicity suggests that there is the possibility of a
cycle existing in multiples of 2 or 3. Figure 9.6 shows the centred moving aver-
age of 39 months which is half of a 78-month cycle. The 39-month moving
average is plotted and moved back by 20 months to create the centred moving
average.
In order to detrend the price and to clearly see if the cycle of 78 months exists,
prices are divided by 39-month centred moving average. This results in an oscil-
lator as shown in Figure 9.6. The lows of the oscillator are seen 78 months apart,
which confirms the existence of a 78-month cycle. The moving average smooths
out the cycle within the time span, and by changing the parameter of the cen-
tred moving average and that of the detrended oscillator, multiple cycles can be
identified. The principle of harmonicity also assists in trying to find out cycle in
multiple of 2 or 3.
194 Time cycles

FIGURE 9.6 Detrending using a ratio of price to a 39-month centred moving average


(DJIA monthly 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

9.6 Combining time cycles with an Elliott Wave


Figure 9.9, showing USD/INR, reflects a combination of time cycles with the
Elliott Wave pattern. The following are the important observation:

• The entire rise seen in USD/INR has been in contraction followed by an


expansion pattern, thereby forming Bow-Tie Diametric pattern. Post comple-
tion of wave G, there was a correction on the downside in the form of wave
(X).
• On an average basis, we can see that 85-week time cycles are helping cap-
ture intermediate lows. These 85 weeks are an actual cycle which is in close
approximation to the 80-week nominal cycle identified by Hurst.
• The lows formed in the form of wave B, wave D and wave (X) are very near
to the cycle lows.
• Combining the Elliott Wave pattern with time cycles helps with developing a
very high-conviction trade set-up for a trader as both these independent stud-
ies point towards a similar outcome.
Time cycles 197

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:

• Prices showed a multifold rise and exhibited an extension and subdivision


within wave III. The primary-degree wave III is composed of intermediate-
degree waves 1 to 5.
• Intermediate wave 3 is also showing clear subdivision marked in the form of
waves (i) through (v).
• Time cycles of 164 weeks look to be helpful in identifying important lows in
the form of wave II, wave (iv) of 3, and wave IV.
• The II–IV trend line is an important support. The break below the II–IV trend
line will suggest that wave V on the upside is probably getting completed or
that it is forming and ending a diagonal pattern. For a trader, it is very impor-
tant information.
198 Time cycles

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

synchronous outlook – Elliott Wave, time cycles, Fibonacci retracement, tri-


angle pattern breakout, RSI and MACD positive divergences, MACD crosso-
ver, and Bollinger Bands.
• The target on the upside is derived using the projection of wave A from the
end of wave B. Since wave B retraced only 61.8% of wave A, the possibility of
the entire structure, forming a zigzag Elliott Wave pattern, looked high. Dur-
ing such a scenario, the target level on the upside is normally equality between
wave C to that of wave A, which gave the target of 57 on the upside.
• The level of 57 was also the upper trend-line resistance of the channel.
• A trader could look forward to taking long positions on USDINR near the
breakout of 46 in early August 2011 for a move towards 57, keeping a stop
level at 43.80, which was a little below the lowest point before the breakout.
This gave a risk–reward of nearly 1:4 which provided an excellent opportunity
with a compelling risk–reward ratio.
• Later, the target of 57 was hit by end of June 2012.
• The rise on the upside from the completion of wave B did not follow impul-
sive rules as there was overlap between internal wave iv and wave i, which is
not allowed per Elliott Wave normal impulse patterns. This increased the odds
that wave C is either forming an ending diagonal pattern or the entire rise
since the start of 2008 is a running Diametric structure. This way, by analys-
ing the rules of Elliott Waves, one has to keep evaluating the probable pattern
under development for future forecasting.

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

It formed a triple combination corrective labelled as (W)–(X)–(Y)–(X)–(Z).


There can be a maximum of two “X” waves or three standard corrections con-
nected, and post that, the entire Elliott Wave pattern has to complete, and new
wave pattern should start.
• The first standard correction labelled as wave (W) formed a zigzag pattern.
• The second standard correction labelled as wave (Y) formed an irregular flat
pattern as wave B retraced more than 100% of wave A and wave C formed an
impulse down.
• The third standard correction is labelled as wave (Z) which formed a seven-
legged Diametric pattern.
• Each of these standard corrections is connected with wave (X).
• On 29 February 2016, the Nifty formed a long-legged Hammer pattern that
marked the completion of wave (Z). Post that, there was a strong bullish candle
which further confirmed the reversal on the upside.
• Wave G of (Z) was also associated with a strong positive divergence between
the ROC indicator and prices.
• The reversal was from the lower trend line support of the channel that further
provided a cluster of evidence that the turn probably has to happen which was
confirmed later by a strong bullish candlestick formation post the Hammer.
• With the completion of wave (Z), it was confirmed that the entire down move
of over a year was over and that the next pattern on the upside was starting,
which would probably break above the channel and will retrace towards 61.8%
202 Time cycles

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

10.2 Concept of algorithmic trading


An algorithm, simply put, is a series of steps or instructions which will ensure that
the input generates consistently the intended output. Grandmother’s pickle recipe
and our trading strategy necessarily both work on an algorithm or a set of instruc-
tions we need to follow. Harari (2016) defines an algorithm as ‘a methodical set of
steps that can be used to make calculations, resolve problems and reach decisions’.
These steps need to be discrete and finite. Importantly, it is the steps that matter
most in this process. So a decision on your trading process can be reached with sim-
ple or complex algorithms. For automated frameworks algorithms are unambigu-
ous instructions that can be correctly executed by a computer (Domingos, 2015).
In the context of trading, these instruction are used to generate the buy and sell
signals for the trader so that trading of securities is ‘based strictly on the buy/sell
decisions of computer algorithms’ (Chan, 2009, p. 1). The computers algorithms
thus need to be designed, coded, and then tested by the traders. It is essential to
backtest the strategy on the historical series to measure its performance. In fact, a
key difference between a traditional investment management process and a quanti-
tative investment process is the possibility of backtesting a quantitative investment
strategy to see how it would have performed in the past (Chan, Ibid).
Following Pruitt (2016), the specific criteria for trading algorithms are therefore
inputs (quantities supplies externally), outputs (quantities produced), definiteness
(unambiguity of instructions), finiteness (of instructions), and effectiveness (fea-
sibility). While many algorithmic traders are programmers, they need not be so.
What is essential is that we understand what the computer needs to know to gen-
erate a trading signal (Pruitt, 2016). The computing system needs to be told when
to generate an entry position, when to exit, and what other parameters to note
(profits, money management, etc.) when generating the signal.
Algorithmic trading essentially requires a set of instructions on the trading strat-
egy and data, and we obtain the output in the form of the trading signal. We may
now recognize the steps involved in developing an algorithmic trading strategy:

• 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 Using Excel for algorithmic trading


While there are numerous software programs that are designed for backtesting,
the most basic and common tool for traders, both retail and institutional, is Excel.
Excel continues to play an important role in algorithmic trading scenario (Pruitt,
2016; Chan, 2009). In this section, we take you through using Excel to code strate-
gies, calculating performance metrics, and using Excel for building the algorithmic
trading system and signal generation. Furthermore, a host of basic trading strategies
and their codes in Excel follows in the e-Resource. A basic familiarity with Excel
functions is required, and if you are well-acquainted in the basics of Excel, you can
skip section 10.3.2.

10.3.1 Getting data for backtesting and live


signal generation
One of the most essential things in backtesting and live trading signal genera-
tion is the access to real-time data. A commonly used free data source is Yahoo!
Finance, https://in.finance.yahoo.com. Historical data of major indices and cur-
rencies are available from Yahoo! Finance. While the historical data can be used
for backtesting, once your trading strategy is decided on based on backtesting, the
Excel file should be connected to a live data source for continuous trade signal
generation.
This connection to the external data source can be made from ‘Existing Con-
nections’ in Data Tab (Microsoft Office, 2020), or the set-up can be particular to
a service provider. For example, for accessing data from the Refinitiv (Thomson
Reuters) Eikon database, go to Excel options, enable Com-Add INS. Now you’ll
see the Thomson Reuters icon tab activated on the spreadsheet. To get historical
data, as well as to link the Excel file to live data, sign in to Thomson Reuters. Go
to Formula Builder tab, search for the instrument, and choose the specifications in
preferences (time range, sorting, etc.) and import the data.

10.3.2 Basic Excel functions to know


One reason for the popularity of Microsoft Excel for backtesting and algorithmic
trading is the large number of in-built logical and mathematical functions which
enable extensive data analysis and calculations. This makes the coding of any tech-
nical analysis indicator and trading strategies based on such indicators seamless in
Excel. Familiarity with the basic logical and mathematical functions in Excel is
required for effective backtesting and coding of trading strategies in Excel. In this
section, we give a brief overview of basic Excel functions that have been used for
backtesting in this book. All the formulae used in the examples are available in the
Formula tab of the Excel. The Excel sheet for this section is provided in the eRe-
source, named ‘Chapter10_1’.2
208 Backtesting and algorithmic trading

10.3.2.1 Reference cells: relative references


and absolute references
The Excel syntax is easy to remember: the ‘=’ sign is used in Excel as indicator for
formula. The ‘ ()’ signs are used after writing the formula and denote the array (row
or column of cells) to be used for the formula. For example, for calculating the sum
of number given in cells A1, . . . , A10, we will write in the cell =SUM(A1:A10).
A formula written in an Excel cell, by default, follows a relative reference,
implying that if we copy the cell down the reference array of the cell changes
(Microsoft Office, 2020). For example, let us suppose a company XYZ is interested
to evaluate its exports performance, that is exports made to different countries, in
2019. In the Excel sheet (eResource: ‘Chapter_10_Excel1’), the data on the com-
pany’s exports to two countries, A and B, are given. Let us first calculate in column
C the sum of exports to countries A and B by adding up the values in the columns
B [‘Exports to Country A (USD)’] and C [‘Exports to Country B (USD)’]. For the
first entry in cell D2, we have D2= SUM (B2:C2). As we copy the cell to the row
below, the new formula would be D3= SUM (B3:C3). This way, any particular cell
in column D would sum the values in the two cells to its left.
In some cases, we may want a particular number to be used throughout a cal-
culation, in which case we have to use the Absolute Reference function in Excel.
For example, we may want to convert the average sale figures in column C into
rupee terms. In this case, we have to multiply each of the values by the prevailing
exchange rate. Let us suppose that we will use the exchange rate USD/INR = 70,
which we write in cell B15 of the sheet. In this case, to maintain the original cell
reference, B15 is preceded with a $ sign so that each value in column C would be
multiplied by $B$15. This is shown in Table 10.1. For tables in this section, the
columns are marked alphabetically in the first row for reference.

10.3.2.2 Mathematical functions
The mathematical functions that we will mostly need for backtesting are as follows:

• + – */ for addition, subtraction, multiplication, and division, respectively


• ABS: displays the numbers and absolute (positive) number

TABLE 10.1 Relative references and absolute references

A B C D E

1 Month Exports to Exports to Total exports Exports to


country A (USD) country B (USD) country A (rupee
(USD) value)

2 Jan, 2019 1092000 870000 =SUM(B2+C2) =B2*B$15


3 Feb, 2019 1098000 800000 =SUM(B3+C3) =B3*B$15
4 March, 2019 980000 1290000 =SUM(B4+C4) =B4*B$15
5 April, 2019 340000 1390000 =SUM(B5+C5) =B5*B$15
Source: Author.
Backtesting and algorithmic trading 209

• AVERAGE: calculates the mean of a range of numbers


• COUNT: counts the number of cells in a range
• COUNTIF: counts the number of cells in a range that meet a specified
criterion
• MAX: shows the maximum value in the range
• MIN: shows the minimum value in the range
• SUM: gives a summation of values in a specified range

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.

Combination of IF & AND function


The AND function is used when one or more logical arguments have to be satis-
fied simultaneously. In this example, let us suppose that the company XYZ wants
to know if the exports to both the countries in a particular month have been above
the exports of the previous month. The AND function is given as =AND (logical
arguments, value if true, value if false). AND can be used when two or more than
two conditions are to be simultaneously satisfied.
Here, the AND function would be written as

= IF (AND (B3>B2, C3>C2), “Yes”, “No”).

Note each parenthesis opened must be logically closed in on Excel function.

Combination of IF & OR function


The OR function is used when either of some logical arguments must be satisfied.
In our example, let us suppose, the company XYZ wants to know if exports to
210 Backtesting and algorithmic trading

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

=IF (OR (B3>B2, C3>C2), “Yes”, “No”).

10.3.3 Coding trading strategies


The coding of strategies in Excel opens a realm of opportunities. It tests how well
you can, with the logical and mathematical functions in Excel, frame an executable
trading strategy. In this section, we discuss the coding and calculation of perfor-
mance metrics for two commonly used strategies discussed earlier in Chapters 5
and 6. Before moving to the actual coding of strategies, the data on the price vari-
able (open, high, low, and close) are arranged as shown in Table 10.2. The columns
are mentioned in the first row which will be used as a reference later on as we code
the strategy. The Excel file for this section, named ‘Ch10_2’, is available in the
eResource. In Tables 10.2 to 10.15, the columns are marked alphabetically in the
first row for reference.

10.3.3.1 Simple and Double Crossover strategy


The moving average is one of the simplest yet powerful technical analysis indica-
tors. Two commonly used moving average strategies are the simple and double
crossover methods using price and shorter- and longer-period moving averages.

Trade signal generation


Crossover strategies generate trading signals depending on the position of the price
and shorter- and longer-period moving averages. As a moving average always fol-
lows the market, any change in the market trend will be followed by the moving
average. Thus, if prices start to move downwards, they will cross the lagged mov-
ing average, signifying a crossover to a downtrend. Similarly, if prices start moving

TABLE 10.2 Data arrangement in Excel sheet ‘Ch10_2’

A B C D E

Timestamp Close Open High Low

1/2/2017 68.1389 67.9447 68.225 67.8999


1/3/2017 68.2529 68.1399 68.43 68.0379
1/4/2017 67.8755 68.27 68.29 67.8399
1/5/2017 67.7325 67.885 68.0029 67.7199
1/6/2017 68.09 67.73 68.1729 67.7299
1/9/2017 68.0903 68.1055 68.295 68.06
Source: Author.
Backtesting and algorithmic trading 211

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

EMAt5 = Close Pricet * weight + (1 − weight ) * EMAt −1 , (2)

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.

TABLE 10.3 Calculation of the average, SMA, and EMA

F G H

1 Average SMA5 EMA5

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

Strategy 1: Simple Crossover


Pseudo code of trade signal: Sell when Pt < EMAt20−1 (3a)
Buy when Pt > EMAt20−1 (3b)

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.

Strategy 2: Double Crossover


In coding a double crossover, the buy signal in this example is generated when the
10-period moving average cuts the 20-period average from below. This identifica-
tion of this point on the chart is as follows: in period t − 1, the 10-period average
is below the 20-period average, and then in period t, the 10-period average is
above the 20-period average. The sell signal in this example is generated when the
10-period moving average cuts the 20-period average from above. This identifi-
cation of this point on the chart is as follows: in the period t − 1, the 10-period
average is above the 20-period average, and then the 10-period average is below
the 20-period average.
Pseudo code of trade signal: Buy when

EMAt10−1 < EMAt20−1 ,&

EMAt10 > EMAt20 (4a)

Sell when

EMAt10−1 > EMAt20−1 ,&

EMAt10 < EMAt20 (4b)

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

EMA10 EMA20 DOUBLE CROSS SIGNAL 2 TRANSP1

22 =B22*(2/11)+J21*(1-2/11) =B22*(2/21)+L21*(1-2/21) =IF (AND (J21<L21,J22>L22), =IF(Q21<>“”,F22,R21)


“buy”,IF (AND
(J21>L21,J22<L22),“sell”,“”))
23 =B23*(2/11)+J22*(1-2/11) =B23*(2/21)+L22*(1-2/21) =IF (AND (J22<L22,J23>L23), =IF(Q22<>“”,F23,R22)
“buy”,IF (AND
(J22>L22,J23<L23),“sell”,“”))
24 =B24*(2/11)+J23*(1-2/11) =B24*(2/21)+L23*(1-2/21) =IF (AND (J23<L23,J24>L24), =IF(Q23<>“”,F24,R23)
“buy”,IF (AND
(J23>L23,J24<L24),“sell”,“”))
Source: Author.
*
Where column B g ives close pr ices, and column F gives average pr ices.
Backtesting and algorithmic trading 213
214 Backtesting and algorithmic trading

Entry and exit transaction price


Entry transaction price (ETP) is the open price in the next period, as the strat-
egy is assumed to materialize into a decision in the next period. While it may
be assumed that the transaction price will be either open, close, or average price,
we cannot assume that we will transact at the high or low price. Again, while
transacting at the open price may be a realistic assumption for daily data, it can
hardly be assumed that we will transact on the open price for the next period
for, say, hourly or minute data. If the prior cell is not empty (i.e. there is a buy
or sell signal generated in the previous period), the close price or average price is
taken, or the previous position price continues. This is shown in the last column
of Table 10.5.

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.

TABLE 10.5 Transaction prices and returns*

R S

TRANSP1 RETURNS 2

13 =IF (Q12<>“”, F13, R12) =IF (P12 =“sell”, R13/R12–1, IF (P12=“buy”,


1-R13/R12,“”))
14 =IF (Q13<>“”, F14, R13) =IF (P13 =“sell”, R14/R13–1, IF (P13=“buy”,
1-R14/R13,“”))
15 =IF (Q14<>“”, F15, R14) =IF (P14 =“sell”, R15/R14–1, IF (P14=“buy”,
1-R15/R14,“”))
16 =IF (Q15<>“”, F16, R15) =IF (P15 =“sell”, R16/R15–1, IF (P15=“buy”,
1-R16/R15,“”))
Source: Author.
*
Where column Q gives the double crossover signal.
Backtesting and algorithmic trading 215

TABLE 10.6 Performance metrics of double crossover signals 1 and 2

Double Cross Signal 1 Double Cross Signal 2

Average Returns 0.1466% 1.8071%


Standard Deviation 1.6435% 2.9300%
Cumulative Returns 5.57% 27.11%
Source: Author.

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

TABLE 10.7 RSI calculation*

B G H I J K L M

Close UP CLOSE/ UP CLOSES DOWN UPSUM DOWN SUM RS RSI


DOWN
Backtesting and algorithmic trading

15 68.09 =B15-B14 =IF(G15 > 0,G15,0) =IF(G15<0,ABS(G15),0)


16 68.05 =B16-B15 =IF(G16 > 0,G16,0) =IF(G16<0,ABS(G16),0) =SUM(H3:H16) =SUM(I3:I16) =J16/K16 =100-(100/(1+L16))
17 68.04 =B17-B16 =IF(G17 > 0,G17,0) =IF(G17<0,ABS(G17),0) =SUM(H4:H17) =SUM(I4:I17) =J17/K17 =100-(100/(1+L17))
18 68.12 =B18-B17 =IF(G18 > 0,G18,0) =IF(G18<0,ABS(G18),0) =SUM(H5:H18) =SUM(I5:I18) =J18/K18 =100-(100/(1+L18))
Source: Author.
*
Where column B g ives close pr ices.
Backtesting and algorithmic trading 217

calculate the up close or down close in prices. It is given by a particular period’s


price minus the price in the previous period. In the next two columns, we separate
the up closes from down closes as the calculation of the RSI requires the summa-
tion of up closes and down closes separately. To do this, we use the IF condition
in the Excel, separating the positive and negative values as shown in Table 10.8.
It must be noted that the down closes in column I must be recorded as absolute
numbers, so we use the ABS function to convert the negative to ABS values. The
default period for the RSI is 14, and therefore, in column J, the summation of the
previous 14 up closes is calculated. Similarly, column K calculates the summation
of the previous 14 down closes (expressed in absolute terms). The ratio of UPSUM
and DOWNSUM gives the RS value, and using the RS value, the RSI value is
calculated in column M. It may be noted that the operations in columns J to M
can be done in the one column, but we separate out each step here for simplicity.
The RSI values calculated in column M is used to generate the trading signals
in column N. In this example, we’ll be generating the trading signals for long
and short strategies separately. We begin with the long strategy and generate the
trading signal if the RSI value was less than 50 in the previous period and moved
above 50 in this period. In Excel (row 20, say), the trading strategy is coded as
=IF(AND(M19 < 50,M20 > 50),1,0), where column M gives the RSI values, as
shown in Table 10.8.
To calculate the take-profit and the stop-loss levels, we use the ATR here. For
calculating the ATR (Table 10.9), we calculate first the difference between the
present period’s high and low in column O. Next we calculate the difference the
previous period’s close and the present period’s high (column P) and the absolute
difference the previous period’s close and the present period’s low (column Q).
The maximum of the previous three values calculated is shown in column R. The
ATR is calculated, as suggested by Wilder, who developed the indicator as shown
in Table 10.9.
Next, the entry price is calculated. As the data are of daily frequency, and RSI
values are calculated using the close prices, any signal can translate into a trade trans-
action only in the next period. If a signal (long) is generated (by end of previous

TABLE 10.8 Entry and transactions prices*

N T

SIGNAL RSI (Long) Entry price

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

TABLE 10.9 ATR calculation*

O P Q R S

H-L H-CLOSE L-CLOSE MAX ATR

16 =D16-E16 =ABS(D16- =ABS(E16- =MAX =AVERAGE


B15) B15) (O16:Q16) (R2:R16)
17 =D17-E17 =ABS(D17- =ABS(E17- =MAX =((S16*13)+
B16) B16) (O17:Q17) R17)/14
Source: Author.
* Where column B gives the close, column D gives the high, and column E gives the low.

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

TABLE 10.10 Calculation of take-profit and stop-loss levels*

T U V

Entry price TP Price SL Price

19 =IF(N18<>0, =IF(N18 = 1,T19+S19*6,U18) =IF(N18 = 1,T19-S19*2,V18)


F19,T18)
20 =IF(N19<>0, =IF(N19 = 1,T20+S20*6,U19) =IF(N19 = 1,T20-S20*2,V19)
F20,T19)
21 =IF(N20<>0, =IF(N20 = 1,T21+S21*6,U20) =IF(N20 = 1,T21-S21*2,V20)
F21,T20)
Source: Author.
* Where column N gives the signal, column F gives the average prices, and column S gives the ATR.

TABLE 10.11 Calculation of trade running, profit-target hit, and stop-loss hit*

W X Y

TRADE RUNNING Profit-Target Hit Stop-Loss Hit

19 =IF(OR(N18 = 1,W18 = 1), =IF(AND(W18 = 1, =IF(AND(W19 = 1,


IF(D19<U19,IF(E19>V19, D19>U18),“TP”,0) E19<V19),“SL”,0)
1,0),0),0)
20 =IF(OR(N19 = 1,W19 = 1), =IF(AND(W19 = 1, =IF(AND(W20 = 1,
IF(D20<U20,IF(E20>V20, D20>U19),“TP”,0) E20<V20),“SL”,0)
1,0),0),0)
21 =IF(OR(N20 = 1,W20 = 1), =IF(AND(W20 = 1, =IF(AND(W21 = 1,
IF(D21<U21,IF(E21>V21, Dvv E21<V21),“SL”,0)
1,0),0),0) 21>U20),“TP”,0)
Source: Author.
* Where column N gives the signal, column D gives the high, column E gives the low, column U gives
the take-profit level, and column V gives the stop-loss level.

TABLE 10.12 Calculation of exit and profit/loss percentage in Excel*

Z AA

Exit price Profit/Loss %

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.

TABLE 10.13 Calculation of performance metrics in Excel*

Y Z

Total gross wins =SUMIF(AA$17:AA$538,“>0”)


Total gross losses =SUMIF(AA$17:AA$538,“<0”)
Profit factor =ABS(Z543/Z544)
Number of winning trades =COUNTIF(AA$17:AA$538,“>0”)
Number of losing trades =COUNTIF(AA$17:AA$538,“<0”)
% of profitable trades =Z546/(Z546+Z547)
Source: Author.
* Where column AA gives the profit/loss percentage.

TABLE 10.14 Evaluation of the trading strategy

Long Trades Short trades

Total gross wins 6258.6 11463.0


Total gross losses −5750.4 −1690.0
Profit factor 1.1 6.8
Number of winning trades 3 3
Number of losing trades 7 1
% of profitable trades 30% 75%
Max drawdown 38% 10%
Source: Author.
Backtesting and algorithmic trading 221

FIGURE 10.1 Accessing data from Eikon: flow chart


Source: Author

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

FIGURE 10.2 Downloading Python from Anaconda: flow chart


Source: Author

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

Assigning values in Python


It is important to remember that Python reassigns values to the variables we are
defining. For example, if x is initially assigned the value of 90 and again the same
variable x is assigned the value of 1, the value is reassigned and the output obtained
for variable x is 1.

[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

• Basic arithmetic operators: The basic arithmetic operations are performed


using the said operators in Python 3 (Table 10.15).

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().

TABLE 10.15 Operators in Python (in ascending order of precedence)

Operators Operation Example Result

+ 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]: type (99)


[Out]: int

[In]: type (0.99)


[Out]: float

[In]: type (‘float’)


[Out]: string

Comparison and logical operators


In Python, along with > and <, we use == (equality) and != (inequality) compari-
son operators. We can compare values in Python using the comparison operators
and get Boolean values as output. For example,

[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,

[In]: False or Not True and True


[Out]: False

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’.

Lists, dictionaries, and tuples


Lists, dictionaries, and tuples are built-in data structures in Python containing a
number of other objects (Hilpisch, 2018). They help with categorizing data into
groups or built-in data structures and are used to assign values to variables. These
can contain any type of data. The major difference between lists and dictionaries
is that lists are mutable, ordered sequences of arbitrary objects whereas dictionaries
are unordered sets. Dictionaries are accessed via keys and not via their position as
shown in the notebook Pythonbasics. A tuple is a sequence of immutable Python
objects, unlike lists, which are mutable. This means that they cannot be changed
Backtesting and algorithmic trading 225

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.

[In]:my_list= [1,2,3] Define a List


[In]:my_list
[Out]:[1, 2, 3]
[In]:my_list.append(4)
[In]:my_list
[Out]: [[1, 2, 3, 4] Appends elements (of differ-
ent types) to list objects
[In]:my_list.append
(“class”)

[In]:nested_list= Create a list which includes


[1,2,3,my_list] previous list
[In]:nested_list
[Out]: [[1, 2, 3, [1, 2, 3,
4, ‘class’]]
[In]:nested_list[3] Call an element indexed 3
[Out]: [1, 2, 3, 4, ‘class’] from the new list

Creating functions in Python


To create a function in Python, we use keyword ‘def ’, followed by the function
name and parameters (if any) in parentheses, followed by a colon. A function can
have even zero parameters. If the function is long enough, the next line begins with
an indent. The syntax structure for a function follows:
def function_name (parameters):

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]: def first():


print (“my_function”)
226 Backtesting and algorithmic trading

[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.

If, Else, and Elif statements


If, Else, and Else If (Elif) statements are very important for programming. With an
If function, we ask certain tasks to be done (say, print ‘Yes’) if a certain condition is
satisfied. Else gives what should be done if the condition is not satisfied. Elif gives
an elegant way to add a second condition to the If function. Let us see an example.
We define a function with ‘def ’ variable called ‘factor_of_five’. If x modulus 5 is
equal to zero, we want to print ‘Factor of five’ This would be written as

[In]: def factor_of_five(x):


       if x % 5 = = 0:
         print (‘Factor of 5’)

Once defined, we can check the code by giving a specific number to check:

[In]: factor_of_five (15)


[Out]: Factor of five

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,

[In]: def factor_of_five(x):


      if x % 5 = = 0:
        print (‘Factor of 5’)
     else:
        print (‘Not factor of 5’)

Once defined, we can check the code by giving a specific number to check:

[In]: factor_of_five (18)


[Out]: Not factor of 5
Backtesting and algorithmic trading 227

Elif allows another condition to be introduced in the statement. For example,

[In]: def Compare_to_1000(y):


if y > 1000:
print (‘Y is greater than 1000’)
elif y < 1000:
print (‘Y is less than 1000’)
else:
print (‘Y is equal to 1000’)

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.

[In]: seq = [5,10,15,20,25]


for item in seq:
print (item**2)
[Out]: 25
100
225
400
625

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

[In]: for item in range(0,100,20):


print (item**2)
[Out]: 0
400
1600
3600
6400

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.

[In]: def square(var):


return var**2
[In]: square (8)
[Out]: 64

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 var: var*2

Lambda functions are especially useful when using maps and filters as we will
see in the following subsection.

Maps and filters


The map function is an in-built function in Python and enables the iteration over a
sequence defined by us. In other words, it maps a function to an iterable sequence.
For example, the lambda defined earlier can be used for a sequence [1, 2, 3, 4] to
generate the list of numbers in the sequence multiplied by 10.

[In]: seq = [1,2,3,4]


list (map (lambda var: var*10, seq))
[Out]: [10, 20, 30, 40]
Backtesting and algorithmic trading 229

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

[In]: list (filter (lambda var: var% 2= = 0, seq))


[Out]: [2 4]

The basic operations explained here are given in the eResources notebook File
Ch10_NB1, and working with arrays is covered in Ch10_NB2.

10.4.2 Using Python for backtesting

10.4.2.1 Importing modules and packages


To effectively use Python for analysing data and backtesting our strategies, we need
to be familiar with modules and packages. Modules are prewritten codes which
define functions, classes, and variables and can be effectively used for financial analy-
sis on Python. Packages or libraries are groups of modules. The Python Standard
Library is a collection of modules available as we install Python. For example, the
map or filter function discussed in the previous section is in-built in Python. Besides
the standard library, there are libraries which are essential for financial analysis which
we will be installing now. The important libraries which you must have for the
analysis we will be doing are numpy (for scientific computing), pandas (for time-
series data analysis), matplotlib (two-dimensional plotting library for visualization of
computations). These three libraries are a part of Scypy group of libraries, a Python-
based ecosystem of open-source software for mathematics, science, and engineer-
ing.5 Three other modules which are essential for data analysis are a math module
(for mathematical functions), a random module (for generation of random num-
bers), and a statsmodels module (for statistical analysis). The previously mentioned
libraries and modules are part of the Anaconda package. For any other packages
which we want to install in Anaconda, we need to go to Anaconda Prompt which
you can access through the Start menu and pip install the said function. For example,
if we want to install pandas_datareader package, an extension in pandas, we go to

Start> Anaconda Prompt>


and put the following command:
<base> C:\Users\Smita Roy>pip install pandas_datareader

Importing of any module or library is done by inputting


Import (module/ library name).

For example to import numpy, we can write

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.

10.4.2.2 Importing data to Python notebook


and saving output
The codes for this section are given in Python notebook file ‘Ch10_NB3’. We will
first do the usual imports of numpy, pandas, datetime, matplotlib and pandas_data-
reader as explained earlier. There are two ways to import data in Python:

1. From the web using the pandas_datareader


Let us suppose we want to look at the data from Apple share price from Yahoo!
Finance.

[In]: start=dt.datetime (2014,1,14)


end=dt.datetime (2020,4,7)
sbi=web.DataReader(‘SBIN.NS’, ‘yahoo’, start, end)
sbi.head()

[Out]:

High Low Open Close Volume Adj Close


Date
2014–01–14 164.899994 162.335007 163.500000 162.750000 10197000.0 135.045486
2014–01–15 165.800003 163.199997 163.199997 164.070007 13624980.0 136.140793
2014–01–16 165.175003 163.244995 164.414993 163.619995 7241970.0 135.767410
2014–01–17 164.449997 161.699997 163.455002 162.154999 11207380.0 134.551773
2014–01–20 164.589996 161.664993 162.154999 164.184998 9468650.0 136.236206

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.

[In]: from pandas_datareader import data as web


from alpha_vantage.timeseries import TimeSeries
ts =TimeSeries (key=‘****’, output_format =‘pandas’)
data, metadata =ts.get_intraday (symbol=‘AAPL’,
interval =’1min’, outputsize=‘full’)
data.head(5)

[Out]:

1. open 2. high 3. low 4. close 5. volume


date
2020–02–12 09:31:00 322.2000 322.2000 322.2000 322.2000 919596.0
2020–02–12 09:32:00 322.2397 322.9223 322.1232 322.6120 156717.0
2020–02–12 09:33:00 322.6316 323.1089 322.2491 322.6916 171635.0
2020–02–12 09:34:00 323.0100 323.1200 323.0100 323.1200 311919.0
2020–02–12 09:35:00 323.1500 323.1500 322.9996 322.9996 154595.0

2. Importing data from Excel or a csv file


We can use the Excel or. csv (comma-separated values) files to get data in Python.
It is very important in this case to specify the correct directory for the file. In the
notebook file ‘Ch10_NB3’, we retrieve data from the Excel file as shown in the
following. In pandas, pd.read functions enable the importing of data from various
formats.
232 Backtesting and algorithmic trading

[In]: inr= pd.read_excel(‘D:inr.xlsx’)


inr.head()

[Out]:

Timestamp Close Open High Low


0 2017–01–02 68.1389 67.9447 68.2250 67.8999
1 2017–01–03 68.2529 68.1399 68.4300 68.0379
2 2017–01–04 67.8755 68.2700 68.2900 67.8399
3 2017–01–05 67.7325 67.8850 68.0029 67.7199
4 2017–01–06 68.0900 67.7300 68.1729 67.7299

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]:

Timestamp Close Open


0 2017–01–02 68.1389 67.9447
1 2017–01–03 68.2529 68.1399
2 2017–01–04 67.8755 68.2700
3 2017–01–05 67.7325 67.8850
4 2017–01–06 68.0900 67.7300

It is important to note that the path of file must be specificed correctly.


To retrieve data from a csv format file saved on D drive:
Backtesting and algorithmic trading 233

[In]:data2=pd.read_csv(‘D:/inr.csv’)
data2.head()

[Out]:

Timestamp Close Open High Low


0 2017–01–02 68.1389 67.9447 68.2250 67.8999
1 2017–01–03 68.2529 68.1399 68.4300 68.0379
2 2017–01–04 67.8755 68.2700 68.2900 67.8399
3 2017–01–05 67.7325 67.8850 68.0029 67.7199
4 2017–01–06 68.0900 67.7300 68.1729 67.7299

a. Arranging data and setting an index


As you can see in the data imported from the Excel file, the index column is
not the Timestamp column which is required for time-series analysis. In the
outputs shown earlier, the Timestamp column is not the index column, and
this can also be seen by asking for information on the Dataframe with the info
command.

[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

As we can see in Output Timestamp column, although marked as a datetime


object, does not appear as the index. We can index the Time column in two ways:

b. Use of the ‘Index_col’ option in pd.read


[In]: inr=pd.read_excel(‘D:/inr.xlsx’,index_col=‘Timestamp’)
inr.head()
234 Backtesting and algorithmic trading

[Out]:

Close Open High Low


Timestamp
2017–01–02 68.1389 67.9447 68.2250 67.8999
2017–01–03 68.2529 68.1399 68.4300 68.0379
2017–01–04 67.8755 68.2700 68.2900 67.8399
2017–01–05 67.7325 67.8850 68.0029 67.7199
2017–01–06 68.0900 67.7300 68.1729 67.729

c. Use to_index option


[In]: inr1=pd.read_excel(‘D:inr.xlsx’)
inr1[‘Timestamp’]=pd.to_datetime(inr1[‘Timestamp’])
inr1.set_index(‘Timestamp’,inplace=True)
inr1.head()

[Out]:

Close Open High Low


Timestamp
2017–01–02 68.1389 67.9447 68.2250 67.8999
2017–01–03 68.2529 68.1399 68.4300 68.0379
2017–01–04 67.8755 68.2700 68.2900 67.8399
2017–01–05 67.7325 67.8850 68.0029 67.7199
2017–01–06 68.0900 67.7300 68.1729 67.729

d. Index setting for non-formatted data


Let us now see how to arrange data in case the Time column is unformatted. The
‘new 2’ Datafame created does not have the Date column defined as either a date-
time object or indexed.

[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’)

10.4.2.3 Visualizing the data using matplotlib


We now visualize the data using options in matplotlib, such as. plot or plt:

[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]:

FIGURE 10.3 Python output (INR open prices)


Source: Author

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.

10.4.2.4 Backtesting in Python: coding a moving average


strategy
With the data retrieved from web or from an Excel file, let us now move to the
actual coding of a strategy in Python. However, before that, a quick note on all the
financial calculations that can be done in Python and which are useful for backtest-
ing. The remaining part of notebook Ch10_NB3b covers these financial calcula-
tions: the computation of average, standard deviation, correlation, and covariance
of a series, as well as the calculation of metrics for a portfolio. We limit from dis-
cussing these financial computations here for sake of brevity. Along with notebook
Ch10_NB3, a self-explanatory help file is provided with the details.
‘Ch10_NB4’ gives the backtesting using a moving average strategy as follows:
a. We import and visualize the data as explained earlier.

[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]:

High Low Open Close Volume Adj Close


Date
2014-03-03 336.00 331.60 332.60 333.10 1839216.0 306.62
2014-03-04 336.92 332.12 333.00 335.85 3221934.0 309.15
2014-03-05 337.50 331.25 336.75 334.88 2003492.0 308.25
2014-03-06 338.85 334.05 336.50 337.80 2474340.0 310.94
2014-03-07 357.45 338.10 339.80 355.73 11383784.0 327.44

[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]:

FIGURE 10.4 Python output (HDFC adjusted close and open prices)


Source: Author

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]:

High Low Open Close Volume Adj Close log_returns

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

Adj Close log_returns SMA30 SMA40 EMA30 EMA40

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]:

SMA30 SMA40 EMA30 EMA40 signal1


count 1466.00 1456.00 1466.00 1456.00 1495.00
mean 758.80 758.96 758.31 758.46 0.51
std 286.16 284.94 285.23 283.75 0.84
min 334.40 334.04 333.65 333.90 -1.00
25% 497.92 497.52 498.13 499.35 0.00
50% 684.78 685.43 682.13 680.00 1.00
75% 1019.93 1017.54 1017.74 1018.34 1.00
max 1273.16 1270.94 1272.76 1268.41 1.00

In this case, we use a nested np.where to allow multiple conditions to be satis-


fied in np.where. Again, the describe function allows us to get details on the series.
f. We can code only the crossover points as done earlier in double crossover
strategy coding in Excel (section 10.3.3.1.). In Python, for deriving the crossover
Backtesting and algorithmic trading 241

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]:

SMA30 SMA40 EMA30 EMA40 signal2


count 1466.00 1456.00 1466.00 1456.00 1495.00
mean 758.80 758.96 758.31 758.46 0.00
std 286.16 284.94 285.23 283.75 0.12
min 334.40 334.04 333.65 333.90 -1.00
25% 497.92 497.52 498.13 499.35 0.00
50% 684.78 685.43 682.13 680.00 0.00
75% 1019.93 1017.54 1017.74 1018.34 0.00
max 1273.16 1270.94 1272.76 1268.41 1.00

g. An easier way to do the preceding without the use of & conditionality is as


follows:
We generate the buy signals column using np.where function and then the. diff
function to get the long and short signals together. The describe function details
the output.

[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

h. Finally, we calculate the strategy returns column by multiplying the log


returns of the series with signals generated in the previous period. This lag is
essential as all moving averages are calculated on the close prices, and therefore,
signals are generated only at the end of the period. This means that the trade can
be executed only in the next period, and therefore, the returns of the next period
tell us how the long or short strategy has actually performed. We therefore calculate
the returns for each of the three strategies.

[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’.

10.4.2.5 Backtesting in Python: coding an RSI strategy


a. We now calculate the RSI in notebook Ch10_NB5 as follows. The import of the
SBI data and the visualization are skipped here but shown in the file ‘Ch10_NB5’.

[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

b. Next we generate the signals:

[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

c. We can see the number of signals generated

[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.

Using the Quantopian platform to backtest your strategy7


Backtesting in Python helps to handle complex strategies and an enormous amount
of data. It is also possible to use platforms like Quantopian to share trading strate-
gies and learn from a growing network of algorithmic traders developing newer
strategies. Quantopian is a crowdsourced quantitative investment firm and has a
unique IDE to write and test trading strategies. Quantopian also provides capital to
algorithmic traders for algorithms that are suitable for its investment strategy. You
can create an account (free) in Quantopian, write your strategies in its IDE, and
backtest them on data on US equity stocks. In the eResources, we have included
a Quantopian coding Word document (‘Ch10_Quantopian strategy code’), with
details of how technical analysis strategies can be coded in Quantopian IDE. The
two examples given are simple crossover strategy and the Bollinger Band strat-
egy. Running the backtest on the Quantopian platform gives us the performance
metrics of the strategy over any specified period. To use the algorithm written for
live trade (please see e_Resource Ch_10_Live_signal_generation), we can use the
broker-provided platforms to run our strategy.
Thus, we see that we can backtest trading strategies using either Excel or Python.
Backtesting helps us to know how the trading strategies have performed on his-
torical data and if such a strategy can therefore be used for creating algorithms.
The strategies which give good results in backtesting can be used for algorithms
as explained. It is important for a trader to backtest the strategies used even if such
strategies not being used for algorithmic trading. Backtesting gives us an objective
view of our sstrategies’ performance and is essential for risk mitigation.

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

6 A pseudo code transforms a trading strategy from the language-based descrip-


tion to a structure which can be coded for the computer.
7 Excel and Python are both highly adaptable and powerful backtesting
platforms.
8 A fully automated trading system accesses the live data from the database, gen-
erates trading signals, and finally submit the orders to a broker for execution
using the broker’s API.
9 A semi-automated system can also be used which generates live signals for
trades, but the trader decides whether each signal would be translated to a
trade.

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

Simplicity in complex systems’ behavior is everywhere. For this very reason, it is


apt not to be noticed, or if noticed, to be taken for granted.1
− Strevens

We started on this journey with a view to understanding and applying technical


analysis to trade effectively in financial markets. The various domains of technical
analysis are indeed tools which work best when used together. As we conclude, we
take you through the recent market developments, spanning across countries and
sectors to help application of technical analysis.
Figure 11.1 shows movement in the DJIA (USA), the DAX (Germany), the
Nikkei 225 (Japan), and the Nifty 50 (India) which have all exhibited synchronized
sell-off with the onset of 2020. Japanese major equity index Nikkei 225, in fact,
topped out much earlier and provided an early warning sign. There is also a nega-
tive divergence between different global indices. The crash in 2020 is very much
apparent in the majority of the world’s equity markets apart from the ones shown
earlier. Such a systematic and synchronized sell-off was earlier seen in 2008. There
is no benefit of diversification across the world’s markets as the correlation increases
drastically during the crash. Lower highs seen in Nikkei225, as compared to other
indices, were also an early warning signal. Technical analysis provided substantial
evidence before 2020 that a rise from 2008 till 2019 had been in much-matured
stages, as discussed in earlier chapters.
It is important to see varied asset performance during 2020, as we have embarked
on a historical event of global market meltdown along with the ongoing pandemic.
In Figure 11.2, the crude oil chart shows that post topping out in 2008, it has con-
tinued in a downward spiral. Interestingly, the selling pressure has again intensified
in this commodity with the beginning of 2020. In fact, one of the biggest monthly
Conclusion 247

FIGURE 11.1 
Globalindices at a glance, 2009–2020 (monthly chart). Created with
Amibroker

FIGURE 11.2 Crude oil (monthly chart). Created with Eikon, Refinitiv


248 Conclusion

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.3 EUR/USD (monthly chart). Created with Eikon, Refinitiv


Conclusion 249

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

Oberlechner, T. (2001). Importance of technical and fundamental analysis in the European


foreign exchange market. International Journal of Finance and Economics, 6(1), 81–93.
OECD Glossary of Statistical Terms. (2019). Financial intermediation. Retrieved from https://
stats.oecd.org/glossary/detail.asp?ID=972
Omrane, B. W., and Hafner, C. H. (2015). Macroeconomic news surprises and volatility
spillover in foreign exchange markets. Empirical Economics, 48(2), 577–607.
Perez, C. (2002). Technological revolutions and ‘financial capital’: The dynamics of bubbles
and golden ages. Northampton, MA: Edward Elgar Publishing Inc.
Pinches, G. E. (1970). The random walk hypothesis and technical analysis. Financial Analysts
Journal, 26(2), 104–110.
Prechter, R. (1990). The major works of R. N. Elliott (2nd ed.). Gainesville, GA: New Clas-
sics Library.
Prechter, R. (2016). Socionomic theory of finance. Gainsville, GA: Socionomics Institute Press.
Prechter, R., and Frost, A. (2005). Elliott wave principle (10th ed.). Gainesville, GA: New
Classics Library.
Pring, M. J. (2014). Technical analysis explained (5th ed). Mc Graw Hill: New Delhi
Pruitt, G. (2016). The ultimate algorithmic trading system toolbox. John Wiley & Sons.
Rajan, R. G., and Zingales, L. (1998). Financial dependence and growth. American Economic
Review, 88(3), 559–586.
Ramakrishnan, R. T. S., and Thakor, A. (1984). Information reliability and a theory of
financial intermediation. Review of Economic Studies, 51, 415–432.
Rockefeller, B. (2002). The global trader: Strategies for profiting in foreign exchange, futures, and
stocks, Wiley Trading Advantage, Volume 104 of Wiley Trading. John Wiley & Sons.
Roy Trivedi, S. (2019). The Moses effect: Can central banks really guide foreign
exchange markets? Empirical Economics. 58, pp. 2837–2865. https://link.springer.com/
article/10.1007/s00181-019-01671-y
Roy Trivedi, S. (2020a), ‘“Manna from heaven”: Does central bank intervention make technical
analysis profitable?’, European Journal of Economics and Economic Policies (EJEEP). (Forthcoming)
Roy Trivedi, S (2020b), Technical analysis using Heiken Ashi Stochastic (HASTOC): To
catch a trend, use a HASTOC, International Journal of Finance and Economics. (Forthcoming)
Roy Trivedi, S., and Bhattacharya, S. (2018). Financial economy: Evolutions at the edge of crises.
UK: Taylor & Francis.
Saacke, P. (2002). Technical analysis and the effectiveness of central bank intervention. Jour-
nal of International Money and Finance, 21, 459–479.
Schwert, W. (1989). Why does stock market volatility change over time? Journal of Finance,
44(5), 1115–1153.
Shiller, R. J. (2016). Irrational exuberance (3rd ed.). New Jersey: Princeton University Press.
Shleifer, A., and Vishny, R. (1997). The limits of arbitrage. Journal of Finance, 52(1), 35–55.
Silber, W. L. (1994). Technical trading when it works and when it doesn’t. The Journal of
Derivatives, 1(3), 39–44.
Soros, G. (2015). The alchemy of finance. John Wiley & Sons.
Strevens, M. (2009). Bigger than chaos: Understanding complexity through probability. London:
Harvard University Press
Surajaras, P., and Sweeney, R. J. (1992). Profit-making speculation in foreign exchange markets.
Boulder: Westview Press.
Szakmary, A. C., and Mathur, I. (1997). Central bank intervention and trading rule profits
in foreign exchange markets. Journal of International Money and Finance, 16, 513–535.
Taleb, N. N. (2001). Fooled by randomness: The hidden role of chance in life and in the markets.
Penguin Random House LLC.
References 259

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

effective trading 7 financial intermediation 7, 8


efficient market hypothesis (EMH) 3, 5, 15 financial markets 1, 4, 5, 7 – 11, 13, 15 – 17,
efficient market paradigm 4 – 5 94, 135, 136; functions of 7 – 8; types
El-Erian, Mohamed A. 16n1 8 – 10
Elliott, Ralph Nelson 150 financial market volatility 13 – 14
Elliott Wave 150 – 156, 181 – 183, flags 56, 66; patterns 58, 63
196 – 202, 249 flat correction pattern (3–3–5) 164 – 169;
Elliott Wave pattern 182, 196 – 198, double and triple flat correction 167,
201, 249 168, 169; irregular flat correction 165,
Elliott Wave Principles 150 – 184; 166; regular flat correction 164, 165;
Fibonacci sequence 151; golden ratio running flat correction 165, 167
151; impulse patterns, understanding Fleming, M. J. 135, 136
151 – 160 foreign exchange markets 2, 4, 5, 9 – 11,
Elliot Wave Theory 148 14 – 15, 135
empirical studies 16 forex quote 9 – 10
ending diagonal 157 – 159, 164, 180, 200 Frost, A. J. 151
engulfing pattern (tsutsumi) 75, 76, 83 fundamental analysis 2 – 4, 6, 16
entry price 217 – 219
entry transaction price (ETP) 214 Galton, Francis 94
equity markets 2, 5, 246, 251, 253 gaps 59 – 66, 88, 89, 93, 132; breakaway
equity ownership 8 gaps 59, 60; case studies 63 – 65;
equity securities: types and combining with other patterns 63 – 65;
characteristics 9 exhaustion gap 61; Island Reversal
Evening Star And Morning Star 80, 81 61 – 63; runaway gap 59, 60
excel 205, 207 – 221; basic excel functions GBP/USD movement 19
207 – 210; coding trading strategies Gehrig, T. 3 – 5
210 – 221; data arrangement 210; data golden ratio 151
for backtesting and signal generation good-on-close orders 14
207; entry transaction price (ETP) good-till-cancelled orders 14
214; exit transaction price 214; return Grafton, Christopher 188
calculation 214; RSI strategy 215 – 221;
simple and double crossover strategy Hanging Man And Hammer 73, 75, 92
210 – 214, 215; trade signal generation Harami pattern 82, 85
210 – 211 Harari, Y. N. 204
exchanges 2, 4 – 6, 9 – 11, 13 – 15, 47, 67, harmonicity 188 – 190, 193, 195, 202;
135, 136, 208 principle of 188
execution instructions 13 – 14 Heads and Shoulders pattern 45 – 47, 50,
exhaustion gap 59, 61 – 62, 132 66, 88
exit price 218, 219 Heiken Ashi (HA) candlesticks 23 – 26
exponential moving average (EMA) 97 – 99, Heiken Ashi (HA) stochastic 125 – 126, 221
101, 104 – 106, 110, 112, 118, 122, 200, Hellwig, M. F. 6
211, 212, 238 – 240 heterogeneity 136
external finance 7, 16; reducing cost to higher-degree waves 151, 154, 158, 183
firms 7 Hilpisch, Y. 222
Homma, Munehisa 67
fan lines 34 hourly chart 36, 46, 73, 132, 133, 139,
Fibonacci numbers 151, 183 140, 142, 155, 156
Fibonacci retracement level 40, 198 Hsu, P.-H. 4
Fibonacci sequence 151 Hurst, J. 186, 188, 189, 192, 194
fifth failure pattern 159, 160, 180
figure charts 21 – 22 IF function 209 – 210
‘fill-or-kill’ orders 14 immediate-or-cancel orders 14
financial assets 7, 8, 10, 16 impulse pattern 151 – 152, 154 – 157, 159,
financial intermediaries 7, 8, 16 161, 164 – 165, 179 – 180, 182 – 183
Index 263

impulse pattern completion confirmation market psychology 5, 32, 68


179 – 180 markets 1, 2, 5, 6, 8, 10, 14, 18, 27 – 29, 32,
impulse patterns, understanding 151 – 160; 69, 70, 74, 105, 120, 142, 215, 253
diagonal pattern 156 – 158; fifth failure market sentiment 70, 92, 131
pattern 159, 160; rules of 152 – 154; market volatility 6, 13, 135, 136, 142
understanding degrees 154; variations to Marubozu candles 70
154 – 156 Mastering Hurst Cycle Analysis 188
impulse waves 151 – 155, 157, 160, 161, matplotlib 221, 229, 230, 236, 237, 239
164, 183 Menkhoff, L. 3 – 6
Indian equity markets 128, 251, 253 Microsoft Excel 203, 207; see also excel
information 5, 8, 13, 14, 16, 17, 23, 27, momentum 113 – 131, 133, 249
135, 136, 140 momentum indicators 111, 113 – 119, 127,
information provision 8 129, 130, 133, 192, 193; case studies
informed traders 14, 136 127 – 133; Nifty 50 index 128 – 133; State
integrated development environments Bank of India (SBI) 127 – 128
(IDEs) 221 money markets 8, 15
intermediaries 11 – 12 Morning Star patterns 80, 81
Inverse Head And Shoulders 45, 46 movement of prices 2, 96, 116
investment 2 moving average convergence divergence
irregular flat pattern 164, 165, 201 (MACD) 122 – 124, 128 – 130, 133, 199,
Island Reversals 61 200, 202
moving average envelopes 137, 141, 148
Japanese bar charting technique 23, 68; see moving averages concept 94 – 97, 99,
also candlesticks 102, 104 – 112, 122, 123, 137, 210,
jobbing 16n2 211; adaptive moving average (AMA)
Jupyter 221 99 – 101; case studies 109 – 111; centred
moving average 102, 103; choice of
Kahneman, Daniel 94 period 102, 104; exponential moving
Kaufman, P. J. 99 average (EMA) 98 – 99; linearly
weighted moving average (LWMA)
Lakonishok, J. 4 97 – 98; SMA 97; for trading 109 – 111;
last n periods 95 trend, support and resistance 104 – 106;
leading diagonal 157 use of 105 – 106
LeBaron, B. 4 Multi Commodity Exchange 47
left and right translation 187 multiple cycles 186 – 188, 193
limit orders 13, 15 Murphy, John 17, 18, 27, 29, 31, 32, 113
linearly weighted moving average 97
line chart 20, 21 Neely, Glenn 173 – 180, 183
liquidity 8 – 13, 16, 135 negative divergence 120, 121, 123,
live signal generation 206, 207 127 – 131, 133, 246, 249, 250
long-body candles 69 NEoWave 173 – 178, 180, 183
long lower shadows only 71 New Concepts in Technical Analysis 141
long positions 12 Nifty 50 43n3, 46, 58, 128 – 133, 140,
long-term debt securities (bonds) 8 147 – 148, 155, 158, 246, 248, 249, 251
long upper shadows only 71 Nikkei 225 246
Nison, Steve 67, 81
macroeconomic news announcements nominal cycles 188 – 191, 194, 196
13 – 14 nominality, principle of 188 – 189
market action 2, 17 – 18, 21, 27, 42 Numpy 221, 229, 230, 237
market movement 2, 6, 16, 17, 27 – 29, 31,
34, 40, 43, 138 open prices 23, 25, 126, 214, 218, 236,
market orders 13 – 15 238
market participants 3, 5, 6, 27, 28, 136 open-source software 221
market prices 13, 139, 186 – 189 orders 12 – 13
264 Index

OR function 209 – 210 ReMolona, E. M. 135, 136


oscillators 114, 118, 136 resistance 32 – 35, 39, 40, 42, 88, 104, 105,
overbought region 118, 120, 137 132, 137, 140, 200, 249; levels 29, 32,
oversold region 118, 120, 125, 139, 215 105, 125, 137
retracements 37, 38, 40, 110, 133, 154;
pandas 221, 229 – 231, 233, 235, 237 levels 40
patterns 18, 44, 45, 52, 57, 63 – 66, 68, 69, reversal patterns 43 – 46, 52, 53, 57, 59,
73, 88, 90, 92, 143, 150, 160, 167, 179 61, 65, 66, 70, 73, 92, 136, 144; Belt
pattern target 47, 48, 50, 51, 53, 54, 128, Hold lines (yorikiri) 86; dark cloud
170, 179 cover (kabuse) 76 – 78; double top
pennants 56, 58, 66 and bottom 48 – 50; engulfing pattern
period 187 (tsutsumi) 75 – 76; Evening and Morning
phase 187 Star patterns 80 – 82; Hanging Man and
piercing line (kirikorni) 79 Hammer 73 – 74, 75; Harami pattern
point charts 21 – 22 82 – 85; Head and Shoulders 45 – 48;
point of wave 152, 164, 165, 175, 179 piercing line (kirikorni) 79; saucers and
positions 12 spikes 51 – 52; Three Advancing White
post-pattern implication 158, 159 Soldiers pattern 82; Three Black Crows
Prechter, Robert R. 6, 151, 162, 182 82; Three Mountains and Three Rivers
price action 17, 27, 31, 42, 71, 105, 106, 86 – 88; triple tops and bottoms 50 – 51;
136, 143, 144, 150 tweezers tops and bottoms 86
price changes 22, 101, 114, 117, 119 Rockefeller, B. 142
price forecast 44 runaway gaps 59 – 62, 132
price movement 2, 16, 18, 20, 25, 27, 105,
106, 114, 125, 126, 136 – 138, 148 Samuelson, Paul 5
price patterns 45, 61, 88, 119, 139, 143 savings: mobilization of 7
price series 95, 111, 112, 185 secondary markets 8 – 10
price trends 109, 117, 119, 133, 145 separating lines 90 – 93
primary market 16 settlement 15
principles of cycle 188 – 190 Shleifer, A. 6
Pring, M. J. 29, 32, 102, 117 shorter-period moving average
profitability of technical analysis 2, 4 – 6, 15 106, 112
proportionality, principle of 189 simple moving averages (SMAs) 95
Pruitt, G. 204 smaller cycles 188, 189, 191
python 203, 205, 221 – 225, 228 – 231, spinning tops 70, 71, 83
236 – 237, 240, 244 – 245; for backtesting Stalled Pattern 82
229 – 244; basics in 222 – 229; State Bank of India (SBI) 127 – 128
comparison and logical operators stochastics 113 – 127, 133
224; creating functions in 225 – 226; stock market anomalies 5
If, Else, and Else If (Elif) statements stock markets 150, 151, 155, 171, 183
226 – 227; lambda expressions 228; stock prices 5, 39, 62
lists, dictionaries, and tuples 224 – 225; stop-loss 14, 15, 50, 51, 58, 63, 143, 147,
logical operators 224; for loops 227; 158, 218 – 220; levels 108, 110, 147, 215,
maps and filters 228 – 229; operators 217 – 219; orders 14, 15
in 223; range() function 228; variable stop orders 14
types in 223 – 224; while loop 227 summation, principle of 188
support 32 – 35, 40, 42, 63, 88, 104, 105,
rate of change (ROC) 114 – 119, 133, 110, 128, 137, 140, 198, 200, 249
143 – 144 support trend line 35, 42, 110, 249, 250
rate of change of volume 143, 144 Symmetrical Triangle pattern 53 – 55, 55
regular flat pattern 164, 165 synchronicity, principle of 188
relative strength index (RSI) 118 – 124, 127,
128, 130, 131, 133, 215 – 221, 243 take-profit 143; level 218, 219
reliance industries 146 – 147 Tasuki gaps 88
Index 265

Taylor, M. P. 3, 5 trend-following indicators 113


technical analysis 1 – 7, 10, 15 – 18, 20, 26, trend lines 29 – 31; including all prices 31;
27, 29, 35, 37, 40, 42, 44, 203, 246; tentative trend line 29 – 31; valid trend
evidence on use of 3 – 4; in financial line 30 – 31; violation of 31 – 32
markets 1 – 3; indicators 15; profitability triangle correction (3-3-3-3-3) 170 – 172;
4 – 7, 15; see also individual entries diametric pattern new patterns 173 – 178;
technical analysts 6, 17 – 18, 20, 27 – 29, 31, irregular wave B triangle 170 – 171
34, 143, 248 triangles pattern 53, 57, 66, 170 – 172, 177,
tenets of technical analysis 26 – 28; averages 179, 180
discount everything 27; averages must triple bottom 50, 51
confirm 28; daily fluctuations 27 – 28; triple combination 177, 178, 201
primary trend 27 – 28; secondary reaction triple crossover method 108, 109, 112
27 – 28 triple top 50, 86
Thaler, R. H. 5 triple zigzag pattern 162, 163, 178
Thinking Fast and Slow 94 tweezers tops and bottoms 86
Three Black Crows And Three Advancing two stage confirmation 180
White Soldiers, The 82
Three Mountain and Three Rivers 86 – 88 validity instructions 13 – 15
time cycles 185 – 192, 196 – 202; values 9, 10, 101, 102, 120, 126, 142, 188,
characteristic of 186 – 187; combining 208, 209, 215, 222, 224, 235, 241
with Elliott Wave 196 – 202; cycle variables 2, 94, 222 – 224, 226, 229, 241
identification, detrending 192 – 194; variation, principle of 189
envelopes 194 – 196; left and right variations to the impulse pattern 154
translation 187 – 188; observational Vishny, R. 6
analysis 190 – 192; oscillator indicator volatility 69, 133, 135 – 149; of price
parameters, selecting 192; principle movement 137, 148
of commonality 189; principle of volatility indicators 136, 137, 146; ATR
harmonicity 188; principle of nominality 141 – 143; Bollinger Bands 138 – 140,
188 – 189; principle of proportionality 141; case studies 146 – 148; moving
189; principle of summation 188; average envelopes 137; Nifty 50
principle of synchronicity 188; principle 147 – 148; reliance industries 146 – 147;
of variation 189 for trading decisions 146 – 148
time frame 18 – 20 volume-based indicators 137, 143; Chaikin
traders 16 Money Flow Index 144 – 145; volume
trades 9 – 15, 29, 65, 136, 203, 205, 206, oscillators 143 – 144
218, 245 volume indicators 133, 135 – 149
trade signal 206, 212, 218
trading: days 14, 188, 189, 200; in financial wave pattern 154, 155, 179
markets 1 – 3; infrastructure of 10 – 15 Wave Theory 150, 154
transaction prices 206, 214, 217 – 218 wedge pattern 57 – 59, 130, 132, 147,
trend 18, 27 – 31, 34, 35, 40, 42, 45, 57, 156, 183
59, 64, 73, 110, 113, 119, 179, 180; wedges 57, 66
definition of 29; lines 29 – 31, 34, 35, 39, Wilder, J. Welles 141
40, 42, 45, 53, 57, 63, 119 windows 88, 93, 221
trend analysis 15, 25, 29 – 34, 38 – 40, 43, Wong, C. Y.-P. 4
44, 73; case studies 39 – 42; channel
line 35 – 37; Fan principle 34, 35; zigzag 160, 162, 164, 167, 175, 177 – 180
potential support and resistance patterns zigzag correction (5–3–5) 160 – 164;
32 – 34; retracements 37 – 42; support double and triple zigzag correction
and resistance 32; support or resistance 162 – 164
40 – 42; in trading 34; using bar zigzag movements 27, 29
technique 39 – 40 zigzag pattern 160 – 162, 167, 175, 178, 201

You might also like