Trailing Stop on Profit MT4/MT5 Expert Advisor

Trailing Stop on Profit EA is an expert advisor that can manage your trades' stop-losses by moving them in tandem with the current price when it goes in your favor. Below you can download this free expert advisor for MetaTrader 4 and 5.

This EA follows a simple rule and doesn't rely on any indicators. You will see it in more detail and with some examples.

What is Trailing Stop?

In case you are new to the concept of trailing stop: trailing stop is the practice of moving the stop-loss level closer to the current price when the price moves in your favor.

Trailing the stop-loss allows traders to limit their losses and safeguard their profits. It is a very popular practice.

As you may have read in books and forums, one of the first rules in Forex is Cut your losses short and let your profits run.

What is Trailing Stop on Profit EA?

Trailing Stop on Profit EA is a free open-source MetaTrader expert advisor that can manage the stop-loss levels of your trades.

In particular, this expert advisor uses two parameters to trail the stop-loss according to your preferences.

In many cases, you might want to start moving the stop-loss closer to the current price or exchange rate when the position is showing profit.

This trailing stop-loss EA allow you to do exactly this: to trigger a stop-loss movement when the profit reaches a specific threshold and the price reaches a certain distance to the existing stop-loss.

Using a trailing stop is a very popular practice among traders. With the Trailing Stop on Profit MetaTrader EA, you can have the stop-loss of your trades incremented gradually as the currency rate or price moves in your favor and the trade is in profit.

Why is Trailing Stop on Profit EA useful?

Risk management is one of the most important aspects in trading. Having a stop-loss will protect you from margin calls and big losses.

In many cases, it is useful to have a trailing stop, which is a "moving stop". A trailing stop is a stop-loss where the value is updated when the price moves in the favor of the trade.

There are many types of trailing stop — it can be a fixed step change or it can follow some indicator.

In the case of the Trailing Stop on Profit expert advisor, the stop-loss follows the price gradually but only once a certain level of profit is attained.

There are several advantages of using Trailing Stop on Profit EA for MetaTrader:

  1. Filtering options to select which trades to manage.
  2. Start trailing when a conditional profit is reached (can be negative!).
  3. The stop-loss follows the price when moving in the trade's favor.
  4. It doesn't require human interaction.
  5. Limit losses.
  6. Secure profits.
  7. Avoid margin calls.
  8. Notifications when the stop-loss is updated.

Rules

The EA abides by the following rules:

  • The price moves in the direction of the order: up for a buy order and down for a sell order.
  • The distance between the stop-loss level and the price is equal or greater than a number of pips given in the first input parameter.
  • The current profit is equal or greater than the number of points given in the second input parameter.

Examples

These two examples explain the mechanics of this EA.

Example with buy trade

Buy order: USD/CHF with open price at 0.94192, stop-loss at 0.94092, trailing stop distance at 100 points, required profit at 200 points.

  • When the price reaches 0.94192 + 200 = 0.94392, the stop-loss will be moved to 0.94392 - 100 = 0.94292.
  • When the price reaches the next price above this level, e.g., 0.94392 + 1 = 0.94393, the stop-loss will be once again moved to 0.94393 - 100 = 0.94293.
  • And so on.

This will continue until the stop-loss is hit or the order is otherwise closed.

Example with sell trade

Sell order: EUR/USD with open price at 1.02005, starting without stop-loss, trailing stop distance at 80 points, required profit at 80 points.

  • When the price reaches 1.02005 - 80 = 1.01925, the stop-loss will be set to 1.01925 + 80 = 1.2005.
  • When the price reaches the next price below this level, e.g., 1.01925 - 3 = 1.01922, the stop-loss will be once again moved to 1.01922 + 80 = 1.20002.
  • And so on.

This will continue until the stop-loss is hit or the order is otherwise closed.

Trailing stop demonstration

Below is the demonstration of how the Trailing Stop on Profit EA works. The red line shows the trade's current stop-loss. The dashed green line shows the entry. The dotted green line shows the profit level where the trailing stop should start taking effect. The solid gray line in the bid price.

Trailing Stop on Profit Expert Advisor Explained

MT4 Trailing Stop on Profit

About MT4 Trailing Stop on Profit EA

About MT4 Trailing Stop on Profit EA

Input parameters in MT4

Trailing Stop on Profit Parameters in MetaTrader 4

Trailing Stop on Profit Parameters in MT4

You can configure this expert advisor with the following input parameters:

  • Trailing Stop — how far from the current price should the stop-loss be moved to.
  • Profit — how many points of profit should the trade have for the EA to trigger.
  • Apply To — select which types of orders to apply a trailing stop to.
  • Filter By Magic Number — true or false depending on whether you want to modify only the orders with a specific magic number.
  • Magic Number — specify the magic number in case the above is true.
  • Filter By Comment — true or false depending on whether you want to modify only the orders with a specific comment.
  • Comment — specify the comment if the above is true. Note: The expert advisor only checks whether a commentary field contains the given text. For example, if you set the parameter to "Test", the EA will work for trades with "123Test" and with "Test123" commentary values.
  • Enable Trailing Stop — if true, the EA is active and is trailing stop-losses.
  • Enable Notifications feature — if true, the EA will send notifications upon triggering.
  • Send Alert Notification — if true, the EA will issue native on-screen alerts.
  • Send Notification to Mobile — if true, the EA will send push-notifications to your mobile device.
  • Send Notification via Email — if true, the EA will send emails when it updates a stop-loss.
  • Show Graphical Panel — if true, a graphical panel will appear on the chart to control the expert advisor.

MT5 Trailing Stop on Profit

About MT5 Trailing Stop on Profit EA

About MT5 Trailing Stop on Profit EA

Input parameters in MT5

Trailing Stop on Profit Parameters in MetaTrader 5

Trailing Stop on Profit Parameters in MT5

As you can see, the MT5 version of the expert advisor uses exactly the same input parameters as the MT4 version. You can read their detailed description above.

How to download and use Trailing Stop on Profit EA?

You can download this MT4/MT5 expert advisor using the links below and install it by following the presented instructions.

MT4 Download

➥ Download MT4 Trailing Stop on Profit

MT4 Trailing Stop on Profit EA installation

The installation is very easy to perform; the same is the use. Once you run the expert advisor, you can set all the necessary input parameters.

Make sure you enable Live Trading in the Common tab when attaching the EA and also in the platform's menu Tools→Options→Expert Advisors. Otherwise, it won't be able to modify orders.

How to Enable Live Trading for Expert Advisors in MT4?

To install the EA in MetaTrader 4, please follow the instructions below:

  1. Download the expert advisor archive file.
  2. Open the MetaTrader 4 data folder (via File→Open Data Folder).
  3. Open the MQL4 Folder.
  4. Copy all the folders from the archive directly to the MQL4 folder.
  5. Restart MetaTrader 4 or refresh the expert advisors list by right-clicking the Navigator subwindow of the platform and choosing Refresh.

Or you can read a more detailed instruction on how to perform the installation of this MT4 expert advisor.

MT5 Download

➥ Download MT5 Trailing Stop on Profit

MT5 Trailing Stop on Profit EA installation

Make sure you enable Allow Algo Trading in the Common tab when attaching the EA and also Allow algorithmic trading in the platform's menu Tools→Options→Expert Advisors. Otherwise, it won't be able to modify orders.

How to enable algorithmic trading for expert advisors in MT5?

To install the EA in MetaTrader 5, please follow the instructions below:

  1. Download the expert advisor archive file.
  2. Open the MetaTrader 5 data folder (via File→Open Data Folder).
  3. Open the MQL5 Folder.
  4. Copy all the folders from the archive directly to the MQL5 folder.
  5. Restart MetaTrader 5 or refresh the expert advisors list by right-clicking the Navigator subwindow of the platform and choosing Refresh.

Or you can read a more detailed instruction on how to perform installation of this MT5 expert advisor.

Frequently asked questions

What settings to use to replicate the standard MetaTrader trailing stop behavior, for example, 100 points trailing stop updating every point regardless of profit?

The Profit input parameter should be set to a negative value — your trailing stop value should work fine. I.e., if you want your trailing stop to be 100 points, you set the Profit parameter to -100.

Conclusion

Using a trailing stop is a good practice with many trading strategies because it can help limiting your losses. This version of a trailing stop EA follows a simple rule of working only when a trade is in specified profit amount and uses no indicators.

You can open a trading account with any of the MT4 Forex brokers to freely use the expert advisor for MetaTrader 4 presented here. If you want to use an MT5 version of the EA, you would need to open an account with a broker that offers MetaTrader 5.

Do you have your own trading results or any other remarks regarding this expert advisor? Discuss Trailing Stop on Profit with other traders and MQL programmers on the experts forums.

© 2005–2022

EarnForex.com

Design — Mart Studio

Forex trading bears intrinsic risks of loss. You must understand that Forex trading, while potentially profitable, can make you lose your money. Never trade with the money that you cannot afford to lose! Trading with leverage can wipe your account even faster.

CFDs are leveraged products and as such loses may be more than the initial invested capital. Trading in CFDs carry a high level of risk thus may not be appropriate for all investors.