I need to stream tick for all pairs from my EA to my external python application via zmq. It currently sends string data but it's uses more CPU than I need it to so I'm considering sending the data in the binary format.
The data being sent is mostly double values, with some strings. It seems the string parts can be converted to char array with StringToCharArray but there's no double equivalent of this.
An example of data being transmitted is as follows:
A double in MQL4 is 8 bytes and a uchar is 1 byte, so I'm wondering if it would be possible to convert a double value to 8 uchars, and put all above string and double values into a single raw uchars array that I can send.
- How can make "Lot" parameter in list array
- Convert String Non-Numeric String to double
- Convert MQL double to IEEE-754 binary or hexadecimal string or byte array
sjl9203:
I'd also like to learn about that, but I'd convert the double to string, then to char array.
I need to stream tick for all pairs from my EA to my external python application via zmq. It currently sends string data but it's uses more CPU than I need it to so I'm considering sending the data in the binary format.
The data being sent is mostly double values, with some strings. It seems the string parts can be converted to char array with StringToCharArray but there's no double equivalent of this.
An example of data being transmitted is as follows:
A double in MQL4 is 8 bytes and a uchar is 1 byte, so I'm wondering if it would be possible to convert a double value to 8 uchars, and put all above string and double values into a single raw uchars array that I can send.
Nelson Wanyama:
I'd also like to learn about that, but I'd convert the double to string, then to char array.
I'd also like to learn about that, but I'd convert the double to string, then to char array.
I found the answer: Use union.
If you convert it to string then to char arr then you'll unnecessarily increase the number of bytes. Easy to do but not optimal, at least for my purpose.
union UDblBuffer { uchar buffer[24]; double doubles[3]; }; UDblBuffer u; u.doubles[0]=1; u.doubles[1]=2; u.doubles[2]=3;
Yes, union, like so maybe.
sjl9203:
Use a struct to store your double values and then convert the struct to byte array with StructToCharArray.
I need to stream tick for all pairs from my EA to my external python application via zmq. It currently sends string data but it's uses more CPU than I need it to so I'm considering sending the data in the binary format.
The data being sent is mostly double values, with some strings. It seems the string parts can be converted to char array with StringToCharArray but there's no double equivalent of this.
An example of data being transmitted is as follows:
A double in MQL4 is 8 bytes and a uchar is 1 byte, so I'm wondering if it would be possible to convert a double value to 8 uchars, and put all above string and double values into a single raw uchars array that I can send.
Laszlo Tormasi:
Use a struct to store your double values and then convert the struct to byte array with StructToCharArray.
This is the best answer for my case. Thank you.
Use a struct to store your double values and then convert the struct to byte array with StructToCharArray.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register