Errors, bugs, questions - page 439

 
Help plz, I am making an EA in the Wizard in MEditor5, compile, put on a chart and it (the EA) crashes, i.e., the icon appears and disappears.
 
cokfx:
Help, plz making an EA in the Wizard in MEditor5, compiling, put on a chart and it (the EA) pops up, i.e., the icon appears and disappears.

On what symbol and on what TF do we set the owl? What does it say in the log?
 
Renat:

It means that there is no error of the tester or the MQL5 execution environment, but there is an explicit mistake of the programmer.

Hm. The programmer has detected an unexpected behavior of the program, detected the essence of this behavior, reproduced it explicitly, gave a simple example bringing it to absurdity(Sleep with negative values) and the programmer says that it is a programmer's error :) Although "programmer's mistake" means, for example, an explicit statement that the Sleep function in the tester does not work.

It follows from the above explanations that developers believe that it is acceptable to use negative values in Sleep() function. Although from the function description ("...it delays execution of the current Expert Advisor or script for a particular interval") we cannot suppose that the delay interval can be calculated with negative numbers. Speaking about errors, consider my statement that the terminal should have prevented using negative values in Sleep() function as such.

 
Yedelkin:

Hm. The programmer has detected an unexpected behavior of the program, detected the essence of this behavior, reproduced it explicitly, gave a simple example bringing it to absurdity(Sleep with negative values) and the programmer says that it is a programmer's error :) Although "programmer's mistake" means, for example, an explicit statement that the Sleep function in the tester does not work.

It follows from the above explanations that developers believe that it is acceptable to use negative values in Sleep() function. Although from the function description ("...delays execution of the current Expert Advisor or script for a particular interval") we cannot suppose that the delay interval can be calculated with negative numbers. Speaking about errors, consider my statement that the terminal should have prevented using negative values in Sleep() function as such.

And you probably expected that you would exit Sleep before entering it if the delay was negative?
 

Yedelkin, how do you imagine that the compiler controls parameters of functions? And there are dozens of such functions which must have parameters' values under control.

There is one of two things here - either speed of compilation or total paranoid control.

We have chosen the first way. In this case the runtime subsystem does not skip wrong parameters at runtime by generating an error code, which we can get using the GetLastError function.

Документация по MQL5: Проверка состояния / GetLastError
Документация по MQL5: Проверка состояния / GetLastError
  • www.mql5.com
Проверка состояния / GetLastError - Документация по MQL5
 
Would you be so kind as to calculate the result of your negative value, relate it to 32 bits of int, then read about arithmetic overflow and find your 17 days.

Welcome to the world of real programming.
 
uncleVic:
You must have expected that you would exit Sleep before entering it with a negative value?

The expectation assumption is wrong.

It was not intended to work with negative values at all. See my post above:"from the function description ("...delays execution of the current EA or script for a certain interval") it is hard to assume that the delay interval can be counted in negative numbers". And it's not about what I "might expect", it's about the fact that, in fact, the SLeep function allows to work with negative values. When this was found out - sent a message. If you consider such operation of the Sleep() function acceptable, it will remain so.

 
Yedelkin:

but that, in fact, the SLeep function allows you to work with negative values.

What do you suggest? To terminate the program in an emergency?
 
Yedelkin:

The assumption about expectations is wrong.

It was not intended to work with negative values at all. See my post above:"from the function description ("...delays execution of the current EA or script for a certain interval") it is hard to assume that the delay interval can be counted in negative numbers". And it's not about what I "might expect", it's about the fact that, in fact, the SLeep function allows to work with negative values. When this was found out - sent a message. If you consider such operation of Sleep() to be acceptable, it remains so.

Of course, the internal representation is unsigned.

You can change the type of parameter to uint.

 
stringo:

Yedelkin, how do you imagine that the compiler controls parameters of functions? And there are dozens of such functions which must have parameters' values under control.

There is one of two things here - either speed of compilation or total paranoid control.

We have chosen the first way. In this case the runtime subsystem does not skip incorrect parameters at the stage of execution, generating an error code, which we can get using the GetLastError function.

Yes gentlemen, I'm always on your side! :) And I know in programming only a small part of what you know (I am guided only by MQL5 Reference). But if I see some points that are not clear to me personally - I write about it. I try to give a vivid example of the "unclear moment", if possible. Accordingly, if you think that the "alarm is false", then it turns out that either I have misunderstood the reference materials, or the reference materials do not reflect all the information necessary to understand the moment. In this case, it would be enough for me to have an indication (warning) in the "Sleep function" section that (1) "the compiler doesn't control the value of the function parameter, so the function can work with negative values" and (2) "Sleep() function is fully supported by the tester".

I have no idea how the compiler works. Proceeding from the described paradigm of the compiler's work, I have an urge: to reflect in the notes to dozens of functions that the values of their parameters are not controlled by the terminal.