typecasting error
maximumLossPerTrade = accountBalanceinEuro / 100 * NormalizeDouble(maximumLossPercentage, 1);
paul selvan:
typecasting error
Without typecasting, it again gives 255.
int maximumLossPerTrade; int accountBalanceinEuro; accountBalanceinEuro / 10014232/100=142, 142*1.8=255
On MT4 v434, division quotient don't give floating point values(Bug??) - MQL4 and MetaTrader 4 - MQL4 programming forum 2012.09.18
William Roeder:
14232/100=142, 142*1.8=255
On MT4 v434, division quotient don't give floating point values(Bug??) - MQL4 and MetaTrader 4 - MQL4 programming forum 2012.09.18
14232/100=142, 142*1.8=255
On MT4 v434, division quotient don't give floating point values(Bug??) - MQL4 and MetaTrader 4 - MQL4 programming forum 2012.09.18
Solved it in this way:
maximumLossPerTrade = (int)((accountBalanceinEuro * NormalizeDouble(maximumLossPercentage, 1)) / 100);
Thanks William.
... or like so of course :)
maximumLossPerTrade = (int)(accountBalanceinEuro / 100.0 * NormalizeDouble(maximumLossPercentage, 1));
setting all variables as double gives good precision
double accountBalanceinEuro = 14232; double maximumLossPercentage = 1.8; double maximumLossPerTrade = accountBalanceinEuro * maximumLossPercentage/ 100 ;
paul selvan:
setting all variables as double gives good precision
Of course, thanks.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
When;
I get 255 for maximumLossPerTrade.
But, in excel, it is 256 which is the correct value.
What is wrong in the above MQL 4 computation ?