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

 
Nikolai Semko #:

means that in combat mode you should turn off all graphical nonsense without minimisation. Let the graphics be frozen if the window remains visible but not active.
And it is easier and better, as it seems to me, to automatically turn off and remove all graphics when the mouse is inactive, e.g. for 1 minute. As soon as the mouse is active - the graphics resume.

This is not good at all. Here you look at the graph for 2 minutes, and the graph died a minute ago. What is the need for it then?

 
Vitaly Muzichenko #:

This is not good at all. You look at the graph for two minutes and the graph died a minute ago. Then what is it for?

Well, of course, you need an "Auto-hide" switch for that mode.

 
Nikolai Semko #:

means that in combat mode all graphical overheads must be switched off without minimisation.

The kanvas of the chart itself is drawn without minimisation. Experienced way was found the mode of Terminal operation, when VPS is loaded minimally.

 

I hope I'm writing in the right subject.

1. Running a test on several pairs at the same time, multi-currency

Question: How do I get the result for each pair?

2We conduct optimization for several pairs at the same time

Question: how to get a result for each pair?

---

Some time ago, about 3 years ago, they promised to include this in the tester, but so far there is nothing. Or am I not finding it?

 

There is a legal way to stop Market Advisor or Signal Service working, for example. Let's say there is no access to them for one reason or another - VPS.

The method will work if there is a restriction on the trading server. You just need to fill everything with pending orders, but carefully, otherwise it will be impossible to close the open positions.


Perhaps someone will write such an emergency Market Product...

 

MQL5. MESSAGE BOX duplicates messages in the "Experts" log. Please advise how to disable it. ***

Thank you!

 

Forum on trading, automated trading systems and trading strategies testing

Features of mql5 language, subtleties and tricks

fxsaber, 2017.09.22 20:43

POSITION_TIME_UPDATE is only relevant to changing the lot of a position. For example, a partial closing of a position on any type of account or a netting add-on.

Changes in SL/TP levels do not affect POSITION_TIME_UPDATE.

Paraphrasing, POSITION_TIME_UPDATE is only affected by modifications reflected in the Trade History - trades. SL/TP-levels do not apply to such modifications, so they are not affected.

There may be situations where POSITION_TIME_UPDATE_MSC == POSITION_TIME_UPDATE despite changes in lot size.

 
 
fxsaber #:
Handy sorting an array of structures


Application


Result

Hi and thanks for sharing!

This would be perfect if it worked. However, when pasted into a .mq5 script and executed unfortunately your code throws the following error(s):

  • template declarations are not allowed in local classes ArraySortStruct.mq5 87 4
  • (after slightly changing your code): template declarations are allowed on global, namespace or class scope only ArraySortStruct.mq5 90 4 )

Could you please fix this? For you it's probably easy whereas I wouldn't know where to start :-)

 
Bodolino #:

Hi and thanks for sharing!

This would be perfect if it worked. However, when pasted into a .mq5 script and executed unfortunately your code throws the following error(s):

  • template declarations are not allowed in local classes ArraySortStruct.mq5 87 4
  • (after slightly changing your code): template declarations are allowed on global, namespace or class scope only ArraySortStruct.mq5 90 4 )

Could you please fix this? For you it's probably easy whereas I wouldn't know where to start :-)

Not sure how to keep the functionality (subfield and method) and usability. Maybe this one will suit your needs.

// Сортировка массива структур и указателей на объекты 
по полю.
#define  ArraySortStruct_Define(TYPE, FIELD)                                      \
namespace TYPE##FIELD                                                            \
{                                                                                \
  class SORT                                                                     \
  {                                                                              \
  private:                                                                       \
    template <typename T>                                                        \
    static void Swap( T &Array[], const int i, const int j )                     \
    {                                                                            \
      const T Temp = Array[i];                                                   \
                                                                                 \
      Array[i] = Array[j];                                                       \
      Array[j] = Temp;                                                           \
                                                                                 \
      return;                                                                    \
    }                                                                            \
                                                                                 \
    template <typename T>                                                        \
    static int Partition( T &Array[], const int Start, const int End )           \
    {                                                                            \
      int Marker = Start;                                                        \
                                                                                 \
      for (int i = Start; i <= End; i++)                                         \
        if (Array[i].##FIELD <= Array[End].##FIELD)                              \
        {                                                                        \
          SORT::Swap(Array, i, Marker);                                          \
                                                                                 \
          Marker++;                                                              \
        }                                                                        \
                                                                                 \
       return(Marker - 1);                                                       \
    }                                                                            \
                                                                                 \
    template <typename T>                                                        \
    static void QuickSort( T &Array[], const int Start, const int End )          \
    {                                                                            \
      if (Start < End)                                                           \
      {                                                                          \
        const int Pivot = Partition(Array, Start, End);                          \
                                                                                 \
        SORT::QuickSort(Array, Start, Pivot - 1);                                \
        SORT::QuickSort(Array, Pivot + 1, End);                                  \
      }                                                                          \
                                                                                 \
      return;                                                                    \
    }                                                                            \
                                                                                 \
  public:                                                                        \
    template <typename T>                                                        \
    static void Sort( T &Array[], int Count = WHOLE_ARRAY, const int Start = 0 ) \
    {                                                                            \
      if (Count == WHOLE_ARRAY)                                                  \
        Count = ::ArraySize(Array);                                              \
                                                                                 \
      SORT::QuickSort(Array, Start, Start + Count - 1);                          \
                                                                                 \
      return;                                                                    \
    }                                                                            \
  };                                                                             \
}

#define  ArraySortStruct(TYPE, ARRAY, FIELD) TYPE##FIELD::SORT::Sort(ARRAY)


Application.

ArraySortStruct_Define(MqlRates, open)
ArraySortStruct_Define(MqlRates, high)
ArraySortStruct_Define(MqlRates, time)

void OnStart()
{
  MqlRates Rates[];
  
  CopyRates(_Symbol, PERIOD_CURRENT, 0, 5, Rates); // Взяли бары
  
  Print("\nБары без сортировки - как получили.");
  ArrayPrint(Rates);
  
  Print("\nСортируем по open-цене.");
  ArraySortStruct(MqlRates, Rates, open);
  ArrayPrint(Rates);

  Print("\nСортируем по high-цене.");
  ArraySortStruct(MqlRates, Rates, high);
  ArrayPrint(Rates);

  Print("\nСортируем по времени.");
  ArraySortStruct(MqlRates, Rates, time);
  ArrayPrint(Rates);
}