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

 
fxsaber:

Reductions.

Well I reset the array through FileWriteArray, if FileSave reduces the size, then the developers should probably adjust the code of the FileWriteArray function

 
Konstantin:

Well, I reset the array through FileWriteArray, if FileSave reduces the size, then the developers probably need to adjust the code of the FileWriteArray function

Look in the Help.

 

Forum on trading, automated trading systems and trading strategies testing

Discussion of the article "Hedging position accounting system added to MetaTrader 5"

fxsaber, 2018.01.17 18:45

Chronologically

  1. Pending order triggered partially - opened position with Position_ID = Order_Ticket.
  2. Closed the position manually.
  3. The rest of the order has been executed - the position with Position_ID != Order_Ticket has opened.

The result of ORDER_POSITION_ID, and how the HistorySelectByPosition will work is still a question.

Obviously, the DEAL_ORDER of one (out of two) opening deal in its order will be DEAL_POSITION_ID != ORDER_POSITION_ID.

So, you really shouldn't count on HistorySelectByPosition, even for Hedges.

 

After setting the EventTimer the first call to OnTimer does not happen immediately, but after a specified timer interval.

 
fxsaber:

After setting the EventTimer the first call to OnTimer does not happen immediately, but after a specified timer interval.

Interesting and useful observation. Thank you. But it's logical...

 
A nuance of comparing integers using a real example
void OnStart()
{
  const ulong StartTime = GetMicrosecondCount();
  
  Sleep(1000);
  
//  if (GetMicrosecondCount() > StartTime + 1000000) // Неправильно
  if (GetMicrosecondCount() - StartTime > 1000000) // Правильно
    Print("Прошло больше секунды.");
  else
    Print("Прошло меньше секунды."); 
}
 
fxsaber:
A nuance of comparing integers on a real example
1e6 is a literal of type double.
 
Combinator:
1e6 is a literal of type double.

Knowing. The example is not affected by this. Think of it as an integer million.

 
fxsaber:

Knowing. The example is not affected.

It directly affects
 
Combinator:
Affects directly

I agree, but that's not what this example is about. In the code I replaced it with a million.

Reason: