Download MetaTrader 5
To add comments, please log in or register
No time to learn MQL5? The source code library is at your service!
hals
11
hals 2015.04.02 20:48 

Hello,

I'm trying to do some mathematical equations within my EA , but the problem is one of equations  requires the first number of account's balance . For example if the balance is 506.60 I want to get this value "5" , if it is 432.32 I want to get "4" . So how can it be done ? 

Note : To get the current balance I use AccountBalance();

peter.MT4Web
158
peter.MT4Web 2015.04.02 21:08  

Hi hals69!

Try

  long value = StringToInteger (StringSubstr (DoubleToString (AccountBalance ( )), 0, 1));


whroeder1
13644
whroeder1 2015.04.03 00:56  
int d = int( AccountBalance() / 100); // 4xx.xx/100=4.xxx 5xx.xx/100=5
What if the balance is 99, do you want zero? What if the balance is 1000, do you want 10? If not then eddie's idea works. If yes, then mine.
/
To add comments, please log in or register