Features of the mql4 language, subtleties and techniques - page 14

 
Note to developers.


https://docs.mql4.com/ru/basis/types/integer


The C++ standard only guarantees the size of the char type. The lengths of the other types are implementation specific. The match table is incorrect and may lead to undefined behavior.

Целые типы - Типы данных - Основы языка - Справочник MQL4
Целые типы - Типы данных - Основы языка - Справочник MQL4
  • docs.mql4.com
Целые типы представлены в языке MQL4 одиннадцатью видами. Некоторые из типов могут использоваться вместе с другими, если этого требует логика программы, но при этом необходимо иметь ввиду правила преобразования типов. В таблице приведены характеристики каждого типа. Кроме того, в...
 
Comments not related to this topic have been moved to "Questions from MQL4 MT4 MetaTrader 4 beginners".
 

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

fxsaber, 2018.12.01 11:15

Super-brake design
string Str[];
const int handle = FileOpen(FileName, FILE_READ | FILE_ANSI | FILE_TXT);  

FileReadArray(handle, Str);

A 40Mb file of 1 million lines takes 18 seconds to read.


The same output result, but done differently

  uchar Bytes[];
  const int handle = FileOpen(FileName, FILE_READ | FILE_BIN);
  
  FileReadArray(handle, Bytes);

  string Str[];
  StringSplit(CharArrayToString(Bytes), '\n', Str);

Is already done in 0.5 seconds.


 

Overloaded 16Gb RAM with tasks. Chrome ended up freezing, MT5 with Optimisation running - no problem. But more interesting is MT4.

Indicators are still working, but Expert Advisors stopped due to "out of range" because of absence of ArrayResize result check.

I don't always want to check ArrayResize but here is a confirmation that absence of this check can stop, for example, a fighting Expert Advisor on VPS.


The only thing I can't understand is how the result is "out of range" if ArrayResize was previously done with a large Reserve?

 
fxsaber:

Overloaded 16Gb RAM with tasks. Chrome ended up freezing, MT5 with Optimisation running - no problem. But more interesting is MT4.

Indicators are still working, but Expert Advisors stopped due to "out of range" because of absence of ArrayResize result check.

I don't always want to check ArrayResize but here is a confirmation that absence of this check can stop, for example, a fighting Expert Advisor on VPS.


The only thing I can't understand is how it got "out of range" if ArrayResize was previously done with a large Reserve?

easy :-) this is true for most languages/systems.

Reserve allocated virtual memory and when I ran out of physical memory, I couldn't find a free page. We got a processor exception, which after a series of processing turned into out-of-range

By the way, the fact that MT did not crash at all confirms the quality of workmanship :-)

 

Tough mistake on the subject of order sorting in history. Sorting by closing time is not always the case, unfortunately.

Checking script

#property strict

void OnStart()
{
  datetime time = INT_MAX;
  
  for (int i = OrdersHistoryTotal() - 1; i >= 0; i--)
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
    {
      if (OrderCloseTime() > time)
      {
        Print(time);
        OrderPrint();
        
//        break;
      }
      
      time = OrderCloseTime();
    }
}


Why such an elementary code could not be written immediately for self-testing is a mystery.

It is also a puzzle: how could it be that orders are not sorted by time? I ask this question because I used a custom tester in a QB. And logically, since the order got into the history, the record of it there later than the ones that got there before. How to shake this logic is not clear at all.

Perhaps, the orders are stored on different MT5 servers and this mess occurs during synchronization. I hope this is a bug of the Terminal and not of the MT4 server. I also hope that this does not happen with trades in MT.

 
fxsaber:

Tough mistake on the subject of order sorting in history. Sorting by closing time is not always the case, unfortunately.

Checking script


Why such an elementary code could not be created for instant self-testing is a mystery.

It is also a puzzle: how could it be that orders are not sorted by time? I ask this question because I used a custom tester in a QB. And logically, since the order got into the history, the record of it there later than the ones that got there before. How to shake this logic is not clear at all.

Perhaps, the orders are stored on different MT5 servers and this mess occurs during synchronization. I hope this is a bug of the Terminal and not of the MT4 server. I also hope that this does not happen with trades in MT.

Have you tried changing the sorting in the account history?

 
Artyom Trishkin:

Have you tried changing the sorting in the account history?

Doesn't affect the result.

 
Artyom Trishkin:

Have you tried changing the sorting in the account history?

Yes, it should have no effect. Only the number of orders in the account history tab is affected. You have to keep an eye on that.

 
fxsaber:

Does not affect the result.

The closing time of the position is given by the server.

Reason: