Mastering Trailing Profit: Your Go-To EA for MetaTrader 5

Mike 2017.08.10 21:56 31 0 0
Attachments

Idea Creator:Vitaly, MQL5 Code Author:barabashkakvn.

Have you ever wanted a tool that manages all your open trades in MetaTrader 5? Look no further! This Expert Advisor (EA) takes care of all positions across various symbols, so you can focus on what matters: trading.

If your total profit hasn't hit the minimum_profit, this EA will patiently wait. But once it does, it sets a profit drawdown percentage and starts tracking your gains.

Let's break it down: the percent_of_profit parameter is expressed in percentage. For instance, if your minimum_profit is set to 1000 and your percent_of_profit is 20, here’s how it works: when your total profit reaches 1000, if it dips to 800 (1000 - 20%), your positions will be closed. But if your profit rises to 2000, the allowable drawdown becomes 400 (2000 - 20%), meaning your positions will close at a total profit of 1600. This EA doesn’t use a fixed drawdown limit, which I find more practical than absolute values.

In theory, you can set the percentage to 0, which acts like a total Take Profit. Alternatively, a percentage of 100 functions as a breakeven point. Just remember, as some trades close, others could take a loss.

A quick heads-up: This EA operates on a 3-second interval:

voidOnTick()
  {
//--- allow work every three seconds
   staticdatetime prev_time=0;
   datetime time_current=TimeCurrent();
   if(time_current-prev_time<3)
      return;
   prev_time=time_current;
//---
}


    List
    Comments 0