Buying or Selling at the 00 levels.
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.
I guess he rather asked for rounding. MathRound() will help him.
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);
//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);
No need to overcomplicate :
double BID=1.1756; double nexthigherround=MathCeil(BID*100)/100.0; double nextlowerround=MathFloor(BID*100)/100.0;
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.