Convert it base10 then, but you will have to write your own conversion function for it. There are many such implementations on the web.
You can also convert to base16 as the hexadecimal representation of an integer.
Both methods will work.
Double to Integer, I'm deeply sorry:
IleZerPoPrz=Digits();
CenaAskStStr=DoubleToString(Tab2_CenaAsk[LiczKonw-1],IleZerPoPrz);
DlCenaAskStStr=StringLen(CenaAskStStr);
CenaAskStStrBK="";
for(PozStr=0; PozStr<DlCenaAskStStr; PozStr++){
ZnakStr=StringSubstr(CenaAskStStr,PozStr,1);
if(ZnakStr==".") continue;
CenaAskStStrBK=CenaAskStStrBK+ZnakStr;}
CenaAskStLong=StringToInteger(CenaAskStStrBK);
String to Integer, from MQL5 Reference:
long StringToInteger(string value);
Great. Before the dot. And probably any character.
Here is what I am doing, although I use a custom "Symbol()" function which does some magic to the string....
#define EA_GLOBAL_MAGICID 0x00A02468 namespace fw_cfg { const static union str_ulong_union { uchar s[8]; ulong id; str_ulong_union(const string _str) { StringToCharArray(_str, s); id = (id << 16) + (PeriodSeconds()) + EA_GLOBAL_MAGICID + (AccountInfoInteger(ACCOUNT_LOGIN)) + id; for(int cnt = NULL; cnt < 8; cnt++) { s[cnt] = (s[cnt] % 62) + 64; } } string str() const { return((CharArrayToString(s, 0, 8))); } } exp_magic_UID(Symbol()); }; // END Namespace #define SYMBOL_MAGIC_ID fw_cfg::exp_magic_UID.id
This should give you a unique MAGIC ID for each symbol, differentiated by timeframe and for every account. This way you can use the magic ID to identify positions when stored in a file or sql database.
As far as I was able to test this, it was unique and had no overlappings within my DB.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to convert symbol name (string) ?to Integer so for each symbol its a unique int and it can be encoded and decoded
base64 is too long and may contain string also, so any other method please inform