ERROR: MathRound + Windows Server 2019 + MetaTrader 4 = not working

 

I found that the MathRound function does not work correctly in the MT4 terminal (latest version 1421) on Windows Server 2019


double Lot2=0.305;
if(SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP)!=0)
      Lot2=MathMin(MathMax(MathRound(Lot2/SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP))*SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP),SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN)),SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX));
Print(" Round="+MathRound(Lot2/SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP)));

Results:

Round=0 



I used different functions, but the problem is only on Server 2019.

MathCeil also doesn't work.


The same code on Standard Windows 11 works without problems.

Round=30




Solution: Now I use (int) instead of Math Round and everything works correctly.

if(SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP)!=0)
      Lot2=MathMin(MathMax((int)(Lot2/SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP))*SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP),SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN)),SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX));

The problem is only on Windows Server 2019


Documentation on MQL5: Math Functions / MathRound
Documentation on MQL5: Math Functions / MathRound
  • www.mql5.com
The function returns a value rounded off to the nearest integer of the specified numeric value. Parameters value [in]  Numeric value before...
 
Latest MT4 update 1421 has a very SERIOUS BUG!!!
Latest MT4 update 1421 has a very SERIOUS BUG!!!
  • 2024.07.29
  • Vu Trung Kien
  • www.mql5.com
Hello Developer Team, I found a very serious bug in latest MT4 update (version 4.00 build 1421 on 22 Jul 2024...
 

We are found a bug in the CRT function floor, when it fallback execution from SSE4.1 to SSE2 and CRT is linked as static library (/MT)

CRT function floor doesn't work properly if your CPU doesn't support SSE4.1

 
Ilyas #:

We are found a bug in the CRT function floor, when it fallback execution from SSE4.1 to SSE2 and CRT is linked as static library (/MT)

CRT function floor doesn't work properly if your CPU doesn't support SSE4.1

Thank you. I don't use servers with old computers. But clients from the market do. They use dedicated servers and get this error en masse.
 
Vladislav Andruschenko #:
Thank you. I don't use servers with old computers. But clients from the market do. They use dedicated servers and get this error en masse.

Lets see what MS will say: https://developercommunity.visualstudio.com/t/function-floor-does-not-properly-work-on/10778831?

We will make custom floor to bypass this bug.

Developer Community
Developer Community
  • developercommunity.visualstudio.com
Developer Community