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.

I’m working on improving my English and trading skill

Re: Modification to Stop Opening New Trades When Equity Below X Amount

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;
I’m working on improving my English and trading skill

Re: Modification to Stop Opening New Trades When Equity Below X Amount

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();     
     }
  }

4 (edited by yonkuro 2017-03-23 05:39:22)

Re: Modification to Stop Opening New Trades When Equity Below X Amount

Great! thanks smile

I’m working on improving my English and trading skill