Algorithmic Identification and Classification of Chart Patterns

Telah dikemas kini
Welcome to the world of technical analysis, where chart patterns play a pivotal role in shaping trading strategies. This is an ultimate guide designed to help users objectively identify the existence of patterns, define the characteristics and classify them. In this discussion, we will mainly concentrate on the patterns formed by trend line pairs. This includes wedges, triangles and channel type patterns.

🎲 Basic Principle of Identifying the Pattern

It is very important to apply definitely set of rules when identifying the patterns in order to avoid biases or fitting patterns to our opinions. The dangers of overfitting the patterns to our bias is documented in the idea
Fitting patterns to your bias?


To identify the patterns objectively, we need to set some ground rules or follow a well-defined technique to derive the patterns. Here is the technique we follow to identify chart patterns.

🎲 Only Indicator Required - Zigzag

Tradingview has plenty of free community scripts for Zigzag indicator. For this demonstration, we are going to use our Multi Timeframe Recursive Zigzag implementation.

Once the indicator is loaded on the chart, go to indicator settings and perform these modifications.
  • Disable the Labels : The Labels contain information that is needed for this exercise.
  • Set the Highlight level to 1 or 0 : We can iteratively increase the level and check next levels on the go.


syot kilat

You can also adjust Zigzag Length and Depth Parameters.

🎲 Scanning and Identification of valid Pattern

We can either use 5 pivots or 6 pivots for pattern identification. 5-Pivot based scanning will generate more patterns than 6-Pivot based scanning. 6 pivot patterns are geometrically more accurate however, there is no proof that 6-Pivot based patterns produce better trading outcome.

🎯 Step 1 - On each level of zigzag, mark the last 5 or 6 zigzag pivots.
Since we are using Multi Timeframe Recursive Zigzag implementation, we can gradually increase the zigzag level from 0. This means that on every level, we can check if there are any patterns.

On each level - consider only the last 5 or 6 pivots and mark them on the chart.

Markings on Level 0 would look like this for 5 and 6 pivot scanning
syot kilat

🎯 Step 2: Draw Trend Lines
As part of this step, draw two trend lines.

  • The first trend line will join pivots 1 and 5 marked in the previous step.
  • The second trend line will join pivots 2 and 4 marked in the previous step for 5 pivot scanning. For 6 pivot scanning, the trend line joining pivots 2 and 6 will be marked.


syot kilat

🎯 Step 3: Inspect the validity of trend lines
A valid trend line is the one that confirm to below two points
  • Touches all the alternate pivots. For example, the trend line drawn from pivot 1 to 5 should also make contact with the candle of pivot 3. In case of 6 pivot scanning, the trend drawn from pivot 2 to 6 should also make contact with the candle of pivot 4.
  • All the candles from the starting pivot to ending pivot of the zigzag should be confined within the trend line pairs. Meaning, no candles should completely go above the upper trend line and no candle should completely go below the lower trend line.


Please note that while verifying the above points, minor adjustments in the alignment of the trend line can be made. Start and end of the trend line does not need to be on the high/low points of the candle, it can also be placed in any of the wick positions.

After adjusting the trend lines, in both type of scanning, we can see that the trend lines confirm to the above-mentioned rules. Hence, we have arrived with valid patterns in both types of scanning on the level 0 zigzag.

syot kilat

🎲 Classification of Patterns
Once the patterns are identified, they need to be classified into different types. We need to apply predetermined rules to objectively classify patterns into what they are. Everyone can build their own rules.

🎯 Properties of Derived Trend Lines
Before classifying the trend lines, we need to understand below properties of the derived trend lines.

▶ Direction of Individual Trend Lines
Both the trend lines needs to be individually classified among these categories

  • Rising - Trend Line is sharply rising up.
  • Falling - Trend Line is sharply falling down.
  • Flat - Trend Line is flat across the pivots.
  • Bi-Directional - Trend Lines are moving in opposite directions


Please note that, it is less probable for trend line to absolutely flat. Hence, allow angle to have certain degree of threshold to be considered as flat. For example, +- 10 degrees can be considered as flat.

Also, the angle of the trend line can further subjective based on how compressed the chart is. It is recommended to use either log/auto-scale or a specific formula based on ATR to identify the angle.

▶ Characteristic of the Trend Line Pairs
This parameter defines how both trend lines are aligned with respect to each other. Possible options are:

  • Converging - Trend Lines are converging and when extended towards the right will intersect at a visible distance.
  • Diverging - Trend Lines are diverging from each other and when extended towards the left will intersect at a visible distance.
  • Parallel - Trend Lines are almost parallel to each other and may not intersect to either right or to left at a visible distance.


To objectively identify the intersection distance, we further need to use some standard. Here are few options

  • Fixed Number of Bars: If the trend lines do not intersect to either left or right within X bars (Lets say 100), they can be considered as parallel. Otherwise, they can be classified as converging or diverging based on which side the intersection happens.
  • Relative to the Length of Pattern: If the length of longest trend line is X bars. The trend lines should converge within 1–2 times the X bars to be considered as converging or diverging. Or else, it can be termed as parallel channels.


🎯 Geometrical Shapes Classification
Following are the main geometrical classifications based on the characteristics of the trend lines and the pair.

  • Channels - Trend Lines are parallel to each other. And hence they both move in the same directions.
  • Wedges - Trend Lines are either converging or diverging from each other. However, both trend lines move in the same direction. Both trend lines will be either up or down.
  • Triangles - Trend Lines are either converging or diverging from each other. But, unlike wedges, upper and lower trend lines will have different direction.


🎲 Types of Patterns

Once we identify the direction and characteristics of trend lines, we can go on and classify the pattern in following categories.

syot kilat

Details below. Please note that examples are generated programmatically.

🎯 Rising Wedge (Contracting)
Rules for Contracting Rising Wedge are as follows:

  • Both Trend Lines are Rising
  • Trend Lines are converging.


syot kilat

🎯 Rising Wedge (Expanding)
Rules for the Expanding Rising Wedge are as follows:

  • Both Trend Lines are rising
  • Trend Lines are diverging.


syot kilat

🎯 Falling Wedge (Contracting)
Rules for the Contracting Falling Wedge are as follows:

  • Both Trend Lines are falling
  • Trend Lines are contracting.


syot kilat

🎯 Falling Wedge (Expanding)
Rules for the Expanding Falling Wedge are as follows:

  • Both Trend Lines are falling
  • Trend Lines are diverging.


syot kilat

🎯 Contracting/Converging Triangle
Rules for the Contracting Triangle are as follows

  • The upper trend line is falling
  • The lower trend line is rising
  • Naturally, the trend lines are converging.


syot kilat

🎯 Rising Triangle (Contracting)
The rules for the Contracting Rising Triangle are as follows

  • The upper trend line is flat
  • The lower trend line is rising
  • Naturally, the trend lines are converging towards each other


syot kilat

🎯 Falling Triangle (Contracting)
The rules for the Contracting Falling Triangle are as follows

  • The upper trend line is falling
  • The lower trend line is flat
  • Naturally, the trend lines are converging towards each other


syot kilat

🎯 Expanding/Diverging Triangle
Rules for the Expanding Triangle are as follows

  • The upper trend line is rising
  • The lower trend line is falling
  • Naturally, the trend lines are diverging from each other.


syot kilat

🎯 Rising Triangle (Expanding)
The rules for the Expanding Rising Triangle are as follows

  • The upper trend line is rising
  • The lower trend line is flat
  • Naturally, the trend lines are diverging from each other


syot kilat

🎯 Falling Triangle (Expanding)
The rules for the Expanding Falling Triangle are as follows

  • The upper trend line is flat
  • The lower trend line is falling
  • Naturally, the trend lines are diverging from each other


syot kilat

🎯 Rising/Uptrend Channel
Rules for the Uptrend Channel are as follows

  • Both trend lines are rising
  • Trend lines are parallel to each other


syot kilat

🎯 Falling/Downtrend Channel
Rules for the Downtrend Channel are as follows

  • Both trend lines are falling
  • Trend lines are parallel to each other


syot kilat

🎯 Ranging Channel
Rules for the Ranging Channel are as follows:

  • Both trend lines are flat
  • Naturally, the trend lines are parallel to each other.


syot kilat
Nota
Thanks everyone. We have further created an open-source indicator to perform these things automatically. Feel free to explore.

Auto Chart Patterns [Trendoscope®]
Chart PatternshewhomustnotbenamedtrendoscopeTriangleWedgeZigzag

Penerbitan berkaitan

Penafian