Vyckaa:
Hi, simple question, is it posible to write account balance in percentage?
why for egz. this :
if (AccountBalance()<90%) lot=0.02;
cannot work instead of this:
if (AccountBalance()<300) lot=0.02;
This is not a programming issue so much as a maths question.
It seems as if you want to look at how depleted the account has become. In this case you need to remember the initial value.
So initially you will want to set ...
double initialBalance = AccountBalance();
Then at some later point you can calculate the required value ...
double percentAccountBalance= 100.0* AccountBalance()/initialBalance;
Then and only then can you write your test ...
if( percentAccountBalance < 90.0 ) lot=0.02;
but don’t use the percentage sign.
Ok i will try, that preaty simple and wise :)
dabbler:
So initially you will want to set ..
So initially you will want to set ..
double initialBalance = AccountBalance();
That won't work unless it's a static or global.
Instead just compute it
double initialBalance = AccountBalance(); int nHist = 0; for(int iPos=OrdersHistoryTotal()-1; iPos >= 0 ; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS, MODE_HISTORY) // Only orders w/ && OrderMagicNumber() == Magic.Number // my magic number && OrderSymbol() == chart.symbol // and my pair. && OrderType() <= OP_SELL// Avoid cr/bal forum.mql4.com/32363#325360 ){ double profit = OrderProfit() + OrderSwap() + OrderCommission(); initialBalance -= profit; nHist++; if (nHist == max.Lookback) break; }

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
Hi, simple question, is it posible to write account balance in percentage?
why for egz. this :
if (AccountBalance()<90%) lot=0.02;
cannot work instead of this:
if (AccountBalance()<300) lot=0.02;