Incorrect Expert ID on negative Magic Number MT5

 

Hello, 

this position is sent with magic number -1.

When i'm hover the position, MT5 shows me this ID, but the position have Magic -1.

It's a MT5 bug?

Thanks so much


 
Metrica Trading Solutions:

Hello, 

this position is sent with magic number -1.

When i'm hover the position, MT5 shows me this ID, but the position have Magic -1.

It's a MT5 bug?

Thanks so much


Where did you see you can use a negative magic number ?

A magic number is of ulong type.

 
Alain Verleyen:

Where did you see you can use a negative magic number ?

A magic number is of ulong type.

Thanks for your reply.

I have developed some function and EAs that placed order via Negative Magic Number, and it works fine for many years now.

When i call PositionGetInteger( POSITION_MAGIC ) it will return correctly -1 if i use -1 in the MqlTradeRequest struct.

Now i would like to know, the possibility that i have now to place order with Negative Magic Number will remain or will be removed?

Thanks  

 

Please tell me if new release will be released because i need to update all the EAs.

Thanks

 
Metrica Trading Solutions:

Thanks for your reply.

I have developed some function and EAs that placed order via Negative Magic Number, and it works fine for many years now.

When i call PositionGetInteger( POSITION_MAGIC ) it will return correctly -1 if i use -1 in the MqlTradeRequest struct.

Now i would like to know, the possibility that i have now to place order with Negative Magic Number will remain or will be removed?

Thanks  

It works because a long or a ulong have to same bits representation but is not interpreted the same, -1 stored in a ulong is interpreted as 18446744073709551615.

If it was displayed as -1 in previous build it was a bug and it's now fixed.

 
Alain Verleyen:

It works because a long or a ulong have to same bits representation but is not interpreted the same, -1 stored in a ulong is interpreted as 18446744073709551615.

If it was displayed as -1 in previous build it was a bug and it's now fixed.

Ok Thanks, so it will works because PositionGetInteger casts a ulong in long. But the real magic will be always in This case (-1) 18446744073709551615 because in terminal it will displayed as ulong. 
So i Don’t need to update my libraries because PositionGetInteger(POSITION_MAGIC) will always return a long type. It’s right?

 
Metrica Trading Solutions:
Ok Thanks, so it will works because PositionGetInteger casts a ulong in long. But the real magic will be always in This case (-1)  18446744073709551615 because in terminal it will displayed as ulong. 
So i Don’t need to update my libraries because PositionGetInteger(POSITION_MAGIC) will always return a long type. It’s right?

Most probably yes. I can't be sure as I have no idea about your code.
 
Alain Verleyen #:

Where did you see you can use a negative magic number ?

A magic number is of ulong type.

Maybe someone needs to fix it in here too:

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
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Order Properties - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5