Errors, bugs, questions - page 108

 
Interesting:

More reliable? Why is getting handles at initialisation not reliable? Why is it unreliable to check for necessary data? And even more so, why is the presence of checks not reliable?

For beginners it may not be so easy, but with time everything will become clear...

In fact, I'm trying to figure it out right away, not later... I don't want to just copy some actions without understanding their meaning. If I've got the code as a built-in function like in MQL4, I will probably add some extra parameter with number of bars.

 

Why does it load?

 
simpleton:

"Ordinary numbers" are constant expressions that also have a type. In this case it is int type.

An expression consisting of a multiplication of two subexpressions, each of int type, is also of int type. This is where the overflow occurs.

And only then the implicit conversion from the int expression's type to the long type occurs during the initialization of the long variable.

Everything is clear here. By the way, it is not necessary to cast each of the operands to long in this case. We can just cast one and implicitly cast the second.

This is what I was trying to say, but using less academic language. The main thing is to warn other observers.

The question is different. Where in what Talmud does it say that :

"Ordinary numbers" are constant expressions that also have a type. In this case it is int type.

For example, if X is set to 10000000000 , then it becomes long type ? And why not ulong or datetime or even string.?

What is the type of number 255uchar orshort ?

 
gumgum:

Why does it load?

Probably because GBPJPY crosspairs and there are margin calculations somewhere in the code. IMHO
 
simpleton:

There seems to be a mix-up between the log and the code. The above code works "clean". And, to get such a log, I had to make variables A and B of int or uint type, and variable X of uint type:

And here is work of original code:

Build 314 (20 Aug 2010).

I cited a different code

long A = AccountInfoInteger(ACCOUNT_LOGIN);  // 661701
long B = A;
long C = 661701;

Print(" A=",A,"  B=",B,"  C=",C);

long X =(long)10000;

long L1 = A*X;
long L2 = B*X;
long L3 = C*X;

Print(" L1=",L1,"   L2=",L2,"   L3=",L3);

Pay special attention to the first line, your account may have a different number. Look it up and put it in long C =

Checked result again

2010.08.25 20:23:12     Servis (EURUSD,H1)       L1=2322042704   L2=2322042704   L3=6617010000
2010.08.25 20:23:12     Servis (EURUSD,H1)       A=661701  B=661701  C=661701

Build 314 (20 Aug 2010).

 
Please tell me why the SymbolInfoDouble(_Symbol,SYMBOL_POINT) function gives a five digit value of 0.00001 after the decimal point for USDCHF, when the accepted value for this pair is 0.0001?
Документация по MQL5: Получение рыночной информации / SymbolInfoDouble
Документация по MQL5: Получение рыночной информации / SymbolInfoDouble
  • www.mql5.com
Получение рыночной информации / SymbolInfoDouble - Документация по MQL5
 
rut_:
Please tell me why the SymbolInfoDouble(_Symbol,SYMBOL_POINT) function of USDCHF pair produces a five-digit point size after the decimal point 0.00001, when this pair is accepted for the point value 0.0001?

why do you think there are 4 digits in this instrument, the terminal clearly shows that the quotes there are 5-digit
 
sergey1294:
What makes you think there are 4 digits in this instrument, the terminal clearly shows that the quotes there are 5 digits

This function can return different point values even in accounts with five digits, it all depends on the settings that will be accepted by the broker.

For example, one brokerage company has the following comment

1 pips (пункт) равен:

для валютных пар с 5 знаками после запятой - минимальному изменению 4-го знака после запятой (0,0001);
для валютных пар с 3 знаками после запятой - минимальному изменению 2-го знака после запятой (0,01).

and another one has 1 pips equal to the fifth digit.

 
SHOOTER777:

That's what I was trying to say, but in less academic terms. And most importantly to warn other seekers.

The question is different. Where in which Talmud does it say that :

"Ordinary numbers" are constant expressions, which also have a type. In this case it is int type.

For example, if X is set to 10000000000 , then it becomes long type ? And why not ulong or datetime or even string.?

What is the type of number 255uchar orshort ?

The constant 10000000000 is already of type long.

How should I put it? Normal languages have suffixes-modifiers that allow you to specify the type of constant without using an explicit type conversion. For MQL5, I have only found it for float. Therefore, it is impossible to define constants of uchar, ushort, uint, ulong, char, short and long types (if the constant value fits into int type) without explicit type conversion.

The constant 255 has an int type. You can find something in the type descriptions, for example, character constants are declared as having type ushort. There is also information about constants of datetime type, color type, bool type, double type and string type.

You may try to print the size of the constant type, as long as the sizeof operation is introduced (but why is it introduced, please explain to one of developers):

void OnStart()
{
  Print("sizeof true                = ", sizeof true);
  Print("sizeof 'a'                 = ", sizeof 'a');
  Print("sizeof 255                 = ", sizeof 255);
  Print("sizeof 200000000           = ", sizeof 20000000);
  Print("sizeof 10000000000         = ", sizeof 10000000000);
  Print("sizeof C'128,128,128'      = ", sizeof C'128,128,128');
  Print("sizeof D'2004.01.01 00:00' = ", sizeof D'2004.01.01 00:00');
  Print("sizeof 1.0f                = ", sizeof 1.0 f);
  Print("sizeof 1.0                 = ", sizeof 1.0);
  Print("sizeof \"Xa!\"               = ", sizeof "Xa!");
  Print("sizeof \"Xa-xa-xa!!!\"       = ", sizeof "Xa-xa-xa!!!");
}

/* Вывод в лог (хронология - сверху вниз):
GF      0       1 (EURUSD,M15)  02:03:23        sizeof true                = 1
IS      0       1 (EURUSD,M15)  02:03:23        sizeof 'a'                 = 2
LF      0       1 (EURUSD,M15)  02:03:23        sizeof 255                 = 4
JI      0       1 (EURUSD,M15)  02:03:23        sizeof 200000000           = 4
EQ      0       1 (EURUSD,M15)  02:03:23        sizeof 10000000000         = 8
DG      0       1 (EURUSD,M15)  02:03:23        sizeof C'128,128,128'      = 4
JN      0       1 (EURUSD,M15)  02:03:23        sizeof D'2004.01.01 00:00' = 8
GE      0       1 (EURUSD,M15)  02:03:23        sizeof 1.0f                = 4
GR      0       1 (EURUSD,M15)  02:03:23        sizeof 1.0                 = 8
QJ      0       1 (EURUSD,M15)  02:03:23        sizeof "Xa!"               = 12
ER      0       1 (EURUSD,M15)  02:03:23        sizeof "Xa-xa-xa!!!"       = 12
*/

In general, only f for double-constants works by modifying them to float, which can be seen by the size of such a constant type.

Here, the only sensible use of sizeof operation I could find. :)

 
SHOOTER777:

I gave you a different code

Pay special attention to the first line, there may be a different number on your account. Look it up and put it in long C =

Checked the result again

Build 314 (20 Aug 2010).

No, I don't have the same effect as you do. I have only to check the bit versions of MT5. I have the 64-bit version, what is yours?

By the way, does the modified code I have tested give you the same results as I do?

If yes, then what I see is very similar to that bug about "origin" of a value - i.e. the code can behave differently (both correctly and incorrectly) depending on where the value on which the further calculations are based originally came from.

Reason: