ENUM_COPY_TICKS values different from reference

 

Hello,

these days I began downloading ticks with CopyTicksRange. I am just getting tick flags that I can't interpret. This is from Reference:
flags_reference


When I observe every tick flag value in debugger I get this:
flags_debugger


But when I download the ticks and print their values in the log, I am mainly getting values of 12 and 14:
flags_print_log


Not sure what to make of it. Or because they are "bit flags" they might be combined in a manner that I don't understand.
It is not critical for what I am going to do, but I am guessing that the reference has to be updated, or is it broker specific?

However. If you require the EA code I would be curious if you had the same result:

ENUM_TIMEFRAMES   m_time_frame = PERIOD_M5;
ulong             m_time_current_msc = 0;
ulong             m_time_tick_dump_start_msc = 0;
ulong             m_time_tick_dump_stop_msc = 0;
int               m_ticks_copied = 0;
MqlTick           m_tick_dump_array[];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int   OnInit(void)
  {
   m_time_current_msc = ulong(1000 * double(TimeCurrent()));
   m_time_tick_dump_start_msc = m_time_current_msc;
   m_time_tick_dump_stop_msc = m_time_tick_dump_start_msc + ulong(1000 * double(PeriodSeconds(m_time_frame)));
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick(void)
  {
   m_time_current_msc = ulong(1000 * double(TimeCurrent()));
   if(m_time_current_msc >= m_time_tick_dump_stop_msc)
     {
      m_ticks_copied = CopyTicksRange(_Symbol, m_tick_dump_array, COPY_TICKS_ALL, m_time_tick_dump_start_msc, m_time_tick_dump_stop_msc);
      m_time_tick_dump_start_msc = m_time_tick_dump_stop_msc;
      m_time_tick_dump_stop_msc = m_time_tick_dump_stop_msc + ulong(1000 * double(PeriodSeconds(m_time_frame)));
      GoThroughTickDump();
     }
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void GoThroughTickDump(void)
  {
   ENUM_COPY_TICKS copy_ticks_all = COPY_TICKS_ALL;
   ENUM_COPY_TICKS copy_ticks_ask = COPY_TICKS_ASK;
   ENUM_COPY_TICKS copy_ticks_bid = COPY_TICKS_BID;
   ENUM_COPY_TICKS copy_ticks_flags = COPY_TICKS_FLAGS;
   ENUM_COPY_TICKS copy_ticks_info = COPY_TICKS_INFO;
   ENUM_COPY_TICKS copy_ticks_last = COPY_TICKS_LAST;
   ENUM_COPY_TICKS copy_ticks_time_ms = COPY_TICKS_TIME_MS;
   ENUM_COPY_TICKS copy_ticks_trade = COPY_TICKS_TRADE;
   ENUM_COPY_TICKS copy_ticks_vertical = COPY_TICKS_VERTICAL;
   ENUM_COPY_TICKS copy_ticks_volume = COPY_TICKS_VOLUME;

   for(int i = 0; i < m_ticks_copied; i++)
     {
      string str_tick_line = "";
      str_tick_line += "Dump Tick No.: " + (string)i;
      str_tick_line += "; MSC: " + (string)m_tick_dump_array[i].time_msc;
      str_tick_line += "; TIME: " + (string)m_tick_dump_array[i].time;
      str_tick_line += "; BID: " + (string)m_tick_dump_array[i].bid;
      str_tick_line += "; ASK: " + (string)m_tick_dump_array[i].ask;
      str_tick_line += "; FLAGS: " + (string)m_tick_dump_array[i].flags;
      str_tick_line += "; LAST: " + (string)m_tick_dump_array[i].last;
      str_tick_line += "; VOL: " + (string)m_tick_dump_array[i].volume;
      str_tick_line += "; VOLREAL: " + (string)m_tick_dump_array[i].volume_real;
      Print(str_tick_line);
     }
  }

If you are aware of an article or forum topic that didn't catch my eye, please share, I found a lot of topics about CopyTicks in the search but haven't seen my topic browsing through the first two pages. Thanks in advance.

 

As a supplement to your information, I get the following ...

#define PrintTickFlag( _flag ) PrintFormat( "%+24s = %8d = %8X", #_flag, _flag, _flag )

void OnStart() {
   PrintTickFlag( TICK_FLAG_BID    );
   PrintTickFlag( TICK_FLAG_ASK    );
   PrintTickFlag( TICK_FLAG_LAST   );
   PrintTickFlag( TICK_FLAG_VOLUME );
   PrintTickFlag( TICK_FLAG_BUY    );
   PrintTickFlag( TICK_FLAG_SELL   );

   PrintTickFlag( COPY_TICKS_INFO     );
   PrintTickFlag( COPY_TICKS_TRADE    );
   PrintTickFlag( COPY_TICKS_ALL      );
   PrintTickFlag( COPY_TICKS_VERTICAL );
   PrintTickFlag( COPY_TICKS_TIME_MS  );
   PrintTickFlag( COPY_TICKS_BID      );
   PrintTickFlag( COPY_TICKS_ASK      );
   PrintTickFlag( COPY_TICKS_LAST     );
   PrintTickFlag( COPY_TICKS_VOLUME   );
   PrintTickFlag( COPY_TICKS_FLAGS    );
};
      TICK_FLAG_BID =        2 =        2
      TICK_FLAG_ASK =        4 =        4
     TICK_FLAG_LAST =        8 =        8
   TICK_FLAG_VOLUME =       16 =       10
      TICK_FLAG_BUY =       32 =       20
     TICK_FLAG_SELL =       64 =       40

    COPY_TICKS_INFO =        1 =        1
   COPY_TICKS_TRADE =        2 =        2
     COPY_TICKS_ALL =        3 =        3
COPY_TICKS_VERTICAL =    32768 =     8000
 COPY_TICKS_TIME_MS =    65536 =    10000
     COPY_TICKS_BID =   131072 =    20000
     COPY_TICKS_ASK =   262144 =    40000
    COPY_TICKS_LAST =   524288 =    80000
  COPY_TICKS_VOLUME =  1048576 =   100000
   COPY_TICKS_FLAGS =  2097152 =   200000
 

You are mixing different things.

1. Your code is using the raw mql CopyTicksRange(). While your documentation link is for the matrix/vector function CopyTicksRange() which is different.

2. Your are mixing the COPY_TICKS_xxx flags and the TICK_FLAG_xxx.

Documentation on MQL5: Timeseries and Indicators Access / CopyTicksRange
Documentation on MQL5: Timeseries and Indicators Access / CopyTicksRange
  • www.mql5.com
CopyTicksRange - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
@Alain Verleyen #:

You are mixing different things.

1. Your code is using the raw mql CopyTicksRange(). While your documentation link is for the matrix/vector function CopyTicksRange() which is different.

2. Your are mixing the COPY_TICKS_xxx flags and the TICK_FLAG_xxx.

That may be the case, but the documentation is still incorrect ... Documentation on MQL5: Matrix and Vector Methods / Initialization / CopyTicks

Below is a copy of the online version and the values are incorrect as demonstrated in my code above.

ENUM_COPY_TICKS

The ENUM_COPY_TICKS enumeration contains the flags to specify the type of data to be passed to the matrix or array. The flag combination allows getting several series from the history in one request. The order of the rows in the matrix will correspond to the order of the values in the ENUM_COPY_TICKS enumeration. In other words, the row with High data will always be higher in the matrix than the row with Low data.

ID

Value

Description

COPY_TICKS_TIME_MS

1

Tick time in milliseconds

COPY_TICKS_BID

2

Bid price

COPY_TICKS_ASK

4

Ask price

COPY_TICKS_LAST

8

Last price (last deal price)

COPY_TICKS_VOLUME

16

Last price Volume

COPY_TICKS_FLAGS

32

Tick Flags

Data arrangement

 

 

COPY_TICKS_VERTICAL

32768

Ticks are copied into the matrix along the vertical axis. The received ticks will be arranged vertically in the matrix, i.e., the oldest ticks will be in the first row, while the most recent ticks will be in the last matrix row.

 With default copying, ticks are added into a matrix along the horizontal axis.

 The flag is only applicable when copying to a matrix.

Documentation on MQL5: Matrix and Vector Methods / Initialization / CopyTicks
Documentation on MQL5: Matrix and Vector Methods / Initialization / CopyTicks
  • www.mql5.com
CopyTicks - Initialization - Matrix and Vector Methods - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Fernando Carreiro #:

That may be the case, but the documentation is still incorrect ... Documentation on MQL5: Matrix and Vector Methods / Initialization / CopyTicks

Below is a copy of the online version and the values are incorrect as demonstrated in my code above.

ENUM_COPY_TICKS

The ENUM_COPY_TICKS enumeration contains the flags to specify the type of data to be passed to the matrix or array. The flag combination allows getting several series from the history in one request. The order of the rows in the matrix will correspond to the order of the values in the ENUM_COPY_TICKS enumeration. In other words, the row with High data will always be higher in the matrix than the row with Low data.

ID

Value

Description

COPY_TICKS_TIME_MS

1

Tick time in milliseconds

COPY_TICKS_BID

2

Bid price

COPY_TICKS_ASK

4

Ask price

COPY_TICKS_LAST

8

Last price (last deal price)

COPY_TICKS_VOLUME

16

Last price Volume

COPY_TICKS_FLAGS

32

Tick Flags

Data arrangement

 

 

COPY_TICKS_VERTICAL

32768

Ticks are copied into the matrix along the vertical axis. The received ticks will be arranged vertically in the matrix, i.e., the oldest ticks will be in the first row, while the most recent ticks will be in the last matrix row.

 With default copying, ticks are added into a matrix along the horizontal axis.

 The flag is only applicable when copying to a matrix.

That's right.

However I don't see why the values matter. They should not be used.

 
Alain Verleyen #: That's right. However I don't see why the values matter. They should not be used.

True, but sometimes, knowing the values helps understand how they work. Documenting the incorrect values could lead to misunderstandings.

 
Fernando Carreiro #:

True, but sometimes, knowing the values helps understand how they work. Documenting the incorrect values could lead to misunderstandings.

Of course, I added it to the ad-hoc topic.
 
Thanks to all for your contributions.
 
Alain Verleyen #:

You are mixing different things.

1. Your code is using the raw mql CopyTicksRange(). While your documentation link is for the matrix/vector function CopyTicksRange() which is different.

2. Your are mixing the COPY_TICKS_xxx flags and the TICK_FLAG_xxx.

Oh yes, that is another thing i noticed. Each time I press F1 while cursor is on the normal CopyTicksRange function, I get the reference article for the vector/matrix function.