MQL4 StringToDouble always returns zero

MQL4 StringToDouble always returns zero

Manage alerts

Loading saved threads...

Fahad · External communityPost link
External question — Stack Overflow Stack Exchange Author: Fahad Original post: https://stackoverflow.com/questions/72944645 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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?
Quote
Report
Fahad · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Fahad Original post: https://stackoverflow.com/a/73029518 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: Fahad Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/a/73029518 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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

Cancel quote

Checking account access…