Errors, bugs, questions - page 440

 
Renat:
Please calculate the result of your negative value and correlate it with 32 bits of int, then read about arithmetic overflow and find your 17 days.

Welcome to the world of real programming.

I did not ask the question "where did 17 days come from? I'll repeat: I found a situation I did not understand in the tester, told it to me and received an explanation that (1) Sleep() function works with negative values too, and it produces a non-zero delay, (2) Sleep() function's work is emulated in the tester. If developers find it acceptable, what can I return? There's no need to calculate exactly 17 days.

Документация по MQL5: Общие функции / Sleep
Документация по MQL5: Общие функции / Sleep
  • www.mql5.com
Общие функции / Sleep - Документация по MQL5
 
stringo:
What do you suggest? Terminate the programme in an emergency?
It is difficult to suggest without knowing how the system works. My aim is to sound out the question and then it's up to you. This time it turned out that the question fully fits into the current ideology of the terminal. Well, then, I'll know more.
 
uncleVic:

Yeah. We didn't see the elephant.

I have a strong suspicion about that line:


and in this case:

It seems to me the compiler shouldn't miss this. Do you have what? Not even a warning? If not, put in a request to Service Desk. Ok?


application#154746

How do we get the sequence number of the element with the maximum/minimum value in the s1.open array?

 
Yedelkin:

In this case it would be enough for me to have an instruction in "Sleep function" section ... (2) "Sleep() function is fully supported by the tester".

We have highlighted the basic questions about testing in a separate article, "Fundamentals of Testing in MetaTrader 5". Here we have tried to explain most of the nuances of using various functions in the tester. We have also explained the functions Sleep():

Sleep() function in the tester

The Sleep() function allows you to suspend for some time the execution of an mql5 program in an Expert Advisor or in a script, when working on a chart. This can be necessary when requesting some data, which at the moment of requesting are not ready and you need to wait until they are ready. A detailed example of Sleep() function use can be found in Data access organization section.

In the tester, calls of Sleep() don't delay the testing process. When calling Sleep(), the generated ticks are "played" within the specified delay, which can trigger pending orders, stops, etc. After Sleep() has been called, the time simulated in the tester is increased by the interval specified in the Sleep function parameter.

If, as a result of Sleep() execution the current time in the tester exceeds the end of the testing period, an error "infinite loop in Sleep" will be received. If such an error occurs, testing results are not discarded, all calculations are completed (number of trades, drawdown, etc.) and the results are passed to the terminal.

Function Sleep() won't work in OnDeinit() as after its call the testing time is guaranteed to be beyond the testing interval.



Figure 7. Scheme of using the Sleep() function in MetaTrader 5 terminal tester.

 
Rosh:

We have specifically covered the main issues of testing in our separate article, Fundamentals of Testing in MetaTrader 5. Here we have tried to explain most of the nuances of using various functions in the tester. We have also explained the Sleep() function:

I'm sorry, it's really my fault. I haven't tested it for 9 months and have missed the article.

It would be nice if mentioning of key articles in corresponding sections of the Reference Guide (I've already suggested something similar last year but today is a good chance to do it again). We all use F1 in the first place, after all.

 
That is, you have not done what I asked.

You have several people here trying to point out your simple error with the arithmetic overflow.
 
Renat:
That is, you didn't do what I asked.

You have several people here trying to point out your simple arithmetic overflow error.

==============================================================

You asked:

Renat:
Would you be so kind as to calculate the result of your negative value, correlate it with 32 bits of int, then read about arithmetic overflow and find your 17 days...

I replied: Yes I didn't ask the question "where exactly 17 days came from?" :) etc.

Answering your current question. What you asked for - I did not do. Because it was done by me yesterday (I had slightly different initial data, but the essence of what I understood). Had someone compiled that script, I would have received as many as two warnings. Overflow/cutoff - I dealt with that myself yesterday.

The questions were why (1) function operates with negative values of the argument and (2) gives a delay in the tester for such arguments. Yet you again point to "programmer's error" with an overflow of int type. - I.e. you reject my test sample only because "overflowed value" was specified when selecting the Sleep() function argument. But the point is not in "overflowed value". It's just an additional touch to the test sample. It seems the participants of the discussion understood it. In the end, you can insert "not overflowing value" in the test example - all other things being equal, the essence of the question will remain the same (the question itself has already been dealt with).

Anyway, thanks for the tip. Because if the compiler hadn't warned you, your advice would have probably come in handy and made you think twice.

 

What are the limitations on its usage? W =(long)ChartGetInteger(Chart_ID[i],CHART_WIDTH_IN_PIXELS,0);
H =(long)ChartGetInteger(Chart_ID[i],CHART_HEIGHT_IN_PIXELS,0);
W_B =(long)ChartGetInteger(Chart_ID[i],CHART_WIDTH_IN_BARS,0);

Calling the function from void OnInit() all is correct, but from void OnTick() the data is incorrect in particular CHART_WIDTH_IN_BARS gives the number of bars visible, although I understand should give the number of bars fit to the chart without offset

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Свойства графиков
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Свойства графиков
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы графиков / Свойства графиков - Документация по MQL5
 
Virty:

Sorry for the primitive question.

The trade query is not running. Error 10014 - wrong volume in the request.

How can I understand/calculate from inside the EA what is the maximum and minimum lot volume I can buy at the moment?

The OrderCheck function is not suitable, because it only checks and does not say how many lots can be bought.

Look at the ENUM_SYMBOL_INFO_DOUBLE enumeration and the corresponding function. Is this what you mean?
 
Yedelkin:
See ENUM_SYMBOL_INFO_DOUBLE enumeration and corresponding function. Is that what you mean?
Yes. Thank you. SYMBOL_VOLUME_MAX found it myself, and you helped.
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
Документация по MQL5: Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте
  • www.mql5.com
Стандартные константы, перечисления и структуры / Состояние окружения / Информация об инструменте - Документация по MQL5
Reason: