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

 

Sorry."TRADE_EVENT_POSITION_OPEN =0x1" x1 is the first bit of the event list???? I mean, in that enum event part, you can have every bit available like that?


Please let me know.

 

There are two types of brokers, which translate the US/European time. Due to this, in particular, the rollover time is shifted.

The broker type can be determined automatically.

// Вычисление типа брокера (USA/Europe).

bool IsEuropeBroker()
{
  MqlCalendarValue Value[1];
  
  CalendarValueHistoryByEvent(840030016, Value, D'2022.11.03', D'2022.11.05');
  
  return(Value[0].time == ChartNewsTime(Value[0].time)); // https://www.mql5.com/ru/forum/357793/page5#comment_44225999
}

void OnStart()
{
  Print(AccountInfoString(ACCOUNT_SERVER) + " - " + (IsEuropeBroker() ? "Europe" : "USA"));
}


Launch results on some brokers.

RannForex-Server - Europe
MetaQuotes-Demo - Europe
FXOpen-MT5 - USA
Alpari-MT5 - Europe
Tickmill-Live - USA
ICMarketsSC-MT5-2 - USA
Darwinex-Live - USA
 

Hello!

I don't know if I'm asking my question in the right thread or not...

The essence of the question - I made a panel with buttons, input fields and labels based on AppDialog from the standard library.

The customer has complained that when zooming in through Windows personalisation settings,

only fonts are scaled up on the panel, but the controls themselves are not scaled, as a result, the inscriptions go beyond the control borders.

How can I solve the problem so that not only fonts but also the sizes of panel elements and the panel itself are scaled?

Of course, I have a small reserve and I can slightly increase the size of the elements, then if I increase the screen parameters to 125%

everything will fit, but if I increase it to 150%, then nothing will fit.

So I want to solve the problem radically, so that the elements of the panel and the panel itself also increase in proportion to the scale. How to do it?

I understand that it is necessary to somehow, probably through WIN IP to get this scale figure - 100%, or 125% or 150%. The question is how to implement it in the EA code?



P.S. For clarification. The programme uses the standard MQL5 library, but it is written in MQL4.


I am grateful in advance to everyone who will respond....

 
Vitaliy Davydov standard library.

The customer complained that when zooming in through Windows personalisation settings,

only fonts are scaled up on the panel, but the controls themselves are not scaled up, as a result the inscriptions go beyond the control borders.

How can I solve the problem so that not only fonts, but also the sizes of panel elements and the panel itself are scaled?

Of course, I have a small reserve and I can slightly increase the size of elements, then when I increase the screen parameters to 125%.

everything will fit, but if I increase it to 150%, then nothing will fit.

So I want to solve the problem radically, so that the elements of the panel and the panel itself also increase in proportion to the scale. How to do it?

I understand that it is necessary to somehow, probably through WIN IP to get this scale figure - 100%, or 125% or 150%. The question is how to implement it in the EA code?



P.S. For clarification. The programme uses the standard MQL5 library, but it is written in MQL4.


I am grateful in advance to everyone who will respond....

Try to define the text size before creating objects using TextSetFont() and TextGetSize()

 
Alexey Viktorov #:

Try to define the size of text through TextSetFont() and TextGetSize() before creating objects

TextGetSize() helped, thanks.
 

I managed to assemble a bicycle construction, which I put into practice. I'll try to tell you briefly.

There is such a work with a database.

// Элемент БД.
class DATA
{
private:
  static int Count;
  
public:
  int Num;
  
  DATA() : Num(DATA::Count++) {}
};

static int DATA::Count = 0;

#define  SIZE 5

// БД.
class A
{
private:  
  static DATA DataArray[SIZE]; // База данных.
  static DATA* Data;           // Выбранный элемент БД.
  
public:
  static void Set( const int Num ) // Выбор элемента и перемешение элементов БД.
  {
    A::Data = &A::DataArray[Num % SIZE];
    
    ::ArrayReverse(A::DataArray); // Перемешение элементов БД.
  }
  
  static int Get() { return(A::Data.Num); } // Получение значения элемента.
};

static DATA A::DataArray[5];
static DATA* A::Data;

Every time an item is selected from the database, its elements are mixed. Artificially, but it is necessary to explain.


And here we need to do the following.

void OnStart()
{  
  A::Set(2);
  Print(A::Get()); // Какое-то значение Value.

  // Перемешиваем БД.
  MathSrand((int)TimeLocal());
  for (int i = MathRand(); i >= 0; i--)
    A::Set(i);
    
  Print(A::Get()); // Что-то образовалось.  
  
  Print(A::Get()); // Здесь хочется получить Value.
}

Explanation of the code: you select an element for the first time, then you do it many times. And we need to get the element that was selected the first time.


We need to somehow add a DB-class so that we can do this. At the same time it is impossible to give access to the pointer to the element (DATA*).

 
fxsaber #:

Code explanation: selected an element for the first time, then did it many times. And we need to get the item that was selected the first time.

We need to somehow add a database class to make it possible to do this. At the same time it is impossible to give access to the pointer to the element (DATA*).

The solution is to add a few lines to the DB-class.

// БД.
class A
{
// Тело класса до решения задачи.
// .....

// В БД-класс дописываются эти строки.
public:
  class POINTER
  {
  private:
    DATA* Data;
    
  public:
    POINTER() : Data(A::Data) {}
    
    void Set() const { A::Data = this.Data; }
  };  
};


After that OnStart looks like this.

void OnStart()
{  
  A::Set(2);
  Print(A::Get()); // Какое-то значение Value.

  A::POINTER Pointer; // Запоминание элемента без доступа к нему.

  // Перемешиваем БД.
  MathSrand((int)TimeLocal());
  for (int i = MathRand(); i >= 0; i--)
    A::Set(i);
    
  Print(A::Get()); // Что-то образовалось.  
  
  Pointer.Set(); // Запомненный элемент становится выбранным в БД.
  Print(A::Get()); // Здесь хочется получить Value.
}

It is possible to do this because the class defined in the body of the main class has access to the hidden static members of this main class.

 
fxsaber #:

class defined in the body of a main class has access to the hidden static members of that main class.

I hope this is not a flaw of the MQL language, but a convenient standard (feature).

class A
{
  private: static int Num;
    
  public: struct B { static int Get() { return(A::Num); } };
};

static int A::Num = 5;

void OnStart()
{
  Print(A::B::Get()); // 5
}
 
fxsaber #:

I hope this is not a flaw in the MQL language, but a convenient standard (feature).

By analogy with C++. A nested class is a friend for the including class. It is written in the standard there. It would be good to write it in the help here too)
 

English (original): I would like to make an MQL language feature request. If this is not the correct thread, please let me know. The original request is on the English forum ...

Russian (Google translate): I would like to make an MQL language feature request. If this is not the correct thread, please let me know. The original request is on the English forum ...