This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community
How to return value to 1 decimal place ??Back to topics list |
|
mpfx
2004.12.10 10:43
Greetings all,
I am trying to calculate a formula that will allow 5% of account equity to be used as lots size. So on a 10k account it would set a lot size of 0.5 lots, 50k acc would be 2.5 lots etc...... This is the formula. Levv = MathAbs((AccountEquity()*Perc/100/100)/10); Perc is declared as an exernal double. I need to round this down to 1 decimal place so mt4 will acept the order. I have tried mathround() but it will round it to 1 lot. Thanks & GT...... |
|
Slawa
2004.12.10 12:29
double norm=NormalizeDouble(your_value,1)
int firstnum=(norm-MathFloor(your_value))*10; see also our library stdlib.mq4, DoubleToStrMorePrecision function |
|
mpfx
2004.12.10 14:01
Thanks Slawa..
fwiw mt4 is working great at my end keep up the good work :) |
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets
