forex software

Create and Test Forex Strategies

forex software

Skip to forum content

Forex Software

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

Pages 1

You must login or register to post a reply

RSS topic feed

Posts: 9

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.

do or do not there is no try

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;
do or do not there is no try

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

do or do not there is no try

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

is this working with portfolio?

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

Yes, it must work.

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

Popov wrote:

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

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

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.

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

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.

Posts: 9

Pages 1

You must login or register to post a reply

Forex Software → Expert Advisor Modifications → Modification to Stop Opening New Trades When Equity Below X Amount

Similar topics in this forum