In an MQL4 EA, using a calculated moving average for a stoploss, I used MathMax and Min to make sure I wasn't too close. The results were a bit off, so I put in a Print()
to get me details:
stoploss=MathMax(NormalizeDouble(Ask+(minstoplevel*Point),Digits),NormalizeDouble(MA_Line,Digits));
Print("Sell SLCalc = "+NormalizeDouble(Ask+(minstoplevel*Point),Digits)+", MA_Line = "+NormalizeDouble(MA_Line,Digits),", Max is ",MathMax(NormalizeDouble(Ask+(minstoplevel*Point),Digits),NormalizeDouble(MA_Line,Digits)));
The result:
2023.03.24 16:46:36.607 2022.07.18 03:14:29 MA1 GBPUSD,M1: Sell SLCalc = 1.18836, MA_Line = 1.18835, Max is 1.1884
I was expecting the Max to have the same 5-digit precision. Why is the MathMax function rounding the result, when I've specified the point to the function, rather than the pip?
It may seem like a small difference, but that's the world of Forex, and a small rounding error could stop me out or keep me in a long trend. Besides, I just want things to work as advertised, or understand why they don't.