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

 

Here is the result from PrintEnum<ENUM_TIMEFRAMES>();

output:

 enum ENUM_TIMEFRAMES
   {
    PERIOD_CURRENT = 0,
    PERIOD_M1 = 1,
    PERIOD_M2 = 2,
    PERIOD_M3 = 3,
    PERIOD_M4 = 4,
    PERIOD_M5 = 5,
    PERIOD_M6 = 6,
    PERIOD_M10 = 10,
    PERIOD_M12 = 12,
    PERIOD_M15 = 15,
    PERIOD_M20 = 20,
    PERIOD_M30 = 30,
    PERIOD_H1 = 16385,
    PERIOD_H2 = 16386,
    PERIOD_H3 = 16387,
    PERIOD_H4 = 16388,
    PERIOD_H6 = 16390,
    PERIOD_H8 = 16392,
    PERIOD_H12 = 16396,
    PERIOD_D1 = 16408,
    PERIOD_W1 = 32769,
    PERIOD_MN1 = 49153,
   };
 

Forum on trading, automated trading systems and testing trading strategies

Peculiarities of mql5 language, subtleties and techniques of work

amrali, 2025.02.14 05:37

#define  PROPERTIES1(function, enumtype) \
   for(int i=-2; i<USHORT_MAX+1000; ++i) \
     { \
      enumtype prop_id = (enumtype)i; \
      if(StringFind(EnumToString(prop_id),"::")<0) \
         Print(EnumToString(prop_id),"=",function(prop_id)); \
     }

It is much more expensive than analysing _LastError.


Unfortunately, lost the universality by introducing macros with different number of input parameters. There may be problems with non-standard properties.

 
fxsaber #:

It is much more expensive than analysing _LastError.


Unfortunately, lost the universality by introducing macros with different number of input parameters. There may be problems with non-standard properties.

These are one-time helpers not a time-critical code. it does not make any difference for the user if it took 10 nansosec vs 100 nanosec :)

I don't give a shit for my cpu usage / electricity bill.
 
amrali #:

These are one-time helpers, not time-critical code. It makes no difference to the user whether it took 10 nanoseconds vs 100 nanoseconds :)

Why make it sub-optimal?

 
fxsaber #:



It is already documented. Do not mix history pools from different sources.



 
amrali #:

It's already documented. Don't mix pools of history from different sources.

Just trying to use your function.

// Пробуем распечатать все балансовые сделки.
void OnStart()
{
  if (HistorySelect(0, INT_MAX))
    for (uint i = HistoryDealsTotal(); (bool)i--;)
    {
      const ulong Ticket = HistoryDealGetTicket(i);
      
      if (HistoryDealGetInteger(Ticket, DEAL_TYPE) == DEAL_TYPE_BALANCE)
        PrintDeal(Ticket);
    }
}

In short, I pointed out an architectural error and gave an example of its manifestation. The error will not disappear from the results of the discussion.

 
fxsaber #:

Just trying to use your function.

In short, I pointed out an architectural error and gave an example of its manifestation. The error will not disappear from the results of the discussion.

Then remember to rename my function to:
SelectPrintDeal() to avoid the mix.
 
amrali #:
Then remember to rename my function to:
SelectPrintDeal() to avoid confusion.

Please, if you make mistakes in code in this thread, correct them instead of exercising wit.

 
fxsaber #:

Please, if you make mistakes in code in this thread, correct them instead of exercising wit.

My friend if you find the code is not fitting your needs then you can skip it, this is up to you. 

There are no mistakes in my code, the mistakes are actually in the way to you try to fit the function into a situation that is actually documented on the platform documentations page.

FYI, it is the job of forum's admin to decide for users what to post or not on this thread.
 
amrali #:
There are no errors in my code

  1. An indication of an error.
  2. Example of use.

Readers are kindly requested to comment.