MQL5: Round price to nearest integer
double RoundPrice(double price, double roundTo)
{
double remainder = fmod(price, roundTo);
double roundedPrice = price - remainder;
if(remainder >= roundTo / 2)
roundedPrice += roundTo;
return roundedPrice;
}
double RoundPrice(double price, double roundTo)
{
double remainder = fmod(price, roundTo);
double roundedPrice = price - remainder;
if(remainder >= roundTo / 2)
roundedPrice += roundTo;
return roundedPrice;
}
Comments
Post a Comment