Topic: Modification to Stop Opening New Trades When Equity Below X Amount
Hi Popov
is there anyway to make the EA stop opening new trades when equity is below X amount?
I want the X amount appears on the EA parameters.
Regards.
Create and Test Forex Strategies
You are not logged in. Please login or register.
Forex Software → Expert Advisor Modifications → Modification to Stop Opening New Trades When Equity Below X Amount
Hi Popov
is there anyway to make the EA stop opening new trades when equity is below X amount?
I want the X amount appears on the EA parameters.
Regards.
Oke I solved it, I just need to add something like this
static input int Minimum_Balance=500; // Minimum Balance
and this
if (AccountFreeMargin()<Minimum_Balance)
{
Print("We have no money.", " Error code=",GetLastError());
return;
Yes, your code may work.
Here is a little bit improved version that closes the current position and also closes the expert.
static input double MinimumEquity = 600; // Minimum Equity
void OnTick()
{
...
double equity = AccountEquity();
if (equity < MinimumEquity)
{
if (posType!=OP_FLAT)
{
ManageClose();
}
ExpertRemove();
}
}
Great! thanks
is this working with portfolio?
Yes, it must work.
Yes, it must work.
hmm doesnt work When i add code and compile than i get following errors:
posType -undeclared identifier
ManageClose - function not defined
Hi Popov
The code is giving me the same errors;
posType -undeclared identifier
ManageClose - function not defined
Can you assist to take a look? And could you code it in % of equity?
Thank you.
I say that the same idea can be used in the Portfolio Experts. Of course, the portfolio can have multiple positions open, and the modification can manage that.
"postType" variable can be replaced with a function that gives if there is an open position at the moment.
"ManageClose" must be a function that can close all open positions of the portfolio. Be careful to take into account the Base_Magic_Number to leave the strategies from the other Portfolios intact.
Forex Software → Expert Advisor Modifications → Modification to Stop Opening New Trades When Equity Below X Amount
Powered by PunBB, supported by Informer Technologies, Inc.