Any questions from a PROFI to a SUPER PROFI - 1. - page 17

 
Am I correct in assuming that I need to convert the strings to an integer array?
 
hrenfx:
Am I correct in assuming that I need to convert the strings to an integer array?
To Unicode. The integer array is just to be substituted for the DLL
 

This?

#define SIZEOF_INT 4
#define BYTE_BITS 8
#define SIZEOF_ANSI 1
#define SIZEOF_UNICODE 2

void StringToINT( string Str, int& Buffer[], bool UniCode = FALSE )
{
  int Koef;
  
  if (UniCode)
    Koef = SIZEOF_UNICODE;
  else
    Koef = SIZEOF_ANSI;
    
  int i = 0, j, Len = StringLen(Str);
  int Pos = 0, Size =  Koef * Len / SIZEOF_INT;
    
  if ((Koef * Len) % SIZEOF_INT > 0)
    Size++;
    
  ArrayResize(Buffer, Size);
    
  while (i < Len)
  {
    Buffer[Pos] = 0;
    
    for (j = 0; j < SIZEOF_INT / Koef; j++)
    {
      if (i < Len)
        Buffer[Pos] |= StringGetChar(Str, i) << (Koef * j * BYTE_BITS);
        
      i++;
    }
    
    Pos++;
  }
  
  return;
}

string INTToString( int& Buffer[], bool UniCode = FALSE )
{
  string Str = "";
  int Tmp, Size = ArraySize(Buffer);
  int Koef;
  
  if (UniCode)
    Koef = SIZEOF_UNICODE;
  else
    Koef = SIZEOF_ANSI;
  
  for (int i = 0; i < Size; i++)
  {
    Tmp = Buffer[i];
    
    while (Tmp != 0)
    {
      Str = Str + CharToStr(Tmp & 0xFF);
      
      Tmp >>= Koef * BYTE_BITS;
    }
  }  
  
  return(Str);
}

void start()
{
  int Buffer[];
  string Str = "abcde";
  
  StringToINT(Str, Buffer, FALSE); // ANSI
  Str = INTToString(Buffer, FALSE); // ANSI
  Print(ArraySize(Buffer));

  Print(Str);

  StringToINT(Str, Buffer, TRUE); // UNICODE
  Str = INTToString(Buffer, TRUE); // UNICODE  

  Print(ArraySize(Buffer));
  Print(Str);
  
  return;
} 
 

Thank you all for your help and participation.

on page 15 - Zhunko and TheXpert have already pointed me in the right direction and I did almost everything right :)


But through inexperience, I forgot and sent MultiByteToWideChar function instead of CP_ACP to CP_UTF8

Thank God Ilnur has come along and corrected my code, otherwise I wanted to give up on this robot in MT4


Thanks again to all for the solution, we are a gang together!:)

 
Files:
 

I am developing an indicator that incorporates a normal distribution bell. Accordingly, here is the problem to be solved.

To estimate the statistical significance of the obtained results we need to find the value of the standard deviation of a random process at the moment of testing N. In this case mathematical expectation is known in advance and equals zero, while the probability of positive outcome (+1) of each trial is equal to the probability of negative outcome (-1) and equals 0.5 correspondingly.

Example 1. Two players will play a game of eagle until they make 1000 coin tosses. Determine the limits of the range, in which one of them will win and the other one will lose with probability 99.7%.

That is, all that is needed is a formula for this very sigma curve. I know, the problem is as old as the world and I myself know how to calculate these deviations on the basis of the available sequence (MNC), but I need to calculate it by itself, without BP itself.

 
C-4:

I am developing an indicator that incorporates a normal distribution bell. Accordingly, here is the problem to be solved.

To estimate the statistical significance of the obtained results we need to find the value of the standard deviation of a random process at the moment of testing N. In this case mathematical expectation is known in advance and equals zero, while the probability of positive outcome (+1) of each trial is equal to the probability of negative outcome (-1) and equals 0.5 correspondingly.

Example 1. Two players will play a game of eagle until they make 1000 coin tosses. Determine the limits of the range, in which one of them will win and the other one will lose with probability 99.7%.

That is, all that is needed is a formula for this very sigma curve. I know, the problem is as old as the world, and I myself know how to calculate these deviations on the basis of the available sequence (OLS), but I need to calculate it by itself, without BP.

C-4,

For a binomial distribution, which is the case here (and which approximates well to a normal distribution when N is large), the standard deviation (sigma) is sqrt(N*p*q), where N is the number of trials, p is the probability of a single win, q = 1-p is the probability of a single loss.

the root added)))

 

I.e. sqrt(1000*0.5*0.5) = sqrt(250) = 15.81

Accordingly, 99.7% fits within plus or minus three sigmas 3*15.81 = 47.434

 
In general, to determine approximately any quantile of the binomial scheme, one can use the Mois-Laplace integral theorem (google). The values of the function F(x) are well tabulated, and there are algorithms that perform numerical integration. The problem is standard, so it has been solved a million times already)
 
alsu:

That is, sqrt(1000*0.5*0.5) = sqrt(250) = 15.81

Accordingly, 99.7% of them are within plus or minus three sigmas 3*15.81 = 47.434


Thanks for the tip. But for some reason the function seems a bit narrow:

500 SBs were used and somehow it does not seem that 99.7% of them fit within three sigmas.