Errors, bugs, questions - page 2828

 
fxsaber:

At the moment, there are a bunch of identical files that differ only in the last digit of the extension.

They're in different folders. Are they symlinked or something?
 
Alexey Navoykov:
They are in different folders. Are they linked by a symlink?

In MQL5 common to both Terminals.

 
How do I change the language of the MT5 interface? I think there used to be a toggle in the menu, now I can't find it.
 
Stanislav Korotky:
How do I change the language of the MT5 interface? I think there used to be a toggle in the menu, now I can't find it.

 
I encountered a strange situation the other day - the indicator on TF M1 is not correctly determining the opening price of the daily bar. The indicator has been used for about 3 years, and I had no problems with it before. The shift was very significant, about 500 pips, at the same time, in the morning it was showing correct data, but in the afternoon it was already lying. Changing TF did not help, only changing TF of indicator calculation in the indicator settings itself helped. I don't know how to reproduce it. Such glitches are scary when trading automatically.
 

When trying to create a resource, the compiler complains about the BMP file mouse.bmp

unsupported image format 'C:\Users\pc\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL5\Files\Images\MyBMP\mouse.bmp'   

Although, if used directly, there is no error and the image is displayed correctly.

#property strict
string label_name="currency_label";        // имя объекта OBJ_BITMAP_LABEL 
#resource "\\Files\\Images\\MyBMP\\Style-Pause-icon.bmp";    // путь к файлу каталог_данных_терминала\MQL4\Files\Images\MyBMP\... 
//#resource "\\Files\\Images\\MyBMP\\mouse.bmp";    
string press      ="::Files\\Images\\MyBMP\\Style-Pause-icon.bmp";    // RESOURCE
string unpress    ="\\Files\\Images\\MyBMP\\mouse.bmp";  // путь к файлу каталог_данных_терминала\MQL4\... 
//+------------------------------------------------------------------+ 
//| Expert initialization function                                   | 
//+------------------------------------------------------------------+ 
int OnInit() 
  { 
//--- создадим кнопку OBJ_BITMAP_LABEL, если ее еще нет 
   if(ObjectFind(0,label_name)<0) 
     { 
      //--- попробуем создать объект OBJ_BITMAP_LABEL 
      bool created=ObjectCreate(0,label_name,OBJ_BITMAP_LABEL,0,0,0); 
      if(created) 
        { 
         //--- привяжем кнопку к правому верхнему углу графика 
         ObjectSetInteger(0,label_name,OBJPROP_CORNER,CORNER_RIGHT_UPPER); 
         //--- теперь настроим свойства объекта 
         ObjectSetInteger(0,label_name,OBJPROP_XDISTANCE,100); 
         ObjectSetInteger(0,label_name,OBJPROP_YDISTANCE,50); 
         //--- сбросим код последней ошибки в 0 
         ResetLastError(); 
         //--- загрузим картинку для состояния кнопки "Нажата" 
         bool set=ObjectSetString(0,label_name,OBJPROP_BMPFILE,0,press); 
         //--- проверим результат 
         if(!set) 
           { 
            PrintFormat("Не удалось загрузить картинку из файла %s. Код ошибки %d",press,GetLastError()); 
           } 
         ResetLastError(); 
         //--- загрузим картинку для состояния кнопки "Отжата" 
         set=ObjectSetString(0,label_name,OBJPROP_BMPFILE,1,unpress); 
          
         if(!set) 
           { 
            PrintFormat("Не удалось загрузить картинку из файла %s. Код ошибки %d",unpress,GetLastError()); 
           } 
         //--- отдадим графику команду на обновление, чтобы кнопка появилась сразу же, не дожидаясь тика 
         ChartRedraw(0); 
        } 
      else 
        { 
         //--- объект создать не удалось, сообщим об этом 
         PrintFormat("Не удалось создать объект OBJ_BITMAP_LABEL. Код ошибки %d",GetLastError()); 
        } 
     } 
//--- 
   return(INIT_SUCCEEDED); 
  } 
//+------------------------------------------------------------------+ 
//| Expert deinitialization function                                 | 
//+------------------------------------------------------------------+ 
void OnDeinit(const int reason) 
  { 
//--- удалим объект с графика  
   ObjectDelete(0,label_name); 
  }
//+------------------------------------------------------------------+

file is in archive.

Editor


Behavior in MT4 is the same...

Документация по MQL5: Общие функции / ResourceCreate
Документация по MQL5: Общие функции / ResourceCreate
  • www.mql5.com
[in]  Относительный путь к файлу, содержащему данные для ресурса. Если путь начинается с обратной косой черты "\" (пишется "\\"), то файл ищется относительно папки Если второй вариант функции вызывается для...
Files:
Images.zip  3 kb
 
Mikhail Dovbakh:

When trying to create a resource, the compiler complains about the BMP file mouse.bmp

Although, if used directly, there is no error and the image is displayed correctly.

file is in archive.

Editor


Behavior in MT4 is the same...

Doesn't want to swallow 8 bitmaps.
Better convert to 24 or 32 bit.

32-bit is preferable when you need alpha-channel, then you can get an image on a transparent background instead of rectangular background covering the chart.

In that case, bitmaps must be converted to an array via ResourceReadImage and COLOR_FORMAT_ARGB_NORMALIZE must be used.

Files:
Images.zip  3 kb
 
Afternoon, the following bug [MT4 (1280) / ME (2375)] has occurred after an update :

Expanding scope via template parameter to access functions with a return value.

Example 1:Calling a function of a base class.
class _f
{
public:
   
   bool f(){ return false; }
   
   void g(){ Print("g");   }   
};

template<typename F>
class run_f : public F
{
public:

   bool f(){ return F::f(); } //<--- '::' - unexpected token

   void g(){ F::g(); }        //<--- OK
};


//+------------------------------------------------------------------+

void OnStart() 
{ 
   run_f<_f> r;
   
   r.f();
   r.g();
}  
If we access a void function via scope expansion or without promoting the return value, it's OK.

Example 2: Calling a static function of a class.
class _f
{
public:
   
   static bool static_f(){ return true; } 
   static void static_g(){}    
};

template<typename F>
bool call_static()
{
   return F::static_f(); //<--- '::' - unexpected token and function not defined
   
   F::static_f();       //<--- OK (не используем возварщаемое значение)
   
   //F::static_g();     //<--- OK (void функция)
   
   return true;  
}

//+------------------------------------------------------------------+

void OnStart() 
{ 
   call_static<_f>();
}  

It worked before update. In MT5/MetaEditor 2560 it works fine too.
Документация по MQL5: Основы языка / Операторы / Оператор возврата return
Документация по MQL5: Основы языка / Операторы / Оператор возврата return
  • www.mql5.com
Оператор возврата return - Операторы - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Not the same behaviour for Select functions.
void OnStart()
{
  PositionSelectByTicket(0); // OK
  OrderSelect(0);            // return value of 'OrderSelect' should be checked
}
 
Good afternoon, after update the following bug occurred [MT4 (1280) / MetaEditor (2375)]:

Template function overload in class body, template parameter overrides correct function version.
(For global functions - allowing overloading works ok.)
template<typename T>
class template_class{};

class X
{  
public:

   template<typename T>
   void f(const template_class<T>&) 
   {
      Print("T");
      
      T * obj = NULL;
   }
   
   void f(const template_class<string>&) 
   {
      Print("string");
   }
   
   void call()
   {
      template_class<string> ts;
      
      f(ts);    //Вызывает версию Т, а должен string.
   }
};

void OnStart()
{
   X x;
   
   x.call();
}
Reason: