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
I didn't understand your suggestion, sorry!
I have the stop loss value as a string so i need to convert it as a double to make the other adjustments;
if i drop the stringtodouble command then the compiler will do an implicit conversion.
Did you refer to this?
Christian
Oh sorry, at the first i didin't understand the question, i try to explain why i have the SL parameter as a string....
I open the order with Telegram, i made a simple bot (for me) that is connected to my MetaTrader Demo account;
to open an order, i have to send a command to the bot followed by the OrderSend parameters separated by ';', this is an example:
So i receive all the command and then i need to split the parameters with the StringSplit function in an array of string.
This is why i have all the parameters (include the SL) as a string...
Tell me if i explained the reason in a clear way..
Oh sorry, at the first i didin't understand the question, i try to explain why i have the SL parameter as a string....
I open the order with Telegram, i made a simple bot (for me) that is connected to my MetaTrader Demo account;
to open an order, i have to send a command to the bot followed by the OrderSend parameters separated by ';', this is an example:
So i receive all the command and then i need to split the parameters with the StringSplit function in an array of string.
This is why i have all the parameters (include the SL) as a string...
Tell me if i explained the reason in a clear way..
Something like StringIsNumeric() may help to check the string before conversion.
Unfortunatly this library is for MT5 (i use MT4) but the ideaa is good :)
Unfortunatly, it doens't work always :(
Despite i adjusted the stoploss value with the MarketInfo function and MODE_TICKET parameter, in some cases during the moltiplication with tickSize, the double value for stoploss return with more than five decimal number.
By debugging the code, i see that during the conversion from String to Double the function add some decimal value (and i don't know why), so for example 1.07866 in string become 1.07866000000001 in double.
Why the StringToDouble function do this? I think all the problems start from here. Is there a way to delete all the decimal numbers over the fifth value?
I also tried with MthFloor and MathRound, without success...
Unfortunatly, it doens't work always :(
Despite i adjusted the stoploss value with the MarketInfo function and MODE_TICKET parameter, in some cases during the moltiplication with tickSize, the double value for stoploss return with more than five decimal number.
By debugging the code, i see that during the conversion from String to Double the function add some decimal value (and i don't know why), so for example 1.07866 in string become 1.07866000000001 in double.
Why the StringToDouble function do this? I think all the problems start from here. Is there a way to delete all the decimal numbers over the fifth value?
I also tried with MthFloor and MathRound, without success...
I read and re-read the article more than one time, i'm not a developer but with lot effort i think i understand the concept.
Basically, i am interesting to know if there are a solution to convert a string in a double and clean it from the decimal values that cause the error.
Because if the asnwer is YES then i can try to study how, but if the answer is NO anyway the i interrupt the project because i think it's stupid studying for something impossible and unsolvable.
So, if you can, do you think is there a possible solution or it is unsolvable? In onor to the community spirit, today this is an informatoin for me, tomorrow it will be an informations for others.
Thnks you so much
Christian
ducarpit #:
By debugging the code, i see that during the conversion from String to Double the function add some decimal value (and i don't know why), so for example 1.07866 in string become 1.07866000000001 in double.
Floating-point has an infinite number of decimals. It's you, not understanding floating-point and that some numbers can't be represented exactly. (like 1/10.)
Double-precision floating-point format - Wikipedia
See also The == operand. - MQL4 programming forum (2013)
If you want to see the correct number of digits, convert it to a string with the correct/wanted accuracy.
question about decima of marketinfo() - MQL4 programming forum (2016)
I read and re-read the article more than one time, i'm not a developer but with lot effort i think i understand the concept.
Basically, i am interesting to know if there are a solution to convert a string in a double and clean it from the decimal values that cause the error.
Because if the asnwer is YES then i can try to study how, but if the answer is NO anyway the i interrupt the project because i think it's stupid studying for something impossible and unsolvable.
So, if you can, do you think is there a possible solution or it is unsolvable? In onor to the community spirit, today this is an informatoin for me, tomorrow it will be an informations for others.
Thnks you so much
Christian