TradingView
Trendoscope
14 jan 2024 06:00

Auto Chart Patterns [Trendoscopeยฎ]ย 

Bitcoin / TetherUSBinance

Beskrivning

โ‹…
๐ŸŽฒ Introducing our most comprehensive automatic chart pattern recognition indicator.

Last week, we published an idea on how to algorithmically identify and classify chart patterns.


This indicator is nothing but the initial implementation of the idea. Whatever we explained in that publication that users can do manually to identify and classify the pattern, this indicator will do it for them.

๐ŸŽฒ Process of identifying the patterns.

The bulk of the logic is implemented as part of the library - chartpatterns. The indicator is a shell that captures the user inputs and makes use of the library to deliver the outcome.

๐ŸŽฏ Here is the list of steps executed to identify the patterns on the chart.
  • Derive multi level recursive zigzag for multiple base zigzag length and depth combinations.
  • For each zigzag and level, check the last 5 pivots or 6 pivots (based on the input setting) for possibility of valid trend line pairs.
  • If there is a valid trend line pair, then there is pattern.


๐ŸŽฏ Rules for identifying the valid trend line pairs
  • There should be at least two trend lines that does not intersect between the starting and ending pivots.
  • The upper trend line should touch all the pivot highs of the last 5 or 6 pivots considered for scanning the patterns
  • The lower trend line should touch all the pivot lows of the last 5 or 6 pivots considered for scanning the patterns.
  • None of the candles from starting pivot to ending pivot should fall outside the trend lines (above upper trend line and below lower trend line)


The existence of a valid trend line pair signifies the existence of pattern. What type of pattern it is, to identify that we need to go through the classification rules.

๐ŸŽฒ Process of classification of the patterns.

We need to gather the following information before we classify the pattern.
  • Direction of upper trend line - rising, falling or flat
  • Direction of lower trend line - rising, falling or flat
  • Characteristics of trend line pair - converging, expanding, parallel


๐ŸŽฏ Broader Classifications
Broader classification would include the following types.

๐Ÿšฉ Classification Based on Geometrical Shapes
This includes
  • Wedges - both trend lines are moving in the same direction. But, the trend lines are either converging or diverging and not parallel to each other.
  • Triangles - trend lines are moving in different directions. Naturally, they are either converging or diverging.
  • Channels - Both trend lines are moving in the same direction, and they are parallel to each other within the limits of error.


๐Ÿšฉ Classification Based on Pattern Direction
This includes
  • Ascending/Rising Patterns - No trend line is moving in the downward direction and at least one trend line is moving upwards
  • Descending/Falling Patterns - No trend line is moving in the upward direction, and at least one trend line is moving downwards.
  • Flat - Both Trend Lines are Flat
  • Bi-Directional - Both trend lines are moving in opposite direction and none of them is flat.


๐Ÿšฉ Classification Based on Formation Dynamics
This includes
  • Converging Patterns - Trend Lines are converging towards each other
  • Diverging Patterns - Trend Lines are diverging from each other
  • Parallel Patterns - Trend Lines are parallel to each others


๐ŸŽฏ Individual Pattern Types
Now we have broader classifications. Let's go through in detail to find out fine-grained classification of each individual patterns.

๐Ÿšฉ Ascending/Uptrend Channel
This pattern belongs to the broader classifications - Ascending Patterns, Parallel Patterns and Channels. The rules for the Ascending/Uptrend Channel pattern are as below
  • Both trend lines are rising
  • Trend lines are parallel to each other



๐Ÿšฉ Descending/Downtrend Channel
This pattern belongs to the broader classifications - Descending Patterns, Parallel Patterns and Channels. The rules for the Descending/Downtrend Channel pattern are as below
  • Both trend lines are falling
  • Trend lines are parallel to each other



๐Ÿšฉ Ranging Channel
This pattern belongs to the broader classifications - Flat Patterns, Parallel Patterns and Channels. The rules for the Ranging Channel pattern are as below
  • Both trend lines are flat
  • Trend lines are parallel to each other



๐Ÿšฉ Rising Wedge - Expanding
This pattern belongs to the broader classifications - Rising Patterns, Diverging Patterns and Wedges. The rules for the Expanding Rising Wedge pattern are as below
  • Both trend lines are rising
  • Trend Lines are diverging.



๐Ÿšฉ Rising Wedge - Contracting
This pattern belongs to the broader classifications - Rising Patterns, Converging Patterns and Wedges. The rules for the Contracting Rising Wedge pattern are as below
  • Both trend lines are rising
  • Trend Lines are converging.



๐Ÿšฉ Falling Wedge - Expanding
This pattern belongs to the broader classifications - Falling Patterns, Diverging Patterns and Wedges. The rules for the Expanding Falling Wedge pattern are as below
  • Both trend lines are falling
  • Trend Lines are diverging.



๐Ÿšฉ Falling Wedge - Contracting
This pattern belongs to the broader classifications - Falling Patterns, Converging Patterns and Wedges. The rules for the Converging Falling Wedge are as below
  • Both trend lines are falling
  • Trend Lines are converging.



๐Ÿšฉ Rising/Ascending Triangle - Expanding
This pattern belongs to the broader classifications - Rising Patterns, Diverging Patterns and Triangles. The rules for the Expanding Ascending Triangle pattern are as below
  • The upper trend line is rising
  • The lower trend line is flat
  • Naturally, the trend lines are diverging from each other



๐Ÿšฉ Rising/Ascending Triangle - Contracting
This pattern belongs to the broader classifications - Rising Patterns, Converging Patterns and Triangles. The rules for the Contracting Ascending Triangle pattern are as below
  • The upper trend line is flat
  • The lower trend line is rising
  • Naturally, the trend lines are converging.



๐Ÿšฉ Falling/Descending Triangle - Expanding
This pattern belongs to the broader classifications - Falling Patterns, Diverging Patterns and Triangles. The rules for the Expanding Descending Triangle pattern are as below
  • The upper trend line is flat
  • The lower trend line is falling
  • Naturally, the trend lines are diverging from each other



๐Ÿšฉ Falling/Descending Triangle - Contracting
This pattern belongs to the broader classifications - Falling Patterns, Converging Patterns and Triangles. The rules for the Contracting Descending Triangle pattern are as below
  • The upper trend line is falling
  • The lower trend line is flat
  • Naturally, the trend lines are converging.



๐Ÿšฉ Converging Triangle
This pattern belongs to the broader classifications - Bi-Directional Patterns, Converging Patterns and Triangles. The rules for the Converging Triangle pattern are as below
  • The upper trend line is falling
  • The lower trend line is rising
  • Naturally, the trend lines are converging.



๐Ÿšฉ Diverging Triangle
This pattern belongs to the broader classifications - Bi-Directional Patterns, Diverging Patterns and Triangles. The rules for the Diverging Triangle pattern are as below
  • The upper trend line is rising
  • The lower trend line is falling
  • Naturally, the trend lines are diverging from each other.



๐ŸŽฒ Indicator Settings - Auto Chart Patterns

๐ŸŽฏ Zigzag Settings
Zigzag settings allow users to select the number of zigzag combinations to be used for pattern scanning, and also allows users to set zigzag length and depth combinations.



๐ŸŽฏ Scanning Settings
  • Number of Pivots - This can be either 5 or 6. Represents the number of pivots used for identification of patterns.
  • Error Threshold - Error threshold used for initial trend line validation.
  • Flat Threshold - Flat angle threshold is used to identify the slope and direction of trend lines.
  • Last Pivot Direction - Filters patterns based on the last pivot direction. The values can be up, down, both, or custom. When custom is selected, then the individual pattern specific last pivot direction setting is used instead of the generic one.
  • Verify Bar Ratio - Provides option to ignore extreme patterns where the ratios of zigzag lines are not proportionate to each other.
  • Avoid Overlap - When selected, the patterns that overlap with existing patterns will be ignored while scanning. Meaning, if the new pattern starting point falls between the start and end of an existing pattern, it will be ignored.



๐ŸŽฏ Group Classification Filters
Allows users to enable disable patterns based on group classifications.

๐Ÿšฉ Geometric Shapes Based Classifications
  • Wedges - Rising Wedge Expanding, Falling Wedge Expanding, Rising Wedge Contracting, Falling Wedge Contracting.
  • Channels - Ascending Channel, Descending Channel, Ranging Channel
  • Triangles - Converging Triangle, Diverging Triangle, Ascending Triangle Expanding, Descending Triangle Expanding, Ascending Triangle Contrcting and Descending Triangle Contracting


๐Ÿšฉ Direction Based Classifications
  • Rising - Rising Wedge Contracting, Rising Wedge Expanding, Ascending Triangle Contracting, Ascending Triangle Expanding and Ascending Channel
  • Falling - Falling Wedge Contracting, Falling Wedge Expanding, Descending Triangle Contracting, Descending Triangle Expanding and Descending Channel
  • Flat/Bi-directional - Ranging Channel, Converging Triangle, Diverging Triangle


๐Ÿšฉ Formation Dynamics Based Classifications
  • Expanding - Rising Wedge Expanding, Falling Wedge Expanding, Ascending Triangle Expanding, Descending Triangle Expanding, Diverging Triangle
  • Contracting - Rising Wedge Contracting, Falling Wedge Contracting, Ascending Triangle Contracting, Descending Triangle Contracting, Converging Triangle
  • Parallel - Ascending Channel, Descending Channgel and Ranging Channel




๐ŸŽฏ Individual Pattern Filters
These settings allow users to enable/disable individual patterns and also set last pivot direction filter individually for each pattern. Individual Last Pivot direction filters are only considered if the main "Last Pivot Direction" filter is set to "custom"



๐ŸŽฏ Display Settings
These are the settings that determine the indicator display. The details are provided in the tooltips and are self explanatory.


๐ŸŽฏ Alerts
A basic alert message is enabled upon detection of new pattern on the chart.

Versionsinformation

โ‹…
Added option to enable/disable repainting.

When permitted, repainting only updates a pattern if the new coordinates yield a more geometrically accurate representation. While repainting can be beneficial for maintaining precise patterns on the chart, it often carries a negative connotation. Therefore, we've set this option to be off by default, allowing users to choose based on their preferences

Versionsinformation

โ‹…
Updates

  • Added option to detect patterns based on custom OHLC. This means, users can select external inputs and apply the pattern detection algorithm on oscillators or other indicators provided they have their OHLC values and not a single value.
  • Added option to limit number of patterns on chart.

Versionsinformation

โ‹…
Library Updates

Versionsinformation

โ‹…
Minor library updates

Versionsinformation

โ‹…
Update libraries
Kommentarer
Ether2020
โ‹…
You are not just good, you are amazing! Beautiful code! Thank you so much, my dear friend!
Trendoscope
โ‹…
@Ether2020, Thanks very much my friend. Really appreciate it and happy that you like the script :)
PineCoders
โ‹…
In the name of all TradingViewers, thank you for your valuable contribution to the community, and congrats!
Trendoscope
โ‹…
@PineCoders, thanks very much for your support ๐Ÿ™
Trader-Berke
โ‹…
You are a legend!
Trendoscope
โ‹…
@Trader-Berke, thanks ๐Ÿ˜Š
zhuwei3018
โ‹…
This indicator is the most awesome on Tradingview. Can you add alerts in the indicator?
Trendoscope
โ‹…
@zhuwei3018, thanks. Basic alerts are already there in it
ayilovemina
โ‹…
Can you teach me to try it? I want to learn it.
davewantsmoore
โ‹…
I'm not really a big chart patterns guy ... but when I like to read good code, and learn new things.... I know where to go.
Mer