data type of magic number

 

 Please advise what type should be correct for the magic number, ulong or long?

A. ulong is used in struct MqlTradeRequest and MQL LIB. 

struct MqlTradeRequest
  {
   ENUM_TRADE_REQUEST_ACTIONS    action;           // Trade operation type
   ulong                         magic;            // Expert Advisor ID (magic number)
   ulong                         order;            // Order ticket
   string                        symbol;           // Trade symbol
   double                        volume;           // Requested volume for a deal in lots
   double                        price;            // Price
   double                        stoplimit;        // StopLimit level of the order
   double                        sl;               // Stop Loss level of the order
   double                        tp;               // Take Profit level of the order
   ulong                         deviation;        // Maximal possible deviation from the requested price
   ENUM_ORDER_TYPE               type;             // Order type
   ENUM_ORDER_TYPE_FILLING       type_filling;     // Order execution type
   ENUM_ORDER_TYPE_TIME          type_time;        // Order execution time
   datetime                      expiration;       // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
   string                        comment;          // Order comment

  };

 

B.  long is used in following functions:

long  OrderGetInteger(
   ENUM_ORDER_PROPERTY_INTEGER  property_id        // Property identifier

   ); 

ORDER_MAGIC

ID of an Expert Advisor that has placed the order (designed to ensure that each Expert Advisor places its own unique number)

long

 

 

long  HistoryDealGetInteger(
   ulong                       ticket_number,     // Ticket
   ENUM_DEAL_PROPERTY_INTEGER  property_id        // Property identifier
   );
 

DEAL_MAGIC

Deal magic number (see ORDER_MAGIC)

long

 

long  PositionGetInteger(
   ENUM_POSITION_PROPERTY_INTEGER  property_id      // Property identifier
   );
 

 

POSITION_MAGIC

Position magic number (see ORDER_MAGIC)

long

 
kwang1:

 Please advise what type should be correct for the magic number, ulong or long?

A. ulong is used in struct MqlTradeRequest and MQL LIB. 

struct MqlTradeRequest
  {
   ENUM_TRADE_REQUEST_ACTIONS    action;           // Trade operation type
   ulong                         magic;            // Expert Advisor ID (magic number)
   ulong                         order;            // Order ticket
   string                        symbol;           // Trade symbol
   double                        volume;           // Requested volume for a deal in lots
   double                        price;            // Price
   double                        stoplimit;        // StopLimit level of the order
   double                        sl;               // Stop Loss level of the order
   double                        tp;               // Take Profit level of the order
   ulong                         deviation;        // Maximal possible deviation from the requested price
   ENUM_ORDER_TYPE               type;             // Order type
   ENUM_ORDER_TYPE_FILLING       type_filling;     // Order execution type
   ENUM_ORDER_TYPE_TIME          type_time;        // Order execution time
   datetime                      expiration;       // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
   string                        comment;          // Order comment

  };

 

B.  long is used in following functions:

ORDER_MAGIC

ID of an Expert Advisor that has placed the order (designed to ensure that each Expert Advisor places its own unique number)

long

 

 

DEAL_MAGIC

Deal magic number (see ORDER_MAGIC)

long

 

 

POSITION_MAGIC

Position magic number (see ORDER_MAGIC)

long

 

I suggest you using uint data types, it can change to ulong or long data types without any loss of information. You can read this information in mql5 reference (MQL5 Reference / Language Basics / Data Types / Typecasting).
 
kwang1:

 Please advise what type should be correct for the magic number, ulong or long?

A. ulong is used in struct MqlTradeRequest and MQL LIB. 

struct MqlTradeRequest
  {
   ENUM_TRADE_REQUEST_ACTIONS    action;           // Trade operation type
   ulong                         magic;            // Expert Advisor ID (magic number)
   ulong                         order;            // Order ticket
   string                        symbol;           // Trade symbol
   double                        volume;           // Requested volume for a deal in lots
   double                        price;            // Price
   double                        stoplimit;        // StopLimit level of the order
   double                        sl;               // Stop Loss level of the order
   double                        tp;               // Take Profit level of the order
   ulong                         deviation;        // Maximal possible deviation from the requested price
   ENUM_ORDER_TYPE               type;             // Order type
   ENUM_ORDER_TYPE_FILLING       type_filling;     // Order execution type
   ENUM_ORDER_TYPE_TIME          type_time;        // Order execution time
   datetime                      expiration;       // Order expiration time (for the orders of ORDER_TIME_SPECIFIED type)
   string                        comment;          // Order comment

  };

 

B.  long is used in following functions:

ORDER_MAGIC

ID of an Expert Advisor that has placed the order (designed to ensure that each Expert Advisor places its own unique number)

long

 

 

DEAL_MAGIC

Deal magic number (see ORDER_MAGIC)

long

 

 

POSITION_MAGIC

Position magic number (see ORDER_MAGIC)

long

 

I suggest you use uint data types, it can change to ulong or long data types without any loss of information. You can read this information in mql5 reference (MQL5 Reference / Language Basics / Data Types / Typecasting).
 
biantoro:
I suggest you use uint data types, it can change to ulong or long data types without any loss of information. You can read this information in mql5 reference (MQL5 Reference / Language Basics / Data Types / Typecasting).

but all the variables and functions regarding m_magic in source code of  MQL5 LIB are ulong. is it a bug?

 
long and ulong (int and uint, short and ushort, char and uchar) are in common the same types. signed or unsigned type applied in arithmetical operations only

Reason: