Finding complex chart patterns has never been an easy task. This article will give you a simple algorithm and a ready to use indicator for complex chart pattern recognition. You will have the freedom to detect any pattern with any pattern length. It has been described as Fréchet distance in literature. This article shows a simple adaptation for chart pattern analysis.
Defining a chart pattern
I am using a simple string definition of a pattern. See the example below:
The V-Top pattern over 11 bars (shown above) can be defined as a simple string. The absolute values of the pattern definition are of no importance. If your pattern runs from 1 to 6 or 1 to 60 will not make any difference. But you surely will detect different patterns if you define the V-Top over 5 bars instead over 11 bars. (5-Bar V-Top: 1,2,3,2,1).
You could use any length and any pattern complexity you would want to have.
With the Tradesignal programming language Equilla the pattern will be defined as an array holding the pattern definition. To get things started I defined some simple show patterns: V-Top, V-Bottom, a rising market and a falling market pattern.
Detecting the chart pattern
To actually find the given pattern on the chart some simple calculations have to be done by the given algorithm.
First the chart compressed to fit the pattern. On the chart below the V-Bottom pattern is selected, and as the definition goes from +10 to 1 and back to +9, the chart is compressed to fit the pattern volatility and price range.
In a second step the difference between the chart and the pattern definition is calculated. I use the squared distances between the individual closing prices and the pattern to calculate a fitting factor. This factor is shown underneath the chart.
A perfect fit would return a fitting factor of zero, but this will never happen in reality. Therefore the pattern recognition indicator has got a “fuzzyfactor” input. It defines the minimum accuracy which will be needed to detect the pattern.
A second input to this chart pattern recognition indicator is the minimum volatility of the pattern. As mentioned above it does not come with the pattern definition, but it can be defined later on. On the chart below I set a minimum volatility of 1% between the pattern high and pattern low. This helps to get rid of useless patterns when the market is not moving.
As soon as the fitting factor (the difference between the pattern and the chart) is below the “fuzzyfactor”, the pattern is detected and shown on the chart.
And now it’s your task: stay creative, define the strings for your favourite patterns and use the algorithm to find your favourable patterns in any market.
Tradesignal indicator code
Please click the link to see the Tradesignal implementation of this indicator. You are free to use it for non commercial purposes as stated in the imprint. If this is fine for you then type iconsent as password to the code page.
another article on candlestick pattern recognition can be found here