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

 
Andrey Dik #:

What does that mean? Can you expand on that?

Andrew, this is the wrong thread. You need to find out in another thread.

 
Artyom Trishkin #:

Andrew, this is the wrong thread. You should find out such things in another thread.

Why not the wrong one? We are talking about mql5 peculiarities, so it is the right one.
 
Andrey Dik #:

Anybody have any thoughts?

Maybe try this?

 // --- если обычное тестирование без оптимизации и визуализации
bool IsUsualTester = (MQLInfoInteger(MQL_TESTER) && !MQLInfoInteger(MQL_OPTIMIZATION) && !MQLInfoInteger(MQL_VISUAL_MODE));

 // --- если не тестирование и не оптимизация, значит видимый график
bool IsVisibleChart = (!IsUsualTester && !MQLInfoInteger(MQL_OPTIMIZATION));
 
Andrey Dik #:

Anybody have any thoughts?

Andrei, please look at the article (Section 2. Modes in MQL5), it may help )).

Программируем режимы работы советника с помощью ООП
Программируем режимы работы советника с помощью ООП
  • www.mql5.com
В статье рассматривается идея мультирежимного программирования торговых роботов на MQL5. Используется объектно-ориентированный подход для реализации каждого из режимов. Приводится пример иерархии режимных классов и пример классов для тестирования. Предполагается, что мультирежимное программирование торговых роботов полностью учитывает особенности каждого режима работы MQL5-советника. Для идентификации режимов создаются функции и перечисление.
 
Andrey Dik #:

What does that mean? Can you expand on that?

It may seem to some that this is not the right branch, but it's simple:

if ChartID gives reasonable - it means that there is a place for it in GUI and it works in it you can draw, so either VISUAL_TESTER or just work in terminal.

If ChartGetInteger(ChartID(),CHART_WINDOW_HANDLE) returns invalid handle, then we are inside the tester. (Or maybe MQ VPS - I haven't touched it, I don't know).

 
Maxim Kuznetsov #:

This may seem like the wrong thread to some, but it's simple:

if ChartID gives reasonable - it means there is a place for it in GUI and it works in it you can draw, so either VISUAL_TESTER or just work in terminal.

If ChartGetInteger(ChartID(),CHART_WINDOW_HANDLE) returns invalid handle, then we are inside the tester. (Or maybe MQ VPS - I haven't touched it, I don't know).

The tester also has a chart, albeit a virtual one, so this is a dead end.

 
Andrey Dik #:

The tester also has a chart, albeit a virtual one, so it's a dead end path

I answered you in that thread (the questions are the same).

 
Andrey Dik #:

Anybody have any thoughts?

//true если работа на чарте или в визуальном тестировании, в остальных случаях false
bool CheckMode ()
{
  if(MQLInfoInteger(MQL_DEBUG)        ||
     MQLInfoInteger(MQL_PROFILER)     ||
    (MQLInfoInteger(MQL_TESTER) && ! MQLInfoInteger(MQL_VISUAL_MODE)) ||
     MQLInfoInteger(MQL_OPTIMIZATION) ||
     MQLInfoInteger(MQL_FRAME_MODE)) return false;

  return true;
}
 
Artyom Trishkin #:

I answered you in that thread (same question).

Well, you have all the rights. Delete where it's off-topic... What's the problem?

 
Andrey Dik #:

What does that mean? Can you expand on that?

I had time to check: yes, the trick failed, ChartID()=12345 for visual and non-visual...(such a constant ChartID of the tester).

But ChartGetInteger(ChartID(),CHART_WIDTH_IN_PIXELS) gives an honest -1 if there is no screen. You can use it to determine the physics - whether there is a place to output something or not. Because there are a lot of flags, and we don't know what is there on VPS at all