The function StringToDouble
always returns zero on passing a variable string.
Let me demonstrate ...
This is what I have so far.
string balance = "12.50USD";
// lets extract the double only from the string
int x = StringReplace(balance,"USD",""); // now we have a plain number
Print(balance); // "12.50"
double balance_only = StringToDouble(balance);
Print(balance_only) ; // Zero? Why?
Well according to the documentation here and here
This is supposed to work? Right? What am I missing?
I even tried to add empty strings on the sides to trick the function but still
double b = StringToDouble(StringConcatenate("",balance,""));
Print(b); // Zero , Why :(
What seems to be the problem here?
After installing and unistalling a couple of MT4 instances,
It was there all along, For some reason I was also using StringSplit function i.e
StringSplit(extracted_balance_string," ", &results[]);
Instead of
StringSplit(extracted_balance_string,StringGetCharacter(" ",0), &results[]); // the space was a special character
I missed that, my bad :D