Object to byte array

 

Hello everyone.

I am trying to convert an MqlRates object to byte array but the only way i found so far is to iterate through the items convert each items ohlc prices to string and then to bite array. Is there a more efficient way of doing this. My goal is to send an MqlRates object through a socket to be processed as a dataframe by a python script on the other side.

I realize that the obvious solution is to use python from the beginning but i am on Linux and I also need the onTimer function.

Thank you in advance.

 

Use an union.

union RatesToBytes
  {
   char     bytes[sizeof(MqlRates)];
   MqlRates rates;
  };
 
Alain Verleyen:

Use an union.


Ahhh yes, thank you. I had completely forgotten the existence of those. I works perfectly

Reason: