# Buying or Selling at the 00 levels.

1041

How would I code something like if bid is at 1.1756 then I want to put a buy limit at next 00 level below it or at 1.1700. Same or sell. If market at say 1.1756 then I want to place sell limit at closest above 00 level or 1.1800 for example. Is there a built in function that does something similar?

Thank you.

Moderator
6152

How would I code something like if bid is at 1.1756 then I want to put a buy limit at next 00 level below it or at 1.1700. Same or sell. If market at say 1.1756 then I want to place sell limit at closest above 00 level or 1.1800 for example. Is there a built in function that does something similar?

Thank you.

Yes

`NormalizeDouble(value,3)`
Depending on Digits of course.
1553

I guess he rather asked for rounding. MathRound() will help him.
Moderator
6152

Doerk Hilger:
I guess he rather asked for rounding. MathRound() will help him.
How does that handle double ? example>?
1553

You can do it with MathMod(), with MathRound() as well as with MathFloor() or simply (int), whereby the last ones need a multiplication based on the amount of the (unwanted) digits upfront.
1553

Untested example for Forex:

double roundbelow = Bid -MathMod(Bid,1);

double roundabove = Bid+1 -MathMod(Bid,1);

And with MathRound():

double closestround=((double)MathRound(Bid*10)/10.0);

double nexthigherround=((double)MathRound(((Bid)*10)+1)/10.0);

double nextlowerround=((double)MathRound(((Bid)*10)-1)/10.0);

Moderator
6152

```//Untested example for Forex:

double roundbelow = Bid -MathMod(Bid,1);

double roundabove = Bid+1 -MathMod(Bid,1);

//And with MathRound():

double closestround=((double)MathRound(Bid*10)/10.0);

double nexthigherround=((double)MathRound(((Bid)*10)+1)/10.0);

double nextlowerround=((double)MathRound(((Bid)*10)-1)/10.0);

Print("roundbelow ",roundbelow);
Print("roundabove ",roundabove);
Print("closestround ",closestround);
Print("nexthigherround ",nexthigherround);
Print("nextlowerround ",nextlowerround);```
Moderator
35117

No need to overcomplicate :

```double BID=1.1756;
double nexthigherround=MathCeil(BID*100)/100.0;
double nextlowerround=MathFloor(BID*100)/100.0;```
1553

Many ways lead to Rome ;) ... but MathFloor() and MathCeil() seem to be the shortest, cause you don´t have to check anything more to figure out where "you are" currently.