Errors, bugs, questions - page 624

 
ivandurak:

Error loading file in Expert Advisor. Find 10 differences. The first code refers to the script, the second to the Expert Advisor, they are identical Ctrl-C Ctrl-V. The code works in the script, it does not work in the Expert Advisor.

To find 10 differences, you need to look at the code of file opening. (and add to this open code output of error code in case of failure)

Second, if you want to test EA with this file add line #property tester_file "KitMaRsi.csv" to EA code

 
Hello. In MQL4, the ERR_HISTORY_WILL_UPDATED(4066) error may occur when executing a program. The GetLastError() function returns the error code. Do you have a similar error in MQL5? I searched herehttps://www.mql5.com/ru/docs/constants/errorswarnings/errorcodes but did not find anything similar.
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки времени выполнения
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки времени выполнения
  • www.mql5.com
Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки времени выполнения - Документация по MQL5
 
Druide:
Hello. In MQL4, when executing a program, the ERR_HISTORY_WILL_UPDATED(4066) error may occur, the code of which is returned by the GetLastError() function. Do you have a similar error in MQL5? I searched herehttps://www.mql5.com/ru/docs/constants/errorswarnings/errorcodes but did not find anything similar.

I will not say anything about the error. The terminal itself makes sure that the data are synchronised, you can synchronise (load) the data and check whether the history is synchronised or not.

The organization of data access is described here (there is an example of history loading script).

Functions that may be needed: SeriesInfoInteger and SymbolIsSynchronized

 
awkozlov:

The switch with character variables doesn't seem to work...

Instead of:

'Type' - illegal switch expression type
'Buy' - constant expression is not integral


Use identifiers rather than text. Which would be simpler and more logical...

//Что-то типа такого (или свои идентификаторы). Написать функцию конвертирующую текст в идентификатор и обратно (при необходимости) достаточно просто.
//Да и выглядит это более профессионально в конечном итоге.
  switch(type)
  {
  case ORDER_TYPE_BUY: {direction = type;  price = SymbolInfoDouble(zSymbol,SYMBOL_ASK); break;}
  case ORDER_TYPE_SELL: {direction = type; price = SymbolInfoDouble(zSymbol,SYMBOL_BID); break;}
  default: {return(lot_value);}
  }

  switch(type)
  {
  case OP_BUY: {direction = ORDER_TYPE_BUY;  price = SymbolInfoDouble(zSymbol,SYMBOL_ASK); break;}
  case OP_SELL: {direction = RDER_TYPE_SELL; price = SymbolInfoDouble(zSymbol,SYMBOL_BID); break;}
  default: {return(lot_value);}
  }
 
awkozlov:

The switch with character variables doesn't seem to work...

Instead:

'type' - illegal switch expression type
'Buy' - constant expression is not integral

I have to draw it like this:

It's not so clear and it's crooked.

It works well in other languages.

Should I write it in another way?

I did this.

#define  OP_BUY               0
#define  OP_SELL              1
#define  OP_BUYLIMIT          2
 
Interesting:

I will not say anything about the error. The terminal itself makes sure that the data are synchronised, you can synchronise (load) the data and check whether the history is synchronised or not.

Organization of access to data is described here (there is an example of history loading script).

Functions that may be needed: SeriesInfoInteger and SymbolIsSynchronized

Thank you! Got it.
 

Are there analogues of such libraries as stdlib.mqh, WinUser32.mqh, stderror.mqh in MQL5, in particular, I am interested in PostMessageA function?

 

When optimising with multiple agents, the results are displayed on the chart in the order they are processed, i.e. alternating. Is it possible to make the order in which the results are displayed according to the selection of parameters, as it was in MT4? I.e., the result that came later would be inserted in the proper order. I'm just saying that it's not convenient to follow trends and regularities during optimization and the results can be analyzed only after the calculations are done.

++: It's all about optimization with full brute force - it naturally doesn't make sense on genetics.

 
Konstantin83:

Description in the handbook

In fact

bool ObjectCreate(
long chart_id, // chart identifier
string name, // object name
ENUM_OBJECT type, // object type
intn win, // window index);


Thank you, corrected.
 
x100intraday wrote https://www.mql5.com/ru/forum/1111/page610#comment_130250:

Let's run the iFractals example code from the help on M1, which uses the second - full - form of OnCalculate() function call. But before that inside this function let's correct

to

in order not to lose sight of a single line with the output (if we leave it as it is, visually 1 will always be visible, because other values are rare and immediately replaced by 1, so it seems that 1 is always displayed) After runtime we see that non-unit values occur every minute, i.e. on every new bar, which unequivocally indicates that the indicator is redrawn every minutefully despite the fact that the code useseconomical algorithm. The doubters can add several lines of code, drawing, say, vertical lines on each fractal and then remove them after the first drawing and wait for the full set of the same lines to appear after a minute with a new bar. Anything about finishing only last fractal or line is out of the question for some reason.

Yes, indeed, the indicator from the example at the iFractals() function refreshes its indicator buffers with values from the built-in indicator. The second condition in the line (highlighted in yellow) is "to blame" for this:

//--- если это первый запуск вычислений нашего индикатора или изменилось количество значений в индикаторе iFractals
//--- или если необходимо рассчитать индикатор для двух или более баров (значит что-то изменилось в истории)
   if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)
     {

Explanation: on each tick these two values are compared and there is an assignment at the end of the function

//--- запомним количество значений в индикаторе Fractals
   bars_calculated=calculated;

And the difference between them can arise in spirit:

  1. the history itself, on which the fractal indicator is calculated, has changed (paging of the history by the user)
  2. occurrence of a new bar event

In this case the separation of the two events is not done, you've discovered that. I can't say yet if we're going to fix this example so that we don't have such questions.

Reason: