Download MetaTrader 5
To add comments, please log in or register
Code Base will help you in mastering your theoretical skills. Come and learn!
trader201
404
trader201 2014.07.04 15:46 
Hello.


What is the correct way to obtain a percentage in MQL4?

I see rule of 3 it work (Y*X/100), but is this the right way? (I just want to confirm).

When I use "X = y%", have the problem of two "=" signs (X=X=Y%;). It does not allow to write "X*1%" . Soo, What is the correct way to obtain a percentage in MQL4?


Thank you in advance

trader201

Ian Venner
2583
Ian Venner 2014.07.04 16:01  
you are over thinking it .... divide account balance by 100.
trader201
404
trader201 2014.07.04 20:24  
SDC:
you are over thinking it .... divide account balance by 100.

divide account balance by 100.doesn´t work.

When I use this value (account/100) and put this in "Alert", it say me the value. But when I use this value to determine the lots in OrderSend ((Account/100) and then divide this /SL), it does not work. The way I said before it does.

My question is: using the rule of 3 (Y*X/100), that worked, is the right way, or I can have a problem later?

What is the way to obteing % in mql4? 

honest_knave
962
honest_knave 2014.07.04 20:27  

I think the issue is with your method of calculating the lot size.

As SDC says, AccountBalance() / 100 is most definitely 1% of your account balance.

Keith Watford
Moderator
7907
Keith Watford 2014.07.04 21:57  
SDC:
you are over thinking it .... divide account balance by 100.

trader201:

divide account balance by 100 doesn´t work. 


Of course it works.

Your question is in your title

What is the correct way to get the 1% of the account?

and dividing the balance by 100 will give you 1%

So if you want to find out X%

Balance/100*X 

/
To add comments, please log in or register