What is a better way to make use of DTW for chart pattern finding

Hi all,

I have an Indicator created on MT4 using DTW and correlation to classify the time series data. There is an issue I found related to the DTW algorithm.
When the pattern is long, the DTW score will become bigger and bigger. Also, the distance metric I am using is Euclidean Distance, when I am measuring the distance between 2 chart bar, (Open High Low Close), that is a 4 dimension space. It turns out that it is harder to distinguish the similarity between different patterns since a small change of the value can represent a big different.

I would like to see if there is a better way to implement the DTW algorithm for similar pattern finding purpose. Or even there is another algorithm other than DTW.

Here are some screen shot to show how my indicator works:

Step 1 - Build the database for pattern recognition
  1. Select the indicator mode
    1. upload_2021-9-12_11-27-56.png
  2. Select the pattern
    1. upload_2021-9-12_11-28-29.png
  3. Database created
    1. upload_2021-9-12_11-29-19.png
Step 2 - Pattern checking
  1. Change Indicator mode
    1. upload_2021-9-12_11-30-2.png
  2. User can check the pattern
    1. upload_2021-9-12_11-30-30.png
Step 3 - Live
  1. Change Indicator mode
    1. upload_2021-9-12_11-31-8.png
  2. Live classifying
    1. upload_2021-9-12_11-31-34.png
 
I would like to see if there is a better way to implement the DTW algorithm for similar pattern finding purpose.

I researched dynamic time warping in 2019 and found this was the fastest one, and the site includes free relatively-portable C++ source code for it.
http://sites.labic.icmc.usp.br/prunedDTW/
This is a supplementary web site to the paper titled "Speeding Up All-Pairwise Dynamic Time Warping Matrix Calculation". Here you can find source codes to reproduce our experiments, links to get the same datasets, detailed results and a brief bio of the authors. Please, visit the webpage containing the proceedings of the SDM 2016 to find our paper.

Here, you find a proof of correctness of Pruned DTW.

Important notice! If you want to use PrunedDTW in your own implementation in a linear complexity of space, you should first read this notice.

here. A similar implementation of the traditional DTW can be found here.
We notice that these are not the implementation used in our experiments. Actually, these codes are pretty much better! Cleaner and faster. If you are interested in reproduce our experiments, please check the remaining of this section.

Here, you find source codes to reproduce our results. Each experiment contains different files to dowload. However, we notice that the classes that implement ED, DTW and PrunedDTW (as well as the classes to read files and other auxiliary methods) are the same in all the cases.
The methods were implemented in C++ and we used Matlab to generate figures. Details about how to use the codes come into the download files (in a README file our commented in the code).


results1.png
The first results (shown in the paper in Figure 10, with graphs similar to the above figure) were obtained by this C++ code (with executables for Linux and Windows). In addition, we used this Matlab code to plot the curves.

The results related to Figure 11 in the paper (where we used the DTW obtained with a 10% warping window as the UB for the DTW with 20% and so on) were generated by this C++ code. To plot the curves, we used the same Matlab code mentioned above.

The results showed in Table 2 (Percentual runtime of FastDTW and PrunedDTW relative to the conventional DTW algorithm) came from this C++ code. The FastDTW implementation used in this work can be obtained here. From this code, we only change the Euclidean distance mehtod to return the squared Euclidean distance.

We are devolping wrappers to use our method with Matlab and R. Coming soon.



UCR Time Series Classification/Clustering Page.

here.

If you are interested in get the clustering results used in the Section 6.2, you can get it here.
 
I researched dynamic time warping in 2019 and found this was the fastest one, and the site includes free relatively-portable C++ source code for it.
http://sites.labic.icmc.usp.br/prunedDTW/

Thanks @ph1l

This is interesting to make the comparison faster.

My question is that currently I may need to compare and identity which DTW result is the best. The issue is that the input chart pattern is 4 dimensions (Open, High, Low, Close).
A small difference of the the DTW score will make a big impact to the result.

Is there a way to improve that?
 
Last edited:
My question is that currently I may need to compare and identity which DTW result is the best. The issue is that the input chart pattern is 4 dimensions (Open, High, Low, Close).
A small difference of the the DTW score will make a big impact to the result.

Is there a way to improve that?

In this post, I found increasing the warping window proportion with dynamic time warping improved the precision and resulted in better predictions. For that test, I'm not sure if the inputs had multiple dimensions.
 
Back
Top