Features of the mql5 language, subtleties and tricks - page 52

 
Alexey Navoykov:
Please correct the code, the first function has number 5 instead of DealsNum. And the check for INT_MAX makes no sense

Thank you, I have corrected it. Checking for INT_MAX - if without input parameters, the Expert Advisor will not slow down and will not call the wasteful HistorySelect.

 
Orders in the history table are sorted by time of placement (not by execution/cancellation). Take this into account when calling HistorySelect.
 
fxsaber:
Orders in the history table are sorted by time of placement (not execution/cancellation). Take this into account when calling HistorySelect.

It would be good to add to this how things stand with trades and positions - to have a complete picture.

 
Artyom Trishkin:

It would be good to add to this how the deals and positions are - to have a complete picture.

There is no way to deal with positions - they are not in the History. And with the deals unambiguously - there is only one time DEAL_TIME.

 
fxsaber:

There is no way to deal with positions - they are not in the History. And with deals unambiguously - there is only one time DEAL_TIME.

Yes, but the positions are in the list of current.

 
Artyom Trishkin:

Yes, but the positions are in the list of current ones.

Please clarify, I don't understand at all.

 
fxsaber:

Please clarify, I don't understand it at all.

PositionsTotal() on a hedge account will return what? The number of positions. They are in some kind of list. And how are they sorted? That's what I'm talking about.

 
Artyom Trishkin:

PositionsTotal() on a hedge account, what will it return? The number of positions. They are in some kind of list. And how are they sorted? This is what I'm talking about.

Got it. I haven't clarified this point for myself, because I haven't encountered a situation where it may be necessary.

 

During the first pass of the Agent job pack (for example, during a single tester run), the time between the start of the Expert Advisor and the first NewTick event may take several seconds. On the next passes of the pack this time is zero.

The last pass of the pack of tasks the Agent performs up to 10% longer than the previous ones.

 
// Перемещение папки. Описание такое же, как у FileMove - https://www.mql5.com/ru/docs/files/filemove
bool FolderMove( const string FolderNameSrc, const string FolderNameDst, const int Common_Flag = 0, const int Mode_Flags = FILE_REWRITE )
{
  if (FolderNameSrc == FolderNameDst)
    return(false);

  string FileName;
  const long handle = ::FileFindFirst(FolderNameSrc + "\\*", FileName, Common_Flag);

  bool Res = false;

  if (handle != INVALID_HANDLE)
  {
    do
    {
      const string TmpFileNameSrc = FolderNameSrc + "\\" + FileName;
      const string TmpFileNameDst = FolderNameDst + "\\" + FileName;

      if (::FileIsExist(TmpFileNameSrc, Common_Flag))
        Res = ::FileMove(TmpFileNameSrc, Common_Flag, TmpFileNameDst, Mode_Flags);
      else
      {
        const string TmpFileNameSrc2 = ::StringSubstr(TmpFileNameSrc, 0, ::StringLen(TmpFileNameSrc) - 1);
        const string TmpFileNameDst2 = ::StringSubstr(TmpFileNameDst, 0, ::StringLen(TmpFileNameDst) - 1);

        if (!FolderMove(TmpFileNameSrc2, TmpFileNameDst2, Common_Flag, Mode_Flags))
          Res = ::FolderCreate(TmpFileNameDst2, Mode_Flags & FILE_COMMON);
      }
    }
    while (::FileFindNext(handle, FileName));

    ::FileFindClose(handle);
  }

  return(::FolderDelete(FolderNameSrc, Common_Flag) && Res);
}
Документация по MQL5: Файловые операции / FileMove
Документация по MQL5: Файловые операции / FileMove
  • www.mql5.com
Файловые операции / FileMove - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5