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

 
C-4:


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

500 SBs were used and somehow 99.7% of them don't seem to fit within three sigmas.

Well, we need to calculate the software directly and check it. There is not much to say from the figure - everything seems correct to me.

If the generation scheme is binomial and neighboring samples are completely independent, the TSP should be satisfied. But if the independence condition is not fulfilled (bad oscillator, etc.), then "fat tails" are quite possible

 
 

how to calculate text size in pixels ?

DrawText vs GetTextExtent

#define DT_CALCRECT 0x00000400

#import "user32.dll"
        int DrawTextA(int hDC, string lpchText, int nCount, int lpRect[4], int uFormat);
        int GetWindowDC(int hWnd);
        int ReleaseDC(int hWnd, int hDC);
#import

start()
{
  string txt="abcdef1234567";
  int hWnd=WindowHandle(Symbol(), Period());
  int hDC=GetWindowDC(hWnd);
  int rect[4]={0,0,0,0};
  DrawTextA(hDC, txt, 8, rect, DT_CALCRECT);
  ReleaseDC(hWnd, hDC);
  Print("x1="+rect[0]+" y1="+rect[1]+"  x2="+rect[2]+" y2="+rect[3]);
}
 
// Функция GetTextExtentPoint32 вычисляет ширину и высоту заданной строки текста.
BOOL GetTextExtentPoint32
(
  HDC hdc,           // дескриптор DC
  LPCTSTR lpString,  // текстовая строка
  int cbString,      // число символов в строке
  LPSIZE lpSize      // размер строки
);
 

GetTextExtentPoint32 is probably more correct

but in principle DrawTextA counts too. The only thing is to change HFONT to the required one. Otherwise, I don't think the result will be quite correct.
 
sergeev:

GetTextExtentPoint32 is probably more correct

The string variable stores the int-value in its internal representation in four bytes.

How it got there is not important.

Can we get this number into an int-variable without using bitwise operations?

 
more:

The string variable stores the int-value in the internal representation in four bytes.

How it got there is not important.

Can we get this number into an int-variable without using bitwise operations?

std::string sText = "12";
int nValue = (MAX_CHAR + 1) * sText[0] + sText[1];
Approximately like this for two bytes.
 
Zhunko:
About this for two bytes.

What is this ?

I'm talking about variables in an MQL4 program.

 
more:

The string variable stores the int-value in the internal representation in four bytes.

How it got there is not important.

Can we get this number into an int-variable without using bitwise operations?


You can, by multiplying each byte by a power of 256 and adding it. Something like this, roughly...

 
Integer:


You can, through multiplying each byte by a power of 256 and adding it.

In other words, it goes like this:

int i = StringGetChar(str,3) ;

i +=StringGetChar(str,2) * 256;

i +=StringGetChar(str,1) * 256*256;

i +=StringGetChar(str,0) * 256*256*256;


Very good.

Thank you !

Reason: