Errors, bugs, questions - page 438

 
joo:
Maybe the mere presence of Sleep (compared to its absence) in the code somehow affects the overall execution time, but the fact that Sleep does not count in the tester - that's for sure.
Well, I'm not an expert here... Half a minute delay in processing Sleep() function with a negative argument and loss of 17 testing days - those are the facts.
 

The code hangs up the terminal:

   MqlRates s1[];

   int count=TerminalInfoInteger(TERMINAL_MAXBARS);
   int s1_copied=CopyRates(Symbol(),Period(),0,count,s1);
   if(s1_copied<=0)
      Print("Ошибка копирования ценовых данных ",GetLastError());
   else Print("Скопировано ",ArraySize(s1)," баров");

   Comment(ArrayMaximum(s1,0,WHOLE_ARRAY));

   ArrayFree(s1);

What is the reason?

 
Graff:

The code hangs up the terminal:

What is the reason?

For starters:
 int count=TerminalInfoInteger(TERMINAL_MAXBARS);
 Print("count=",count);

Is the terminal not set to Unlim?

 
uncleVic:
For starters:

Isn't Unlim in the terminal settings?


max bars is set to 5000. can this value be reduced?
 
Graff:
the max bars are 5000. can this value be reduced?

I don't think you can do less (I'm not sure).

What does Print(count) show?

 
uncleVic:

I don't think less is possible (not sure).

Well, what does Print(count) return?

2011.06.30 21:41:29 MultiInstruments3 (EURUSD,M5) 5000 bars copied
2011.06.30 21:41:29 MultiInstruments3 (EURUSD,M5) count=5000

in comment -1

I tried it with another symbol but it did not show up in the comment -1

REMARK: Freeze after a few sec. I start the code from int OnInit()

 
joo:
Yes, and it works in the tester, because Sleep is ignored in the tester.

Sleep is fully and accurately emulated in the Sleep tester.

In the example, due to arithmetic overflow when dealing with integer values, there was just a 17.5 day wait. The tester waited exactly that long.

Therefore, there is no error in the tester or in the MQL5 execution environment, but there is an obvious error made by the programmer.

 

Renat:

That is, there is no error of the tester or the MQL5 execution environment, but there is a clear error of the programmer.

It's quite clear.

Renat:

Sleep is emulated in the tester completely and quite accurately.

Due to the arithmetic overflow when working with integer values the wait time is 17.5 days. That's exactly how long the tester waited.

Hmm, there you go. And I mistakenly thought Sleep was just ignored.

So, for example, if I set Sleep (3 months) in Expert Advisor in testing mode, the tester would simply fast-forward the history for 3 months? - That's great.

 
Yes, it will rewind. Only the limit of the function is 49 days, until the millisecond counter is full.

During the waiting period the tester continues to fully emulate the trading environment, including all processing of previously placed orders. The tester in MT5 is very detailed.
 
Graff:
2011.06.30 21:41:29 MultiInstruments3 (EURUSD,M5) 5000 bars copied
2011.06.30 21:41:29 MultiInstruments3 (EURUSD,M5) count=5000

in comment -1

I tried it with another symbol but it did not show up in the comment -1

REMARK: Freeze after a few sec. I will run the code from int OnInit()

Yes. We didn't even notice the elephant.

Something makes me very suspicious about this line:

   Comment(ArrayMaximum(s1,0,WHOLE_ARRAY));

ArrayMaximum

searches for the maximum item in a one-dimensional numeric array.

intArrayMaximum(
doublearray[],// array to search
intstart=0//from which index we start the search
intcount=WHOLE_ARRAY,// number of indexes to be checked
);


and in our case:

   MqlRates s1[];

I think the compiler shouldn't skip this. What do you have? Not even a warning? If not, put in a request to Service Desk. Okay?

Общайтесь с разработчиками через Сервисдеск!
Общайтесь с разработчиками через Сервисдеск!
  • www.mql5.com
Ваше сообщение сразу станет доступно нашим отделам тестирования, технической поддержки и разработчикам торговой платформы.