Errors, bugs, questions - page 743

 
Fia:

Hello, gentlemen developers!

Can we make changes in the MQL5 compiler to at least give us a warning?

for errors of this kind in the code.

if(Flag_Exitl=true) {break;}


The comparison condition here is not correct (it should be == ), that's why it will always be break.

How to address this situation in the compiler (if it's possible at all), so that I could get less bumpy when writing code?

(I've thought it won't work, it seems like we should separate assignment and comparison in if, so the question is removed).

You can do it, if the condition contains boolean assignment with constant on the right.
Variables of bool type can not be compared to true/false, but used directly (essentially it's a yes/no flag)
if(Flag_Exitl) {break;}
Your way is buttery.
Документация по MQL5: Основы языка / Типы данных / Целые типы / Тип bool
Документация по MQL5: Основы языка / Типы данных / Целые типы / Тип bool
  • www.mql5.com
Основы языка / Типы данных / Целые типы / Тип bool - Документация по MQL5
 
notused:

I get error 4401 regularly

ERR_HISTORY_NOT_FOUND

The following indicator code

will give an error right after start (if not on D1). Or rather, once you start the terminal and open the chart - put the indicator on, you will get an error. If the terminal is not closed, then there will not be such an error at start.

But after some time (a couple of hours - 2 hours were enough for me) we will see that we will get the error on the already open chart. (I ran it on m30)

Representatives, MetaQuotes, please comment, is it supposed to be like this?
 
struct SDaylyRange {double min, max, open, close;};
struct SNoDaylyRange {
   uint x;
   double y;
 };

void OnStart()
  {
   SNoDaylyRange tmp;
   SDaylyRange tmp2 = tmp;
  }
This code compiles without a single warning. Although it probably shouldn't even compile
 
notused:
..error 4401 appears regularly.

reference:

Organising data access

Data Accessibility

Availability of data in HCC format or even in HC ready-to-use format does not always mean the unconditional availability of these data for display on a chart or for use in mql5-programs.

When accessing the price data or indicator values from mql5-programs, we should remember that it is not guaranteed to be available at a certain moment of time, or from a certain point in time. This has to do with the fact that MetaTrader 5 does not store the full copy of the required data for mql5-program, but gives direct access to the terminal database in order to save resources.

The price history for all timeframes is built from the common data in HCC format and any update of the server leads to the data update for all timeframes and indicator recalculation. Therefore, the access to the data may be denied even if the data was available just a moment ago.

CopyRate

When requesting data from the indicator, if the requested timeseries haven't been built or they need to be downloaded from the server, the function will return -1 immediately, but the process of downloading/building will be initiated.
This seems to be the way it should be. Before CopyRate SERIES_SYNCRONIZED you can check...
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Информация об исторических данных по инструменту
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Информация об исторических данных по инструменту
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Информация об исторических данных по инструменту - Документация по MQL5
 
Swan:

fact sheet:

Looks like it should be. Up to CopyRate SERIES_SYNCRONIZED you can check...

I'm just sprinkling ashes on my head, yeah. Thank you.

Although it's strange to see the request for two bars and history unavailable, although only zero bar changes. But never mind - if it's described in the documentation, it's not an error

 

in my IsNewBar there was an error coming out.

Instead of

CopyTime(sym, period, 0, 1, currentTime);

I should have written

   if (CopyTime(sym, period, 0, 1, currentTime) < 1) return (false);

And I was wondering why every couple of hours IsNewBar(PERIOD_D1) == true -> hence I found out about history inaccessibility, but I couldn't think of a function I wrote a year or two ago.

 
sergeev:

Why the indicator cannot handle colour types (COLOR_ARROW, etc.) with more than one buffer

code sample

We set two DRAW_COLOR_ARROW (buf1 and buf2) and for each one additional colour buffer (clr1, clr2)

At the same time, though the second buffer buf2 gets High/Low bars, it doesn't show up on the chart. It seems that colour of arrows in this buffer = clrNONE. That is, colour setting in clr2 buffer does not work


here is a screenshot. only values of buf1/clr1 are visible. values of the second buffer are not displayed with colour though values are received.


Where is error?

The question was simply created to answer "in MQL5 DNA".

Such nonsense also on DRAW_FILLING and even on relatively normal DRAW_HISTOGRAM2 (not so stable of course, but bugs occur).

Just from the instability of bugs, I conclude that you are unlikely to get an answer without a CD.

 

Bild 642 for Win32

Some problem with three-dimensional arrays of double appears if you by mistake go beyond the array limits when outputting in the Print function

The script goes into an infinite loop by itself.

int i1,i2,i3;
double out[3][7][7];
for(i1=0;i1<7;i1++) out[0][0][i1] = inp[i1];
double sum;
sum = 0.0;
for(i3=0;i3<3;i3++){
   for(i2=0;i2<7;i2++){
      for(i1=1;i1<7;i1++)  sum += W[i3][i2][i1] * out[i3][i2][i1-1];
      out[i3][i2][i1] = f(sum + WT[i3][i2]);
      sum = 0.0;
      Print("out[",i3,"][",i2,"][",i1,"] = ",out[i3][i2][i1]);
   }
}
Print("sum = ",sum);

}
//-------------------------------------------------------
double f(double x){return(1/(1+MathExp(-x)));}
 
IgorM:

Bild 642 for Win32

some problem with three-dimensional arrays double appears if you by mistake step outside the array when outputting in the Print function

Actually, the overrun occurs two lines earlier

and you're calling an exponent from a non-existent element, most likely zero.

Look in the log

 
sergeev:

Generally, the out-of-bounds occurs two lines earlier

and you're calling an exponent from a non-existent element, most likely zero.

look in the log

Yes, I know, and I cited code that doesn't cause a run-time error, but loops the script