- Futures - For Advanced Users - Trading Operations
- Opening and Closing Positions - Trade - MetaTrader 5 for Android
- Opening and Closing Positions - Trade - MetaTrader 5 for iPhone
For you to use balance like that the orders have to be already closed so you have to use a different function.
Please see these:
For the function AccountInfoDouble()
Identifier | Description | Type |
ACCOUNT_BALANCE | Account balance in the deposit currency | double |
ACCOUNT_CREDIT | Account credit in the deposit currency | double |
ACCOUNT_PROFIT | Current profit of an account in the deposit currency | double |
ACCOUNT_EQUITY | Account equity in the deposit currency | double |
ACCOUNT_MARGIN | Account margin used in the deposit currency | double |
ACCOUNT_MARGIN_FREE | Free margin of an account in the deposit currency | double |
ACCOUNT_MARGIN_LEVEL | Account margin level in percents | double |
ACCOUNT_MARGIN_SO_CALL | Margin call level. Depending on the set ACCOUNT_MARGIN_SO_MODE is expressed in percents or in the deposit currency | double |
ACCOUNT_MARGIN_SO_SO | Margin stop out level. Depending on the set ACCOUNT_MARGIN_SO_MODE is expressed in percents or in the deposit currency | double |
ACCOUNT_MARGIN_INITIAL | Initial margin. The amount reserved on an account to cover the margin of all pending orders | double |
ACCOUNT_MARGIN_MAINTENANCE | Maintenance margin. The minimum equity reserved on an account to cover the minimum amount of all open positions | double |
ACCOUNT_ASSETS | The current assets of an account | double |
ACCOUNT_LIABILITIES | The current liabilities on an account | double |
ACCOUNT_COMMISSION_BLOCKED | The current blocked commission amount on an account | double |
record the account balance on EA start.
each time your equity reaches your 5% gain (your smaller goal), close all positions, then set the current account balance as a new starting point.
double STARTING_BALANCE; // a global variable of course OnInit() : STARTING_BALANCE = AccountInfoDouble.....(ACCOUNT_BALANCE....) Ontick() : if there's open positions right now.... // check by PositionsTotal()... current_EQUITY = AccountInfoDouble....(ACCOUNT_EQUITY....) // current floating equity if(current_EQUITY >= STARTING_BALANCE * 105 * 0.01) { // here close all open positions.... STARTING_BALANCE = current_EQUITY; }
record the account balance on EA start.
each time your equity reaches your 5% gain (your smaller goal), close all positions, then set the current account balance as a new starting point.
yes .. agree with you
- Search for it,
-
Beg at
- Coding help - MQL4 and MetaTrader 4 - MQL4 programming forum
- Requests & Ideas (MQL5 only!) - Trade FX - Expert Advisors and Automated Trading - MQL5 programming forum
- Free coding for your trading system.. - Easy Trading Strategy - General - MQL5 programming forum
- I will code & automate your strategy for free - Options Trading Strategies - General - MQL5 programming forum
- Make It No Repaint Please! - MetaTrader 5 - MQL4 and MetaTrader 4 - MQL4 programming forum
- learn to code it. If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into yours.
- or pay (Freelance) someone to code it.
No free help
urgent help.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use