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

Discussion in 'Strategy Building' started by sulfred, Sep 11, 2021.

  1. sulfred


    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
  2. ph1l


    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.
  3. sulfred


    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: Sep 12, 2021
  4. ph1l


    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.
    sulfred likes this.