The head and shoulders is a reversal pattern formed by three consecutive highs and two intermediate lows. The first and third peaks are called shoulders and are located below the second - the head. The neck line - the line drawn along the intermediate minima - is also of importance. The pattern is considered completed only when the price reaches the right shoulder and falls below the neck line. It is expected that the further downward movement of the price will be approximately equal to the height of the head.
The inverted version of the pattern is also valid.
The indicator analyzes the last 600 bars in search of patterns. The DTW (Dynamic Time Warping) algorithm is used for the primary recognition. This algorithm allows you to find compressed and time-stretched sequences of values of the specified source that match a given template of 7 points.
Points 2-6 in the patterns found using DTW are tied to pivots. Points 1 and 7 are placed at the low values located below the neck line. The indicator checks whether the points comply with the pattern’s rules and the specified minimum allowable height difference between the head and shoulders. Of all the patterns that have been found, those that are closest to the source and to the end of the chart are drawn.
Invert Pattern - Invert the pattern to search for inverted head and shoulders.
Source - Source for the primary search. The indicator searches for the pattern in the source data using the DTW algorithm.
Minimum Required Difference - The minimum allowable difference in the height of the shoulders and the head. The height of the head and shoulders is calculated from the smallest of the intermediate minima. Percentage value.