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
It doesn't really achieve anything beyond a simple typecast.
Like @Keith Watford I use it in conjunction with OBJ_EDIT boxes. But I opt for the simple typecast rather than the function call.
I am now wondering why I used StringToDouble() with CSV data .
So I made a little script to compare the speed.
2017.02.25 13:56:35.536 Bench : METHOD 1 : StringToDouble("ABCDEF") = 0.000000. Executed 10000000 times in 1078 ms.
2017.02.25 13:56:36.485 Bench : METHOD 2 : double("ABCDEF") = 0.000000. Executed 10000000 times in 953 ms.
2017.02.25 13:56:37.410 Bench : METHOD 3 : (double)"ABCDEF" = 0.000000. Executed 10000000 times in 922 ms.
2017.02.25 13:56:37.410 Bench :
2017.02.25 13:56:38.397 Bench : METHOD 1 : StringToDouble("x12345") = 0.000000. Executed 10000000 times in 984 ms.
2017.02.25 13:56:39.329 Bench : METHOD 2 : double("x12345") = 0.000000. Executed 10000000 times in 938 ms.
2017.02.25 13:56:40.273 Bench : METHOD 3 : (double)"x12345" = 0.000000. Executed 10000000 times in 937 ms.
2017.02.25 13:56:40.273 Bench :
2017.02.25 13:56:42.163 Bench : METHOD 1 : StringToDouble("123x45") = 123.000000. Executed 10000000 times in 1891 ms.
2017.02.25 13:56:43.982 Bench : METHOD 2 : double("123x45") = 123.000000. Executed 10000000 times in 1812 ms.
2017.02.25 13:56:45.746 Bench : METHOD 3 : (double)"123x45" = 123.000000. Executed 10000000 times in 1766 ms.
2017.02.25 13:56:45.746 Bench :
2017.02.25 13:56:47.923 Bench : METHOD 1 : StringToDouble(" 123") = 123.000000. Executed 10000000 times in 2187 ms.
2017.02.25 13:56:50.060 Bench : METHOD 2 : double(" 123") = 123.000000. Executed 10000000 times in 2125 ms.
2017.02.25 13:56:52.218 Bench : METHOD 3 : (double)" 123" = 123.000000. Executed 10000000 times in 2157 ms.
2017.02.25 13:56:52.218 Bench :
2017.02.25 13:56:54.228 Bench : METHOD 1 : StringToDouble(" 12 3") = 12.000000. Executed 10000000 times in 2015 ms.
2017.02.25 13:56:56.171 Bench : METHOD 2 : double(" 12 3") = 12.000000. Executed 10000000 times in 1938 ms.
2017.02.25 13:56:58.128 Bench : METHOD 3 : (double)" 12 3" = 12.000000. Executed 10000000 times in 1968 ms.
2017.02.25 13:56:58.128 Bench :
2017.02.25 13:57:01.826 Bench : METHOD 1 : StringToDouble("123.45") = 123.450000. Executed 10000000 times in 3688 ms.
2017.02.25 13:57:05.495 Bench : METHOD 2 : double("123.45") = 123.450000. Executed 10000000 times in 3672 ms.
2017.02.25 13:57:09.035 Bench : METHOD 3 : (double)"123.45" = 123.450000. Executed 10000000 times in 3547 ms.
2017.02.25 13:57:09.035 Bench :
2017.02.25 13:57:12.577 Bench : METHOD 1 : StringToDouble("123.4.5") = 123.400000. Executed 10000000 times in 3531 ms.
2017.02.25 13:57:16.122 Bench : METHOD 2 : double("123.4.5") = 123.400000. Executed 10000000 times in 3547 ms.
2017.02.25 13:57:19.626 Bench : METHOD 3 : (double)"123.4.5" = 123.400000. Executed 10000000 times in 3515 ms.
2017.02.25 13:57:19.626 Bench :
2017.02.25 13:57:21.306 Bench : METHOD 1 : StringToDouble("1,234.50") = 1.000000. Executed 10000000 times in 1672 ms.
2017.02.25 13:57:22.907 Bench : METHOD 2 : double("1,234.50") = 1.000000. Executed 10000000 times in 1610 ms.
2017.02.25 13:57:24.556 Bench : METHOD 3 : (double)"1,234.50" = 1.000000. Executed 10000000 times in 1640 ms.
Thanks all for your explanation of the function StringToDouble(). But what I need now is a similar function that returns zero whenever an alphanumeric string is entered even though the string starts with a number, and returns number for a pure number. Actually, I am working with OBJ_EDIT as a text box rather than using the property window.
2017.02.25 14:04:49.535 Bench : METHOD 1 : StringToDouble("ABCDEF") = 0.000000. Executed 10000000 times in 1110 ms.
2017.02.25 14:04:51.706 Bench : METHOD 2 : double("ABCDEF") = 0.000000. Executed 10000000 times in 2172 ms.
2017.02.25 14:04:53.556 Bench : METHOD 3 : (double)"ABCDEF" = 0.000000. Executed 10000000 times in 1843 ms.
2017.02.25 14:04:53.556 Bench :
2017.02.25 14:04:54.397 Bench : METHOD 1 : StringToDouble("x12345") = 0.000000. Executed 10000000 times in 844 ms.
2017.02.25 14:04:55.208 Bench : METHOD 2 : double("x12345") = 0.000000. Executed 10000000 times in 813 ms.
2017.02.25 14:04:55.991 Bench : METHOD 3 : (double)"x12345" = 0.000000. Executed 10000000 times in 781 ms.
2017.02.25 14:04:55.991 Bench :
2017.02.25 14:04:57.514 Bench : METHOD 1 : StringToDouble("123x45") = 123.000000. Executed 10000000 times in 1515 ms.
2017.02.25 14:04:58.953 Bench : METHOD 2 : double("123x45") = 123.000000. Executed 10000000 times in 1438 ms.
2017.02.25 14:05:00.324 Bench : METHOD 3 : (double)"123x45" = 123.000000. Executed 10000000 times in 1375 ms.
2017.02.25 14:05:00.324 Bench :
2017.02.25 14:05:01.851 Bench : METHOD 1 : StringToDouble(" 123") = 123.000000. Executed 10000000 times in 1531 ms.
2017.02.25 14:05:03.335 Bench : METHOD 2 : double(" 123") = 123.000000. Executed 10000000 times in 1485 ms.
2017.02.25 14:05:04.852 Bench : METHOD 3 : (double)" 123" = 123.000000. Executed 10000000 times in 1515 ms.
2017.02.25 14:05:04.852 Bench :
2017.02.25 14:05:06.213 Bench : METHOD 1 : StringToDouble(" 12 3") = 12.000000. Executed 10000000 times in 1360 ms.
2017.02.25 14:05:07.593 Bench : METHOD 2 : double(" 12 3") = 12.000000. Executed 10000000 times in 1375 ms.
2017.02.25 14:05:09.077 Bench : METHOD 3 : (double)" 12 3" = 12.000000. Executed 10000000 times in 1484 ms.
2017.02.25 14:05:09.077 Bench :
2017.02.25 14:05:11.731 Bench : METHOD 1 : StringToDouble("123.45") = 123.450000. Executed 10000000 times in 2656 ms.
2017.02.25 14:05:14.416 Bench : METHOD 2 : double("123.45") = 123.450000. Executed 10000000 times in 2688 ms.
2017.02.25 14:05:17.119 Bench : METHOD 3 : (double)"123.45" = 123.450000. Executed 10000000 times in 2703 ms.
2017.02.25 14:05:17.119 Bench :
2017.02.25 14:05:19.703 Bench : METHOD 1 : StringToDouble("123.4.5") = 123.400000. Executed 10000000 times in 2578 ms.
2017.02.25 14:05:22.487 Bench : METHOD 2 : double("123.4.5") = 123.400000. Executed 10000000 times in 2797 ms.
2017.02.25 14:05:25.328 Bench : METHOD 3 : (double)"123.4.5" = 123.400000. Executed 10000000 times in 2828 ms.
2017.02.25 14:05:25.328 Bench :
2017.02.25 14:05:26.649 Bench : METHOD 1 : StringToDouble("1,234.50") = 1.000000. Executed 10000000 times in 1328 ms.
2017.02.25 14:05:27.953 Bench : METHOD 2 : double("1,234.50") = 1.000000. Executed 10000000 times in 1313 ms.
2017.02.25 14:05:29.261 Bench : METHOD 3 : (double)"1,234.50" = 1.000000. Executed 10000000 times in 1296 ms.
I would also appreciate it, if there is a function that removes the leading numbers and leaves only the alphabets and other symbols. So that I may execute StringToDouble on the remaining symbols (without leading numbers) and get a zero value.
So I made a little script to compare the speed.
And same test with mql5 :-D
Same results I had on earlier MT4 builds i.e. no change in the outcome and no consistent speed benefit from using the function call over the typecast.
So I got lazy and typed less characters from that point onwards
Same results I had on earlier MT4 builds i.e. no change in the outcome and no consistent speed benefit from using the function call over the typecast.
So I got lazy and typed less characters from that point onwards
I will change all my codes to remove StringToDouble()
You guys may also check if the function
You could check and report back.
I'm fairly sure we dealt with the MathIsValidNumber() issue in your other thread
You could check and report back.
I'm fairly sure we dealt with the MathIsValidNumber() issue in your other thread
You could check and report back.
I'm fairly sure we dealt with the MathIsValidNumber() issue in your other thread