0% found this document useful (0 votes)
238 views35 pages

Algorithmic Identification of Chart Patterns

The document discusses algorithmic identification of chart patterns by describing academic approaches and the author's published algorithms. It outlines smoothing price data, zigzag identification, and matrix template matching as common academic methods. The author focuses on simplicity, eliminating pattern variation and scale issues, and speed of implementation. A detailed example is provided for identifying the cup pattern through finding dimensional relationships between pattern branches rather than thresholds.
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)
238 views35 pages

Algorithmic Identification of Chart Patterns

The document discusses algorithmic identification of chart patterns by describing academic approaches and the author's published algorithms. It outlines smoothing price data, zigzag identification, and matrix template matching as common academic methods. The author focuses on simplicity, eliminating pattern variation and scale issues, and speed of implementation. A detailed example is provided for identifying the cup pattern through finding dimensional relationships between pattern branches rather than thresholds.
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/ 35

Algorithmic Identification of

Chart Patterns

step-by-step identification procedures


which can be coded in a computer
program
Algorithmic Identification of
Chart Patterns

Key Benefits

• Instant scan innumerous charts

• Objective statistical analyses

• Powerful research means on combinations of


chart patterns with other analysis methods
Algorithmic Identification of
Chart Patterns

Major Obstacles
• Pattern Variation
endless ways for a textbook pattern to manifest itself
in a real chart.

• Scale
Almost all chart patterns of classic technical analysis
are scale-free
Outline of the Talk

• Brief review of methods used in academic


literature (finance and computer science)

• Ideas I have used in my articles

• A detailed example
Academic Approaches (Finance)

Three major identification methods in


academic financial literature.

• Smoothing price data


• Zigzag-ing
• Matrix template
Academic Approaches (Finance)
1st Method (Smoothing Price)
• smooth price data in a Max2
time span and identify
local extrema
Max1 Max3
• Define the pattern via
conditions for these
extrema

• Repeat the procedure


using different time Min2
spans. Min1
Academic Approaches (Finance)
2nd Method (“Zigzag-ing”)
• Apply a “Zigzag” swing Peak2
indicator to filter noise
(disregard changes below x% cutoff
and
threshold) identify
Peak3
peaks and troughs Peak1

• Define the pattern via


conditions for the peaks
and troughs

• Repeat using different Trough2


Trough1
cutoff threshold x%
Academic Approaches (Finance)
3rd Method (Matrix Templates)
-1 -1 -1 -1 -1 +2 +2 -1 -1 -1 -1 -1

-1 -1 -1 -1 -1 +2 +2 -1 -1 -1 -1 -1

-1 -1 +1 0 -1 +2 +2 -1 0 +1 -1 -1

A matrix template -1 -1 +2 +1 -1 +2 +2 -1 +1 +2 -1 -1

models the desired -1 +1 +2 +2 0 +2 +2 0 +2 +2 +1 -1

0 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 0
pattern using weights +1 +2 +2 +2 +2 +2 +2 +2 +2 +2 +2 +1

+2 +2 +2 +2 +2 0 0 +2 +2 +2 +2 +2

+2 +2 +1 +2 +1 -1 -1 +1 +2 +1 +2 +2

+2 +2 0 +1 -1 -1 -1 -1 +1 0 +2 +2
+2 0 -1 -1 -1 -1 -1 -1 -1 -1 0 +2

+2 0 -1 -1 -1 -1 -1 -1 -1 -1 0 +2

An iconic 12x12 matrix template for H&S


Academic Approaches (Finance)
3rd Method (Matrix Templates)

Superimpose a grid
(having the same dimensions as
the matrix template) in the
actual price chart
Academic Approaches (Finance)
3rd Method (Matrix Templates)
x x
x x
x x
The price action is x x x
x x x x x x x x
then converted into
x x x x x x x x x
matrix form x x x x x x x x x
x x x x x x x x x x x
x x x x x x x x x
x x x x x x
x x x
x
Academic Approaches (Finance)
3rd Method (Matrix Templates)
+2
x +2
x
+2
x +2
x
Sum up all weights for +2
x +2
x
the price action +2
x +2
x +2
x
-1
x +1
x +2
x +2
x +2
x 0x +2
x +1
x
x +2
0 x +2
x +2
x +2
x +2
x +2
x +2
x 0x
The higher the sum, the +1
x +2
x +2
x +2
x +2
x +2
x +2
x +2
x +1
x
+2
x +2
x +2
x +2
x +2
x 0x +2
x +2
x +2
x +2
x +2
x
better the price action fits
+2
x +1
x +2
x +1
x +1
x +2
x +1
x +2
x +2
x
the pattern model +2
x x +1
0 x -1
x +1
x +2
x
+2
x -1
x -1
x
+2
x
Academic Approaches
(Computer Science)
• Perceptually Important Points (PIP)
A smart modification of the zigzag-ing method: no use of % thresholds;
you a-priori define the number of swings you want instead.

• Symbolic Aggregate Approximation (SAX)


Uses alphabetic symbolic representation of segmented data series and
applies methods from bioinformatics and text data mining

• Support Vector Machines (SVM)


Sophisticated classification method which makes use of learning
algorithms in high-dimensional feature spaces
My Published Algorithms on Chart
Pattern Identification

Focus on:
Perception of Technical Analysts in mind
Elimination of Variation and Scale obstacles
Implementation in almost any technical analysis
software (Simplicity)
Execution Speed

To accomplish the above:


I created different algorithms per case (pattern)
Simple ideas I have Used (I)

• Chart patterns usually consist of


branches

• These branches have some dimensional


restrictions with respect to one another

• If we identify even just one of these


branches, then we can usually identify the
whole pattern
Example:
Identifying the top of the left shoulder in H&S

Area of
possible tops
for the left
shoulder

The dimensions of the green area are related


to the dimensions of the orange one
Simple ideas I have Used (II)

When a branch of a chart pattern is


more or less curved, you can
usually identify its important points

(no matter the scale)


Example:
Identifying the top of the head in H&S

The highest Check all prices


between P and Q.
of them is
the top of
the head

P
Q
Move backwards in time until
you find a price (Q) which is
lower than the last one (P)
A Detailed Example

Identifying the cup pattern

A modification of a simple algorithm presented in my February 2006


article “Identifying The Cup” in the Technical Analysis of Stocks and
Commodities magazine
What is a Cup pattern?

Rounding Bottom Rounding "Bottom" Rounding "Bottom"


after a downtrend after an uptrend after a sideways market

All these different types of rounding


"bottoms" are called cups and they
are generally considered bullish
patterns
Identifying the Cup

High of the last Bar


C
Move backwards in time until Consider the bars
you find a bar having a higher below the red line
Let C be the lowest
high than A.
low of all red bars
Identifying the Cup

“Imprison” the red bars behind a 5x5 grid of equal


rectangular cells using A and C as milestones
Identifying the Cup

A
1st Condition:

No Closing
price inside the
yellow cells
AND
No High price
inside the
C
orange cells
Identifying the Cup

A
2nd Condition:

Bar lows exist


inside both
green boxes

OR
bar lows exist C
inside both
blue boxes Height of blue and green boxes = 2/3 of the height of cells
Identifying the Cup

A
3rd Condition:

There are at
least 20 red
bars

C
Application

Application of the algorithm in the daily


charts of all S&P500 stocks from 1982 to
2014 reveals a total of 3,991 distinctive*
cups of various durations.

Scan took less than 20 seconds

distinctive*
No time overlap of more than 70% between any two
cups in the same chart
Algorithm in Action [Example 1]

Apple (Daily)

49 bars

49 bars 143 bars


Algorithm in Action [Example 2]

Big Lots Inc (Daily)

30 bars

95 bars
Algorithm in Action [Example 3]

C.H. Robinson WW (Daily)

22 bars

71 bars
Statistics for the S&P500 Stocks
(Daily Charts 1982-2014)

• Total number of cups: 3,991 • Median duration: 32 bars


• Minimum duration: 20 bars
• 80% of all cups were less than
• Maximum duration: 1,162 bars 3-months long (75 trading days)
Evaluation of Chart Patterns

Algorithmic identification gives us the means


to evaluate the effectiveness and efficiency of
a chart pattern

Because: it gives us detailed info about innumerous


manifestations of the pattern in actual charts
Example: Evaluating of Cup

Questions:
Does the cup pattern actually produce uptrends?

Are these trends exploitable?

What is the historical edge of the cup?

How confident we are that this edge is statistically


significant?
Example: Evaluating the Cup
A simple buy-only system was applied in the previous data

• Go long at the high of the identification bar when a cup is


identified
• Exit when the price falls below a % trailing stop-loss of 0.7
times the % distance from A to C

Example A
Go long
-21% here with a
-30%
trailing stop
loss of 21%

C
Example: Evaluating the Cup

A Profit Factor (PF) was calculated for every


hypothetical trade :

So, all cups are treated under equal terms (no matter
their height) allowing us to determine the "edge" of cup
pattern from this system's point of view
Example: Evaluating the Cup

Results for S&P500 stocks from 1982 to 2014:

Statistical Values Translation

• Mean PF = 0.166 Edge of cup (1982-2014) = 16.6%


• Profitable trades (%) = 39% Most trades produced loses
• CV = 1,105% PF’s vary too much in relation to the
edge of the system

• 99% confidence levels for We can be 99% sure that the


Mean PF : 9.1% - 24.0% [9% , 24%] interval captures the all-
time edge of the cup pattern
Epilogue

Algorithmic identification of classic TA


patterns is feasible and provides important
benefits for the chartists

Thank you

You might also like