0% found this document useful (0 votes)
92 views5 pages

Trading Harmonic Patterns 2

The document discusses analyzing the profitability of trading common bullish harmonic patterns in US stock, forex, and crypto markets. It describes the data, tools, evaluation metrics, and methodology used, including analyzing the accuracy of two pattern matching algorithms and evaluating the bullish Gartley, butterfly, bat, and crab patterns based on number of trades, success rate, compound annual growth rate, and maximum drawdown.

Uploaded by

Jewan Joga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views5 pages

Trading Harmonic Patterns 2

The document discusses analyzing the profitability of trading common bullish harmonic patterns in US stock, forex, and crypto markets. It describes the data, tools, evaluation metrics, and methodology used, including analyzing the accuracy of two pattern matching algorithms and evaluating the bullish Gartley, butterfly, bat, and crab patterns based on number of trades, success rate, compound annual growth rate, and maximum drawdown.

Uploaded by

Jewan Joga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

In this study, a primary focus would be given to the bullish Gartley pattern, and other popular ones

would be discussed afterwards. The study aims to investigate the occurrence of the common bullish
harmonic patterns in the US stock, Forex, and Crypto markets and the profitability of trading with
these patterns in a single instrument. Two algorithms of scanning harmonic patterns will be examined,
in terms of their accuracy, followed by analyzing the profitability.

In Section 3, the data, tools, and evaluation metrics for the profitability of trading harmonic patterns
are described. Next, Section 4 explains the details of each harmonic pattern and the process flow of a
backtesting program. In Section 5, the accuracy of the first pattern matching algorithm and the
drawback are discussed. In Section 6, the second pattern matching algorithm is introduced and is used
to evaluate the profitability of the bullish Gartley pattern in different markets. Thereafter, Section 7
analyzes other popular bullish harmonic patterns, including the butterfly, the bat, and the crab, and
Section 8 concludes the work.

3 Data, Tools and Evaluation

3.1 Data
Mainly three instruments are used throughout the study:

1. SPDR S&P 500 ETF Trust (SPY)


2. The EUR/USD pair
3. The BTC/USD pair

The SPDR S&P 500 ETF Trust tracks the Standard & Poor’s 500 Index, which is comprised of 500
large companies listed on the stock exchanges in the United States and represents the stock market’s
performance. The second instrument, the currency pair EUR/USD, indicates how many US Dollars are
needed to purchase 1 Euro while the BTC/USD pair shows the price of 1 Bitcoin in US Dollars. The
three instruments are the most-traded ones in the US stock, Forex, and Crypto market, respectively,
and are chosen to be the representative of these three markets.

The data used in the study are obtained from the historical data feed of the Dukascopy Group. Since
the earliest data of SPY and the BTC/USD pair that can be extracted from the platform is in 2017, the
hourly data of the three instruments from 01/09/2017 to 01/09/2021 are used. The close price in each
data frame is extracted for data processing.

6
3.2 Tools
Algorithm implementation and backtest are conducted in Python 3.9 using numpy, pandas, and
matplotlib. In addition, two other third-party libraries, TA-Lib and ZigZag, are also used to introduce
some technical analysis indicators and identify relative extreme points of a time series in Section 6 [6].

TA-Lib introduces the average true range, a market volatility indicator, which is for defining the price
target and stop-loss in the program. The average true range is defined as follows [7]:

𝑇𝑅 = 𝑀𝑎𝑥[(𝐻 − 𝐿), 𝐴𝑏𝑠(𝐻 − 𝐶𝑃 ), 𝐴𝑏𝑠(𝐿 − 𝐶𝑃 )]


𝑛
1
𝐴𝑇𝑅 = ∑ 𝑇𝑅𝑖
𝑛
𝑖=1

TRi is the true range at a particular time, which is the maximum of ‘high minus low’, ‘the absolute
value of high minus previous close’, and ‘the absolute value of low minus previous close’. ATR is the
moving average of true range TR, usually using 14 for n.

The library ZigZag introduces a simplified version of the Zig Zag indicator. A typical Zig Zag
indicator is customizable in 3 parameters– the deviation, depth, and backstep:

1. The deviation is the minimal price change required for the indicator to define a new extreme
and to plot a swing high (a local maximum) or a swing low (a local minimum) on the chart. It
is equivalent to a threshold of identifying a new extreme point.
2. The depth sets the minimal time interval where the indicator will define a new extreme if the
threshold is passed. It is usually expressed in the unit of candlesticks.
3. The backstep specifies the minimum number of bars that have an opposite direction to the
current bar between 2 extrema to be plotted. For example, if the value of backstep equals 3,
after a new swing high, there should be at least three red candlesticks to have a new swing low
been formed.

In the library ZigZag, only the parameter deviation is considered, and it is expressed in terms of the
percentage change of price. For example, if an instrument has a price of $1000 per unit at a swing low,
and the deviation is set to be 5%, a local maximum point is identified only if the price increases over
$50 to at least $1050. If it is a swing high, a local minimum point is identified only after the price
drops under $950.

7
3.3 Evaluation Metrics
The number of trades, the success rate of predicting price movement (abbreviated to success rate),
compound annual growth rate, and maximum drawdown are the four key indicators to evaluate the
profitability of trading harmonic patterns.

3.3.1 Number of trades


Once a similar pattern is identified, the program enters a trade. Therefore, the number of trades is a
measure of how frequent a similar pattern occurs in the market.

3.3.2 Success Rate


The success rate, r, is expressed as the ratio of profiting trades, np, to the total number of trades, nt. It
indicates how accurate a specific pattern is to predict future price trends.

𝑛𝑝
𝑟=
𝑛𝑡

3.3.3 Compound Annual Growth Rate


The compound annual growth rate, CAGR, measures the rate of return of the investment. A higher
CAGR usually implies a better investment strategy. The CAGR of the buy-and-hold strategy is a
benchmark to evaluate our trading strategy. The CAGR is defined as follows:

𝐸𝑛𝑑𝑖𝑛𝑔 𝑣𝑎𝑙𝑢𝑒 1
𝐶𝐴𝐺𝑅 = ( )𝑛 − 100%
𝐵𝑒𝑔𝑖𝑛𝑛𝑖𝑛𝑔 𝑣𝑎𝑙𝑢𝑒

n is the number of years.

3.3.4 Maximum Drawdown


The maximum drawdown, MDD, is the maximum observed loss from a peak to a trough of a portfolio
before a new peak is attained. It allows an investor to examine the risk of the strategy and decide
whether he or she can tolerate the risk.

𝑇𝑟𝑜𝑢𝑔ℎ 𝑉𝑎𝑙𝑢𝑒 − 𝑃𝑒𝑎𝑘 𝑉𝑎𝑙𝑢𝑒


𝑀𝐷𝐷 =
𝑃𝑒𝑎𝑘 𝑉𝑎𝑙𝑢𝑒

8
4 Methodology

4.1 Popular Harmonic Patterns


In this study, the algorithm is firstly developed for scanning the bullish Gartley pattern. Different sets
of retracement levels in other popular harmonic patterns, including the butterfly, bat, and crab, will be
substituted into the corresponding parameters in the later part. The profitability of each pattern will be
examined individually.

4.1.1 The Gartley Pattern


Different variants of Gartley patterns with different ratios have been developed. This study adopts 3
different sets of Fibonacci retracement levels for the Gartley pattern, which are (0.618, 0.382, 1.13),
(0.618, 0.382, 1.272), and (0.618, 0.886, 1.618) respectively. Using the first ordered set (0.618, 0.382,
1.13) as an example, leg AB is defined as the 0.618 retracement of leg XA, leg BC is defined as the
0.382 retracement of leg AB, and leg CD is defined as the 1.13 projection of leg BC.

Figure 4a: The first Gartley pattern

9
Figure 4b: The second Gartley pattern

Figure 4c: The third Gartley pattern

Other harmonic traders also consider ‘leg CD being 0.786 retracement of leg XA’ and ‘AB=BC’
(which means the leg BC has a similar number of candlesticks as the leg AB) as confluence, which
signals a higher probability of success when trading with the Gartley pattern. However, this study may
not cover all of these because the trade opportunity is limited.

10

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy