Morse code - page 5

 
Morse code version "1.004": Fixed bug - pattern was read backwards.
Files:
Morse_code.mq5  15 kb
 
Vasiliy Sokolov:

Question: What is the probability of a combination appearing in the market that matches the required 64 digits? Answer: (1/2^64)*BarsCount. That is, with a probability close to 100% such a combination will not be found. So, obviously, only number int or long cannot fully describe the pattern, so we need an additional parameter specifying the length of the pattern.

This is if we look at all 64 bits. But it is obviously unnecessary.

When I performed such investigations, I found out that it is not reasonable to take the length of a candlestick pattern longer than 5. Moreover, if we distinguish between bars not only by the "bull-bear" ones but by their sizes as well, even this length is too long.

If we have a pattern with large length - it is much more reasonable to specify "characteristic features" and simply limit the length by minimal and maximal values.

 

Not exactly formed yet, but the general idea is: two parameters - length and int parameter from 0 to 3. Inside the Expert Advisor is already interpreting this number (Pseudobit representation):

intLength (aka mask)Pseudobit representation
0х0
1х1
2xx00
3xx01
4xx10
5xx11
6xxx000
7xxx001
8xxx010
9xxx011
10xxx100
11xxx101
12xxx110
13xxx111

It remains to decide how to code these parameters. A straightforward solution: a structure in which each int parameter (the first column of the table) corresponds to a Pseudobit representation (the third column). If you limit the mask to only five characters (xxxxxx), the structure is not very big.

And the most important thing - the optimizer allows you to rearrange the structure!

 

You can also make three separate parameters for the three candles in the properties window. Two birds are killed at once - it is both clear and optimised.

The same can be done for 10 candlesticks.

 
Dmitry Fedoseev:

You can also make three separate parameters for the three candles in the properties window. Two birds are killed at once - it is both clear and optimised.

The same may be done for 10 candlesticks.

I support

input bool svecha1 = true;
input bool svecha2 = false;
input bool svecha3 = true;
input bool svecha4 = false;
input bool svecha5 = true;
 
Vladimir Karputov:

Not exactly formed yet, but the general idea is: two parameters - length and int parameter from 0 to 3. Inside the Expert Advisor is already interpreting this number (Pseudobit representation):

intLength (aka mask)Pseudobit representation
0х0
1х1
2xx00
3xx01
4xx10
5xx11
6xxx000
7xxx001
8xxx010
9xxx011
10xxx100
11xxx101
12xxx110
13xxx111

It remains to decide how to code these parameters. A straightforward solution: a structure in which each int parameter (the first column of the table) corresponds to a Pseudobit representation (the third column). If the mask is limited to only five characters (xxxxxx), the structure is not very big.

And the most important thing - the optimizer allows you to rearrange the structure!


This is the enumeration for mask from x to xxxx:

//+------------------------------------------------------------------+
//| Enum pattern type: numerical or string                           |
//+------------------------------------------------------------------+
enum ENUM_PATTERN_MASK
  {
   _0=B'0',       // 
   _1=B'1',       //  
   _2=B'00',      // 
   _3=B'01',      // 
   _4=B'10',      // 
   _5=B'11',      // 
   _6=B'000',     // 
   _7=B'001',     // 
   _8=B'010',     // 
   _9=B'011',     // 
   _10=B'100',    // 
   _11=B'101',    // 
   _12=B'110',    // 
   _13=B'111',    // 
  };
 

Morse code version "1.005"

Here is the solution: the mask is defined as an enumeration

//+------------------------------------------------------------------+
//| Enum pattern mask                                                |
//+------------------------------------------------------------------+
enum ENUM_PATTERN_MASK
  {
   _0    =   0    ,   // 0
   _1    =   1    ,   // 1

   _2    =   2    ,   // 00
   _3    =   3    ,   // 01
   _4    =   4    ,   // 10
   _5    =   5    ,   // 11

   _6    =   6    ,   // 000
   _7    =   7    ,   // 001
   _8    =   8    ,   // 010
   _9    =   9    ,   // 011
   _10   =   10   ,   // 100
   _11   =   11   ,   // 101
   _12   =   12   ,   // 110
   _13   =   13   ,   // 111

   _14   =   14   ,   // 0000
   _15   =   15   ,   // 0001
   _16   =   16   ,   // 0010
   _17   =   17   ,   // 0011
   _18   =   18   ,   // 0100
   _19   =   19   ,   // 0101
   _20   =   20   ,   // 0110
   _21   =   21   ,   // 0111
   _22   =   22   ,   // 1000
   _23   =   23   ,   // 1001
   _24   =   24   ,   // 1010
...

in OnInit(), the mask is translated into a string variable"sExtMorseCode" (the variable"sExtMorseCode" is declared globally) in the ConvertNumberToString function:

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool ConvertNumberToString(const ENUM_PATTERN_MASK num_mask,string &text)
  {
   bool result=true;
//---
   switch(num_mask)
     {
      case 0:  text="0"; break;
      case 1:  text="1"; break;
      case 2:  text="00"; break;
      case 3:  text="01"; break;
      case 4:  text="10"; break;
      case 5:  text="11"; break;
      case 6:  text="000"; break;
      case 7:  text="001"; break;
      case 8:  text="010"; break;
      case 9:  text="011"; break;
      case 10: text="100"; break;
...
      case 53: text="10111"; break;
      case 54: text="11000"; break;
      case 55: text="11001"; break;
      case 56: text="11010"; break;
      case 57: text="11011"; break;
      case 58: text="11100"; break;
      case 59: text="11101"; break;
      case 60: text="11110"; break;
      case 61: text="11111"; break;
      default: text=""; return(false);
     }
//---
   return(result);
  }

Two problems have been solved:

1). the user sees the pattern as "0101" in the input parameters:

Convenient view of the input parametre

2). The input parameter is perfectly optimized in the tester.

Files:
Morse_code.mq5  20 kb
 
Vladimir Karputov:

Morse code version "1.005"

Two problems have been solved:

1). the user sees the pattern as "0101" in the input parameters:

2). The input parameter is perfectly optimized in the tester.

The user can specify a candlestick combination without mathematical calculations according to the initial idea?

 
Pyxis:

The user can specify a candlestick combination without mathematical calculations, as originally conceived?


Yes, he can do it without any mathematical calculations. And now you don't need to enter the combination manually - just select the appropriate candlestick combination from the"pattern mask" drop-down list.
 
Ran in the tester (full optimization)Morse code version "1.005"- pure patterns (like now) are not fishy at all :(.