William Roeder #:
I thought that using accountbalance and accountprofit would give me the amounts Mihlali Dlulane: but it does not seem to be working properly | |
Why do you expect this to work correctly? |
Use the constants to get the actual values.
void CloseByEquity () { const double Balance = ACCOUNT_BALANCE; const double Profit = ACCOUNT_PROFIT; if ( Profit >= Balance * 10/100){ return; } int retries = 10; for (int i=0; i<retries ; i++){ if (CloseAll()){ return; } } return; }
so i need to set them like this instead ?
Mihlali Dlulane #: so i need to set them like this instead ? | const double Balance = ACCOUNT_BALANCE; const double Profit = ACCOUNT_PROFIT; |
Same as the previous post. | const double Balance = 0; const double Profit = 2; |
What part of “Use the constants to get the actual values.” was unclear?
For the function AccountInfoDouble()
Identifier | Description | Type |
---|---|---|
ACCOUNT_BALANCE | Account balance in the deposit currency | double |
ACCOUNT_PROFIT | Current profit of an account in the deposit currency | double |
William Roeder #:
sorry i didnt read the documentation, Mihlali Dlulane #: so i need to set them like this instead ? | |
Same as the previous post. |
What part of “Use the constants to get the actual values.” was unclear?
Thanks for the help
void CloseByEquity () { const double Balance = AccountInfoDouble(ACCOUNT_BALANCE); const double Profit = AccountInfoDouble(ACCOUNT_PROFIT); if ( Profit >= Balance * 10/100){ return; } int retries = 10; for (int i=0; i<retries ; i++){ if (CloseAll()){ return; } } return; }
This is how is should be used now ?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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 i made this function to close trades when the amount of profit in the open positions crosses a certain threshold the bot closes all open positions cause i noticed in the back test that EA was had alot of equity it was holding onto but was not closing the trades.
but it does not seem to be working properly cause its still not closing the trades in the backtest when the threshold is passed.