Auto Close/Reset/Restart all positions when some profit is done

 

Auto Close/Reset/Restart all positions when some profit is done

Hi Everybody,

I use many martingale MT4-EAs. Many times there is situations when the current Profit(because of still open negative positions) is negative but the current Equity is higher than the time when last martingale cycle was started (because meanwhile some very profitable positions were closed on good profit) . At this time I want to close all open positions and restart the martingale cycle. Unfortunately my EAs do not do that and wait current balance to be positive but I do not want to wait to close all opened positions because I am already on + Equity since last restart and also because there are open positions(negative)  with higher lot size(comparing to initial lot size). Some of you may say that this should be integrated in the EAs but I have many EAs and I could not force all authors to integrate this function.

I need simple MT4 EA that has 2 parameters:

1.) Check Period [min] =1,2, 5, 60 ....

2.) Equity Amount threshold above which to do:

-Stop Auto trading

-close all open positions

-save on file and in memory current Balance=Equity

-Start Auto trading

May be this simple EA already exist(preferably for free)

Regards

 
  1. Micho Dumanov: I use many martingale MT4-EAs.

    Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
              Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum 2015.02.11

    Why it won't work: Calculate Loss from Lot Pips - MQL5 programming forum 2017.07.11

  2. Micho Dumanov: I need simple MT4 EA that …
    You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

  3. Micho Dumanov: May be this simple EA already exist

    You don't know how to code, but the changes are easy? That's like saying "I don't know how to build engines but adding another cylinder should be easy; it's just one more."
              Is it easy (or difficult) to …? - General - MQL5 programming forum #2 2017.08.31

  4. You are in the hole. Instead of completeing the cycle and making one unit profit, you want to stop at zero net profit. That worse than Martingale.
 
William Roeder:
  1. Martingale, guaranteed to blow your account eventually. If it's not profitable without, it is definitely not profitable with.
              Martingale vs. Non Martingale (Simplified RoR vs Profit and the Illusions) - MQL5 programming forum 2015.02.11

    Why it won't work: Calculate Loss from Lot Pips - MQL5 programming forum 2017.07.11

  2. You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

  3. You don't know how to code, but the changes are easy? That's like saying "I don't know how to build engines but adding another cylinder should be easy; it's just one more."
              Is it easy (or difficult) to …? - General - MQL5 programming forum #2 2017.08.31

  4. You are in the hole. Instead of completeing the cycle and making one unit profit, you want to stop at zero net profit. That worse than Martingale.

I am not agree about point 1.)  because I have EA that make 500-1000% profit /month so if I withdraw reguraly each +100% even I reach MC I will be on rpfit.

About point 4.) You didn't read what I have written carefully. I sad that I want to close all position when the Equity is higher than above. That means I am on profit.

About point 2.) There is no attempt. I just locking for free solution.

About point 3.) Eventually I can code it myself but I am sure someone is done it for free before me.

 

Hi  Micho Dumanov,

Did you find a solution yet? I am looking for the same solution.

Micho Dumanov
Micho Dumanov
  • 2020.08.14
  • www.mql5.com
Trader's profile
 

So, it took me 2 minutes to find the answer on google. It directed me to the documentation. Because I may need this in the future.

For MT4:

double  equity  = AccountEquity();

double balance = AccountBalance();

Then you could compare both values and if the difference is greater than some number. Then you could iterate through all open orders and close them.

Reason: