Download MetaTrader 5
To add comments, please log in or register
Write articles and earn money. We pay 200 USD for them!
t1m0thy
19
t1m0thy 2015.09.01 20:31 
I'm trying to convert a whole number of pips to the correct price value. For example I want to be able to enter '50' and the function output 0.0005. To do this the maths is simple - 50 / 100000 (this is for a broker giving prices accurate to 5 decimal places of course) now the output is technically correct - 1e-005 but when I try to add this to a price to determine stop levels for example I get a 130 ERR_INVALID_STOPS. Any ideas? Thanks.

UPDATE: When I do 50.0 / 100000 I get the correct, usable answer = 0.0005
ABOVE 50.0 instead of 50, just in case you missed it!
BUT: When I do 3.0 / 100000 I get the useless 3e-005 instead of 0.00003
Daniel Lagoshniak
213
Daniel Lagoshniak 2015.09.02 07:59  
are you sure you put all zeros correctly? try     3 * Point   instead and make sure you add the obtained value to a correct price value(your value is correct if you get it from some price, ie low or high or close of some bar, it is incorrect if you get it from manually installed horizontal line or from the average(and other operations with dividing) of two or more prices. you can also make your values acceptable by NormalizeDouble(value, Digits)
Keith Watford
Moderator
7894
Keith Watford 2015.09.02 11:30  

BUT: When I do 3.0 / 100000 I get the useless 3e-005 instead of 0.00003

 It is not useless. I guess that you are probably printing the value?

  Print( 3.0 / 100000);

 Will print  3e-005 

If you want to see it in a more recognisable form

  Print( DoubleToStr(3.0 / 100000,Digits));

 but it is the same value

/
To add comments, please log in or register