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.
Thanks to Tradesignal for the great software to accomplish this task, thanks to Refinitiv for the great data
another article on candlestick pattern recognition can be found here
Thanks for the post
I always appreciated your research.
Q1: if financially rewarding, *why* do you make it available?
Thanks
why not? I am a strong believer in open source and sharing ideas. This specific idea I got form another blog: https://robotwealth.com/pattern-recognition-with-the-frechet-distance/
Hello , I saw this reply on some some website talkin about pattern recognition. I’m not looking to waste your time. I’m an old guy 77 years old who has been playing around with developing indicators for trading. I know nothing about coding or programming not to bore you it took many years to develop a chart that I believe will work if I can put pattern recognition to buy and sell. Is there anyone or a program that you could direct me to or assist me with. Any advice or pictures Direction would be greatly appreciated
Sorry, but without programming skills it will be hard in this area. Why not read a good book from Tolstoi instead of worrying where the market might go?
Thats not very nice of you to say that to someone trusting your expertise to guide him in the right direction, is it?
sometimes being nice is not a good advice
nice implementation and thanks for sharing!
Спасибо
This is really interesting. Much more elegant than ways I have tried pattern scanning using volatility changes within time periods. How can I read the tradesignal code in order to mess around with it? Seems to be an error page of sorts after entering the password.
thanks.
the password (as mentioned in article) is: iconsent
seems to work fine over here…
I cannot read the code after using this password: iconsent
sorry for the inconvenience. Just checked, it works over here. Try using a different browser?
I am still failed to access the link with this password by using Chrome, Firefox, IE and edge. I have no idea why. Anyway, Thanks for your help.
Hi!
Thanks a lot!
For some reason it just shows:
“noticed” phrase after I put the password.
sorry, then there has been a spam attack from your IP and wordpress blocks it. Please try again in a few hours or from a different IP
Is this what quant traders for hedge funds use?
Where do you find this type of research so that I can look into this more indepthly?
sorry, no idea. try to do it by yourself…
they use whatever promises to make money
Hi Kahler Philip!
Thank you very much for the information. I tried to convert the code into javascript and wasn’t able after several attempt.
Can you help me with the conversion as you understand both the concept and the code?
sorry, no java…
Thanks for your excellent coding I am able to convert it to easylanguage which I will use to create scanner to scan for stocks at VBottom .
Do you think we can do this similar coding for pennant , M and W , as well as triangle patterns ?
Thank you
Regards
Tony
sure. Just fill the array with the numbers needed or create a different array length.
For patterns over several bars you might want to have several definitions. (a M pattern can go over 20 to 50 bars, do a 20, 35 &50 bar definition to find most of them…)