Chart Pattern Bullish Flag

Bullish Flag is a technical analysis chart pattern that implies the continuation of the main trend after a correction. The main trend forms the flagpole, and the correction forms a parallel channel of the flag. It is expected that after the price breaks through the parallel channel of the flag upwards, further price growth will be approximately equal to the size of the flagpole.

Inverting the Bullish Flag results in another valid pattern, the Bearish Flag:


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 5 points. The points in the patterns found using DTW are tied to the most suitable pivots. Once they are found, the indicator checks whether the points comply with the pattern’s rules and the specified maximum permissible deviation.


In the interval between points 2 and 5, the price is allowed to cross the wedge lines with ‘high’ and ‘low’, but not with ‘close’ or ‘open’. The largest non-overlapping flags among the found patterns that fit the description above are drawn on the chart.


Inputs:


Invert Pattern - Invert the pattern to search for a bearish flag.


Source - Source for the primary search. The indicator searches for the pattern in the source data using the DTW algorithm.


Permissible Deviation - The maximum allowable deviation of the points in the flag from the parallel channel lines. It is calculated as a percentage of the channel height.