Morse code - page 3

 

Make two parameters. One for human - string, second for machine - int. The third variable is for type selection. In any case, when indicator starts, print second option of combination's coding. If consequence is set to 100, then print additional information - from how many to how many can change parameter int.

For a candlestick with equal opening and closing we can assume that it has the direction of the nearest candlestick with unequal opening and closing. If one candlestick is coded with three numbers, 0- for equal opening and closing, then there will be too many rare sequences.

 

The optimizer needs two parameters to run: the combination length and the counter. Suppose our combination length is 4, then 2^4 = 16. It means that the counter should be from 0 to 15. Going through it in the optimizer we will get all combinations of 4-digit patterns.

In order not to confuse the user, you must add ENUM_PATTERN_TYPE structure, which sets pattern type: numeric or string. If you select a string pattern, do not use counters and length of combinations. And vice versa, if you want to run in the optimizer, select the numeric pattern type.

 

I've seen something like this before, it's searchable on Yandex for "candlecode"

 
Vasiliy Sokolov:

The optimizer needs two parameters to run: the combination length and the counter. Suppose our combination length is 4, then 2^4 = 16. It means that the counter should be from 0 to 15. Going through it in the optimizer we will get all combinations of 4-digit patterns.

In order not to confuse the user, you must add the ENUM_PATTERN_TYPE structure, which defines pattern type: numeric or string. If you select a string pattern, do not use counters and length of combinations. And vice versa, if we want to run in the optimizer, we select the numeric pattern type.


I have added the ENUM_PATTERN_TYPE structure, while I suggest to hide the "int" type parameter which defines the type of candlestick combination from the user:

  • anyway "int" type is a number and does not correlate in any way with a binary type of a string parameter
  • The "int" type is only needed during optimization.

but leave only these parameters:

CTrade         m_trade;                      // trading object
//+------------------------------------------------------------------+
//| Enum pattern type: numerical or string                           |
//+------------------------------------------------------------------+
enum ENUM_PATTERN_TYPE
  {
   PATTERN_TYPE_NUMERICAL=0,  // numerical
   PATTERN_TYPE_STRING=1,     // string 
  };
//---
input ENUM_PATTERN_TYPE    InpPatternType          = PATTERN_TYPE_STRING;  // pattern type
input string               InpsMorseCode           = "101";                // string Morse code (max 5 characters)
input ENUM_POSITION_TYPE   InpPosType              = POSITION_TYPE_BUY;    // posinion type
input double               InpLot                  = 0.1;                  // lot
sinput ulong               m_magic                 = 88430400;             // magic number
input ulong                m_slippage              = 30;                   // slippage
//---
string sExtMorseCode="";
int max_string_len=5;         // limitation of the length of the pattern "string"
int i_morse_code=0;           // int Morse code (use only if pattern type=numerical)
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if(InpPatternType==PATTERN_TYPE_STRING)
     {

Inputs Morse code 1.002

 

I don't quite get it - are these programmers or suckers?

Why translate something into something?

If we need a code 101 - that's the normal value of 5. That's it. What's the problem? Translate mentally the decimal into binary?

I made similar experiments, only my candle had four more sizes - from small to large. That makes eight different candle sizes. And, consequently, three bits. In the pattern we write the number (ulong) - the grid is bigger than for a twenty-bar pattern.

The problem is, in my opinion, far-fetched.

 
George Merts:

I don't quite get it - are these programmers or suckers?

Why translate something into something?

If we need a code 101 - that's the normal value of 5. That's it. What's the problem? Translate mentally the decimal into binary?

I made similar experiments, only my candle had four more sizes - from small to large. That makes eight different candle sizes. And, consequently, three bits. In the pattern we write the number (ulong) - the grid is bigger than for a twenty-bar pattern.

The problem is, in my opinion, far-fetched.


Normal users cannot mentally convert decimal to binary :)
 
George Merts:

I don't quite get it - are these programmers or suckers?

Why translate something into something?

If we need a code 101 - that's the normal value of 5. That's it. What's the problem? Translate mentally from decimal to binary?

I made similar experiments, only my candle had four more sizes - from small to large. That makes eight different candle sizes. And, consequently, three bits. In the pattern we write the number (ulong) - the grid is bigger than for a twenty-bar pattern.

The problem is, in my opinion, far-fetched.


The program will be used by a regular user, not a programmer (it's been already mentioned above and more than once) - and for him "101" and "5" are two different numbers, while for him "5" doesn't contain any information about the relative position of the candles, but "101" clearly says "bullish, bearish, bullish".

 

How do you code the dodge?

For example the "evening star" pattern can be bullish-dodge (or wolf or pin bar)-bear. If you ignore the dodge (wolf or pin bar) then the pattern is not correctly identified. I think 1 bit for coding a candle will not be enough 2 bits per 1 candle.

For example the bull candle is 01, the bear candle is 10 and the other candles are 11. Then, 'evening star' would be 01 11 10, 'morning star' would be 10 11 01.

....

I was also thinking. How to code a takeover pattern? A simple bullish-bearish combination does not tell us anything, but a bullish-big bearish combination already tells us about a bullish-bearish takeover. Or alternatively we could sum these two candlesticks into one and get a pin bar and code this summed candlestick as 11.


 
Vitalii Ananev:

How do you code the dodge?

For example the "evening star" pattern can be bullish-dodge (or wolf or pin bar)-bear. If you ignore the dodge (wolf or pin bar) then the pattern is not correctly identified. I think 1 bit for coding a candle will not be enough 2 bits per 1 candle.

For example the bull candle is 01, the bear candle is 10 and the other candles are 11. Then "evening star" will be 01 11 10, "morning star" will be 10 11 01


The shadows are not coded in any way (at least at this stage). Maybe later ...
 
Vladimir Karputov:

The shadows are not coded in any way (at least at this stage). Perhaps later...


We should consider everything at once to avoid re-doing it later.

....

Again, if we return to the "Evening Star" pattern, it can be seen as a bullish-small candle-bearish and a bullish-bearish takeover. It means that we have a composite pattern consisting of a bullish candle and a bearish absorption. And if we sum up all three candlesticks from the pattern, we get a pin bar again.