How To Automate The Trailing Stop Loss In Metatrader With An EA

Trailing Stop is one of the most common practice in Risk Management. It is an important task in many strategies to limit losses and secure profits. Trailing Stop simply means to move the Stop Loss price in favour of the trade in some situations. You can automate this task through a Trailing Stop EA in Metatrader.

What Is A Trailing Stop Loss

So what exactly is a Trailing Stop?

Trailing Stop is the short form of Trailing Stop Loss and it is the activity of moving the Stop Loss price when the current price moves in favour of your trade.


Say for example you open a long (buy) position in EURUSD at price 1.1200 and you set the stop 20 pips away (1.1180).

The price then moves to 1.1220 and you move the stop loss to 1.1200.

The price moves again to 1.1240 without hitting your stop and you move the stop to 1.1220.

You are basically applying a trailing stop. You are moving the Stop Loss following the price, until you eventually hit your Take Profit Target or the Stop Loss.

As you can see later in this article there are several types of Trailing Stops.

You can apply it following an indicator or following a fixed distance from the current price.

You also need to know that there are several Expert Advisors (EA) that can automate this process.

Why Using A Trailing Stop

Using a trailing stop is a very common practice between beginner and experienced traders.

It is often implemented in the rules of Risk Management for several strategies.

There are many benefits in executing this task and the mains are:

  • If the trade is still in loss you can limit your losses
  • when the trade is profitable you can secure profits
  • you can avoid margin calls if there are sudden big moves against your trade

Do not underestimate the use of a trailing stop because it can be the difference between a losing and a profitable strategy.


Difference Between Trailing Stop And Stop Loss

Trailing Stop and Stop Loss are closely related but there is a key difference between them.

The Stop Loss price is a price recorder in the trade that when hit will immediately close the trade.

The Trailing Stop is that activity of updating the Stop Loss Price when the price moves in favour of the trade.

It is very important to understand that the two are executed in Metatrader in different ways.

The Stop Loss Price is registered on the server together with the trade, so if that price is hit by the current price the server closes the trade.

The Trailing Stop on the other side is performed on the client side, meaning that you configure it on your terminal and your terminal must be open to update the Stop Loss Price.

In other words, you cannot have a Trailing Stop working without having your Metatrader software running.

How To Enable Trailing Stop In MT4

At this point you should understand fairly well what is a Trailing Stop and why you should use it.

Metatrader MT4 platform offers a very simple Trailing Stop option that you can enable.

To set an auto trailing stop in MT4 right click one of your open orders.

You can see an option “Trailing Stop” that expands in some settings.

With that option you can set the number of points of distance between the current price and the stop loss price.

This is also explained in this article.


Once this is set, your MT4 client will move the stop loss following the current price if this moves in the favour of the trade, keeping a distance of the number of points you set.

For example you set a trailing stop of 100 points (usually 10 pips) on a long position EURUSD opened at 1.1200.

If the price goes to 1.1205 the stop loss will follow to 1.1195.

If the price grows again to 1.1210 the stop loss will follow to 1.1200, keeping a distance of 10 pips.

If the price moves back to 1.1203, the stop will stay at 1.1200 because the price moved against the trade.

So as you can see the Trailing Stop acts as a protection of the trade.

How To Enable Trailing Stop In MT5

To enable the automatic trailing stop in MT5 the process is the same as MT4.

In your MT5 client right click an open trade and select Trailing Stop and the number of points.

MT5 will Trail the Stop Loss following the price at a distance of the points you set.


Auto Trailing Stop EA In Metatrader MT4 And MT5

I find the auto trailing stop in Metatrader too limited.

I believe it is too simple and does not include some other important features.

It would be useful to have more functions like:

  • Ability to apply Trailing Stop to some selected Trades only
  • Filtering the trades with trailing stop by Magic Number
  • Filtering the trades with trailing stop by Comment
  • Send a notification if the stop loss is updated
  • Ability to use more complex function or indicators to trail the stop loss

There are many Expert Advisors that can assist with the Trailing Stop and that include many functionalities.

Some ideas and examples are listed here.

You can find all the Trailing Stop Expert Advisors that I developed in the following links:

How To Move Stop Loss To Break Even

A very simple form of trailing stop is to move the stop loss to break even, which is the open price.

This can be done when the price is at a minimum distance from the Open Price.

For Example if you want to move the stop loss to break even when the price is 50 pips above your buy order open price.

This is a trailing stop that only acts once.



Trailing Stop Using MA

The Moving Average can be an indicator that you can us as a trailing stop although I believe there are more suitable indicators.

With a Trailing Stop MA you can have the Stop Loss to follow the Moving Average Line.



Trailing Stop Using Fixed Step

This Trailing Stop is similar to the one that you can set in Metatrader but it only triggers at specific steps.

For example you could set a Trailing Stop that increments of 20pips.

So using the previous example. Long EURUSD open at 1.1200 and original stop 1.1180 with a 20pip step trailing stop.

When the price goes to 1.1220 then the stop moves to 1.1200.

If the price goes to 1.1240 then the stop moves to 1.1220 and so on.

The Stop Loss doesn’t move if the increment is less than 20 pips.

The price moves only on specific steps.



Trailing Stop Using ATR

The ATR indicator is the Average True Range.

It is a very popular indicator that traders use to understand volatility.

The ATR tells you how volatile the price has been in the recent candles.

You can use this indicator to set the stop loss and trailing stop.

For example if you see an ATR of value 30 you can expect the price to move up and down the current price of 30 pips in average.

This can help you setting a Stop Loss accordingly.

You can also set this as a value for your Trailing Stop.

Average rating:

Trailing Stop Using PSAR

The Parabolic SAR is also an indicator that can act as Trailing Stop.

This might be more suitable in strong moves and defined trends and probably not the best for ranging markets.



Trailing Stop Using Supertrend

Supertrend is one of my favourite indicators.

In my opinion this is one of the most suitable indicators for Trailing Stop.

The Supertrend has only a few options and can follow pretty well trend situations.

It is for this reason that it can often be an ideal solution for a trailing stop.



Trailing Stop Using Fractals

Fractals is another good indicator that can provide a good Trailing Stop value.

Fractals as you can see can be good levels of stop loss in trend situations.




In this article you learned about Trailing Stop and its importance in Risk Management strategies.

You also saw how to automate The Trailing Stop In Metatrader through Expert Advisors.

If you liked the article or have any question please leave a comment below or feel free to Contact Us.

2 thoughts on “How To Automate The Trailing Stop Loss In Metatrader With An EA”

    • The last instance of either the PSAR or Fractal becomes the stop loss and it stays that way if the indicator flips on the other side


Leave a Comment

We use cookies to ensure that we give you the best experience on our website.