Hi,
I am trying to write a function that returns a round number if it's present between two values;
e.g.
1.66500
1.67000
1.67500
I want the funtion to take two price value and then return the round number between these values.
I have already written this function
-----------------------------------------------
string roundNumbers (double p){
string price,substr;
if ( MarketInfo(Symbol(),MODE_DIGITS)==5)
{
price=DoubleToStr(p,5); // convert to string
substr=StringSubstr(price,4,2);
return (substr); // returns 00,50, or anything else
}
if ( MarketInfo(Symbol(),MODE_DIGITS)==3)
{
price=DoubleToStr(p,3); // convert to string
substr=StringSubstr(price,4,2);
return (substr); // returns 00,50, or anything else
}
}
-------------------------------------------
and then i can call if with something like;
if ((roundNumbers (1.68773)=="00"){ Print ("This is not a round number");}
but I'm not really there yet. The problem being is that I can see a way to do it by having an iterative loop between two value that iterated pip by pip and each time calls this function, but I am playing to scan mulitple currencies, and time frames simultaneoulsy and that to me seems like a hell of a lot of looping! Please help - James
if you use the search box in top right of this page you will find for example https://www.mql5.com/en/forum/118820 :-)
if you use the search box in top right of this page you will find for example https://www.mql5.com/en/forum/118820 :-)
Thankyou, I'll check that out.
double rounded.above = MathCeil( Bid / 100)*100, rounded.below = MathFloor(Bid / 100)*100;
Extended discussion (in Russian) at Hunting Foot
Code at BHS system
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am trying to write a function that returns a round number if it's present between two values;
e.g.
1.66500
1.67000
1.67500
I want the funtion to take two price value and then return the round number between these values.
I have already written this function
-----------------------------------------------
string roundNumbers (double p){
string price,substr;
if ( MarketInfo(Symbol(),MODE_DIGITS)==5)
{
price=DoubleToStr(p,5); // convert to string
substr=StringSubstr(price,4,2);
return (substr); // returns 00,50, or anything else
}
if ( MarketInfo(Symbol(),MODE_DIGITS)==3)
{
price=DoubleToStr(p,3); // convert to string
substr=StringSubstr(price,4,2);
return (substr); // returns 00,50, or anything else
}
}
-------------------------------------------
and then i can call if with something like;
if ((roundNumbers (1.68773)=="00"){ Print ("This is not a round number");}
but I'm not really there yet. The problem being is that I can see a way to do it by having an iterative loop between two value that iterated pip by pip and each time calls this function, but I am playing to scan mulitple currencies, and time frames simultaneoulsy and that to me seems like a hell of a lot of looping! Please help - James