Discussion of article "Merrill patterns"

 

New article Merrill patterns has been published:

In this article, we will have a look at Merrill patterns' model and try to evaluate their current relevance. To do this, we will develop a tool to test the patterns and apply the model to various data types such as Close, High and Low prices, as well as oscillators.

In order to clarify how and for what data we are going to apply Merrill patterns, we need to understand what they actually are. The main two categories are the patterns resembling the letters M and W. They are called M and W patterns. Each of the categories contains 16 patterns.

Fig. 1 represents 16 M patterns. As we can see, the difference is in the mutual arrangement of the five points that make up the pattern.  


Author: Alexander Fedosov

 
The M2 and M4 patterns in the pictures are the same - is this a typo?
 

Interesting material, thanks!

I didn't like the implementation of pattern recognition:

//+------------------------------------------------------------------+
//|| Pattern Recognition|
//+------------------------------------------------------------------+
PATTERN_TYPE CProgram::GetPatternType(double A,double B,double C,double D,double E)

it is clear that the method fulfils its task, perhaps for this article it is the optimal solution.


I would like to find a more elegant (universal) solution to this problem, something like a matrix for storing data (array)? - has anyone come across such an implementation of pattern search?

 
Sergey Pavlov:
The M2 and M4 patterns in the pictures are the same - is that a typo?

We'll fix it, thanks.

 
Igor Makanu:

Interesting stuff, thanks!

didn't like the implementation of pattern recognition:

it is clear that the method fulfils its task, perhaps for this article it is the optimal solution


I would like to find a more elegant (universal) solution to this problem, something like a matrix for storing data (array)? - has anyone met such an implementation of pattern search?

Of course, we could put it all into a structure or array. But so far it is easier to understand from scratch in the form of points of a polyline.

 
Igor Makanu:

...

I would like to find a more elegant (universal) solution to this problem, something like a matrix for storing data (array)? - has anyone come across such an implementation of pattern search?

I have, I've done it universally. But I'm unlikely to find it, I don't even know where to start looking.

There is one line, there are two points. The third point can occupy one of two positions: between the first and the second point, or above the first point (let's assume that the first line is directed upwards). Now there are three points, the fourth point can occupy one of three positions or the bottom of two.... First there are two points in the array, you stand at index 1, add all variants of the third point location to the end of the array. You move to index 2, add all variants of another point to the end of the array.... etc. The pattern itself is set by numbers, as soon as the array size reaches the specified size - here is the pattern with this number. You need an array of structures, and in the structure an array with point numbers.

***

The array does not contain coordinates of points, but numbers of vertices from the beginning. For example, M16 would be encoded like this: {1, 3, 2, 5, 4}. And if you add another vertex, you get these options?

{1, 3, 2, 5, 4}

{1, 3, 2, 5, 6, 4}

{1, 3, 2, 5, 4, 6}


***

Here's how we check it. Let's say we are looking for a pattern: {1, 3, 2, 5, 4} This means that vertex 1 is below 3, 5 is above 2 and below 4, etc.

 
Dmitry Fedoseev:

It was, it was universal. But I don't think I'll find it, I don't even know where to start looking.

There is one line, it is two points. The third point can occupy one of two positions: between the first and the second point, or above the first point (let's assume that the first line is directed upwards). Now there are three points, the fourth point can occupy one of three positions or the bottom of two.... First there are two points in the array, you stand at index 1, add all variants of the third point location to the end of the array. You move to index 2, add all variants of another point to the end of the array.... etc. The pattern itself is set by numbers, as soon as the array size reaches the specified size - here is the pattern with this number. You need an array of structures, and in the structure an array with point numbers.

***

The array does not contain coordinates of points, but numbers of vertices from the beginning. For example, M16 would be encoded like this: {1, 3, 2, 5, 4}. And if you add another vertex, you get these variants?

{1, 3, 2, 5, 4}

{1, 3, 2, 5, 6, 4}

{1, 3, 2, 5, 4, 6}


***

And the way to check it is this. Let's say we are looking for a pattern: {1, 3, 2, 5, 4} This means that vertex 1 is below 3, 5 is above 2 and below 4, etc.

Yeah, that's the kind of coding I'd like to find.

It looks like a weighted graph adjacency matrix, where the weight will mean which vertex is higher/lower than the current vertex.

Матрица смежности графа — Викиконспекты
Матрица смежности графа — Викиконспекты
  • neerc.ifmo.ru
Матрицей смежности (англ. Adjacency matrix) невзвешенного графа называется матрица , в которой — количество рёбер, соединяющих вершины и , причём при каждую петлю учитываем дважды, если граф не является ориентированным, и один раз, если граф ориентирован. Матрицей смежности (англ. Adjacency matrix) взвешенного графа называется матрица , в...
 

Excellent work - both in terms of the problem statement and its software solution, and in terms of the implementation of the graphical interface.

And just by way of suggestion: if possible, add the results of research of the effectiveness of the figures themselves for finding market entry points.

Probably, due to the voluminous nature of the task, it can be a separate topic and a separate publication.

 
Aleksandr Masterskikh:

Excellent work - both in terms of the problem statement, and its software solution, and the implementation of the GUI.

And just as a suggestion: if possible, add the results of the research of the effectiveness of the figures themselves for finding market entry points.

Probably, due to the voluminous nature of the task, it can be a separate topic and a separate publication.

Thank you, Alexander, for liking my article. About the research, the application from this article is ready for them. The current customisation options already present a large number of options for searching.

In the next article I will try to expand the possibilities of the application.

 
Alexander Fedosov:

Of course, we could put it all into a structure or array. But this way it is easier to understand from scratch in the form of points of a polyline.

It is clear that in addition to universality, the code in the article should be clear and readable, but I like combinatorial problems, or to wiggle my brain, so I grouped this function by the first condition through a search in ME:

//+------------------------------------------------------------------+
//|| Pattern Recognition|
//+------------------------------------------------------------------+
PATTERN_TYPE GetPatternType(double A,double B,double C,double D,double E)
  {
   if(A>B && C>A && B>E && E>D) return(W6);
   if(A>B && C>E && E>A && B>D) return(W11);
   if(A>B && E>C && C>A && B>D)return(W12);
   if(A>B && C>E && E>D && D>A)return(W15);
   if(A>B && E>C && C>D && D>A) return(W16);

// A>C
   if(A>C && B>D && D>A && C>E) return(M3);
   if(A>C && B>D && D>E && E>A) return(M8);
   if(A>C && D>B && B>E && E>A) return(M10);
   if(A>C && C>B && B>E && E>D) return(W1);
   if(A>C && C>E && E>B && B>D) return(W2);
   if(A>C && C>E && E>D && D>B) return(W4);
   if(A>C && E>A && C>B && B>D) return(W8);
   if(A>C && E>A &&  C>D && D>B)return(W10);
// C>A else ? 
   if(C>A && B>D && D>C && A>E) return(M7);
   if(C>A && D>B && B>C && A>E) return(M9);
   if(C>A && B>D && D>E && E>C) return(M13);
   if(C>A && D>B && B>E && E>C) return(M15);
   if(C>A && D>E && E>B && B>C) return(M16);
   if(C>A && A>E && E>B && B>D) return(W7);
   if(C>A && A>E && E>D && D>B) return(W9);
   if(C>A && E>C && A>D && D>B) return(W14);
   
   
   if(B>A && A>D && D>C && C>E) return(M1);
   if(B>A && A>D && D>E && E>C) return(M2);
   if(B>A && D>B && A>C && C>E) return(M5);
   if(B>A && D>B && A>E && E>C) return(M6);
   if(B>A && D>E && E>B && A>C) return(M11);
   

   if(B>D && D>A && A>E && E>C) return(M4);
   if(B>D && D>C && C>E && E>A) return(M12);
   if(B>D && A>E && E>C && C>B) return(W3);
   if(D>B && B>C && C>E && E>A) return(M14);
   if(D>B && A>E && E>C && C>D) return(W5);
   if(D>B && C>E && E>A && A>D) return(W13);
   
   
   return(-1);
  }

there should still be a compact and universal solution!..... but I don't see it yet

 
Igor Makanu:

It is clear that in addition to universality, the code in the article should also be visual and readable, but I like problems on combinatorics, or to wiggle my brain, so I grouped this function by the first condition through the search in ME:

there should still be a compact and universal solution!..... but I don't see it yet

So good solution above Dmitry suggested. You can play it this way:

In the arguments of the GetPatternType method pass the pattern dimension and that's it. It itself makes all possible combinations from this number and based on this data searches for a given one in a structure or array.