Example needed.

 
Take a price, for example 1.4322 (For most pairs) or 121.97 (for Yen Pairs).

How do you write a function with two inputs of price that returns price values to the nearest zero?

Example: 1.4322 as 1.4320 (realize the last digit is zero) and 121.97 to 122.00.

I used this function, but it did not work for some reason:

double ZeroUp(double price) //Function added to get nearest zeros value.
{
   return((MathRound(price/Point))*Point); //This converts values like 1.4322 and 121.97 into 14322 and 12197.
}                                          //Then it rounds it up to the nearest zero: 14322 to 14320 and 12197 to 12200.
                                           //Lastly, it returns the values back as price values such as 1.4320 and 122.00.

Anyone know why ?
 

use

  #property  copyright "ps"
double getNearestDoubleZero(double price, int pos) {
   double factor=MathPow(10, pos);
   return(MathRound(price*factor)/factor); }
 
FinGeR:

use Function getNearestDoubleZero(double price, int pos

'Double-Zero Indicator'

FinGeR,


Thanks.

 
Thank you. Its working fine. :-)