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

 
Artyom Trishkin:

Then I don't understand it at all. What do you mean by "OrderCommission() stores data not rounded to cents"? Where are they rounded? And how are they rounded?

In the GUI, reports and OrderPrint to cents.

 
fxsaber:

In the GUI, reports and OrderPrint to the cents.

100.12345 is rounded up to 100.12 ?

 
Artyom Trishkin:

100.12345 rounded up to 100.12 ?

Yes.

 
//+----------------------------------------------------------+
//|В скрипте могут присутствовать функции OnInit() и OnDeinit|
//+----------------------------------------------------------+
#property   strict

void OnInit()
{
  Alert("1. Инициализация скрипта");
}

void OnStart()
{
  Alert("2. Расчет");
}

void OnDeinit(const int Причина)
{
  string Прич[3]={"Эксперт прекратил свою работу, вызвав функцию ExpertRemove()",
                  "Программа удалена с графика",
                  "Программа перекомпилирована"};

  Alert(3,". ",Прич[Причина]);
}

The script may have OnInit() and OnDeinit functions

is useful if the script is looped. Then we put preparatory operations in OnInit(), a loop in OnStart() and program termination in OnDeinit()

 
Comments not related to this topic have been moved to "Any questions from newbies on MQL4, help and discussion on algorithms and codes".
 
Comments not related to this topic have been moved to "Any questions from newbies on MQL4, help and discussion on algorithms and codes".
 
Comments not related to this topic have been moved to "Any questions from newbies on MQL4, help and discussion on algorithms and codes".
 
MT5 features for cross-platform
// https://www.mql5.com/ru/docs/files/fileload
template <typename T>
long FileLoad( const string FileName, T &Buffer[], const int CommonFlag = 0 )
{
  long Res = -1;
  const int handle = FileOpen(FileName, FILE_READ | FILE_BIN | CommonFlag);
  
  if (handle != INVALID_HANDLE)
  {
    if (!(Res = FileReadArray(handle, Buffer)))
      Res = -1;
    
    FileClose(handle);
  }
  
  return(Res);  
}
// https://www.mql5.com/ru/docs/files/filesave
template <typename T>
bool FileSave( const string FileName, const T &Buffer[], const int CommonFlag = 0 )
{
  const int handle = FileOpen(FileName, FILE_WRITE | FILE_BIN | CommonFlag);
 
  const bool Res = (handle != INVALID_HANDLE) && FileWriteArray(handle, Buffer);
  
  if (handle != INVALID_HANDLE)
    FileClose(handle);
  
  return(Res);  
}
 
If you want the indicator not to receive Calculate events
#property indicator_chart_window
#property indicator_buffers 0

// Фейковый (MT4) OnCalculate
int OnCalculate( const int, const int, const int, const double& [] ) { return(0); }


The log will be

indicator on custom buffer is not supported yet


and OnCalculate will not be called.