Contents
Following a moving average is another way to implement a trailing stop. Below you can download a free expert advisor for MetaTrader 4 that can adjust the stop-loss level of your trades by following a moving average with set parameters.
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.
A moving average is one of the simples and most popular indicators. It is often shorted as MA and is an average of the price of the last N candles. There are several types of moving averages available to traders. The most popular of them are simple and exponential.
In the chart screenshot below, you can see a purple line of a simple moving average with the period set to 25.
In MetaTrader 4 MQL4 language, the function to retrieve the value of a moving average is iMA()
.
The official documentation provides more information about using the iMA() function.
The expert advisor Moving Average Trailing Stop moves the stop-loss of the selected orders by assigning the value of the moving average of the previous candle.
It can be very useful in trending periods to follow the trend and cut losses.
Risk management is one of the most important aspect 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 MT4 MA Trailing Stop expert advisor, the stop-loss follows the moving average values.
There are several advantages of using MT4 MA Trailing Stop EA:
This expert advisor has the following input parameters to configure its operation and interface:
Warning! For the email and mobile notifications to work, you have to configure them in your platform beforehand. Native on-screen alerts do not require additional configuration.
The Expert Advisor is configured with the following rules:
It is important to remember that we want to move the stop-loss level always in the direction of the order and never to make it bigger than the initial distance. This helps us follow risk management rules.
You can see an ideal example of this expert advisor at work below. The trailing stop moves the stop-loss level after each candle following the moving average (red line).
You can download the expert advisor using the link below and install it by following the presented instructions.
➥ Download MQLTA MT4 Moving Average Trailing Stop
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.
To install the EA, please follow the instructions below:
Or you can read a more detailed instruction on how to perform the installation.
Using a trailing stop that follows a moving average can be ideal in a situation where there is a clear trend. This type of trailing stop will allow to follow the trend and to protect the order from unexpected spikes or reversals.
You can open a trading account with any of the MT4 Forex brokers to freely use the presented here expert advisor for MetaTrader 4.