How to Trail Your Stop Loss Using a Moving Average
To trail a stop loss with a moving average, pick an MA that the trend respects (often the 20 EMA on your trading timeframe), and after each candle closes move your stop to just beyond that MA, minus a small buffer, but only in the direction of the trade, never backwards. Alternatively, exit when a candle closes on the wrong side of the MA. The method keeps you in trends longer than a fixed target, at the cost of giving back part of the move when the trend ends.
Key takeaways
- Choose one MA and one timeframe before the trade; the 20 EMA suits shorter trends, the 50 SMA or EMA slower ones.
- Place the stop a buffer beyond the MA, commonly a fraction of ATR, so normal noise does not stop you out.
- Update at candle close only, and only ever tighten the stop.
- "Stop at the MA" and "exit on a close beyond the MA" behave differently; pick one and test it.
- MetaTrader's built-in trailing stop is fixed-distance; MA trailing needs manual updates or an EA.
- Trailing does not remove gap risk, slippage or the reality that most retail leveraged accounts lose money.
Why trail with a moving average at all
A fixed take-profit caps every winner. A fixed-distance trailing stop, the kind built into most platforms, follows price by a set number of pips regardless of how the market is behaving. A moving average trail sits between the two: it follows the trend's own average, so in a steady trend it rises with price, and when the trend loses momentum price crosses it and the trade ends.
It also answers a practical question many traders struggle with: "when do I get out of a winner?" Without a rule, people tend to grab small profits quickly and hold losers. A mechanical MA trail removes that decision from the moment of emotion. If you are new to trailing stops in general, the trailing stop explainer covers the basic types first.
MA trails also pair well with adding to a winner. If you add a second position once the trend is established, a single MA-based stop for both positions keeps the total risk visible and defined. The guide on scaling into a winning trade works through how to keep combined risk within your limit when you do that, which matters more than the entry of the second position itself.
Step 1: choose the moving average
The right MA is the one price has been respecting during the current trend. Look back at the last few pullbacks. If they repeatedly stopped near the 20 EMA, that line is a reasonable trail. If they regularly pierced the 20 and held the 50, the 20 will stop you out too early.
| MA | Behaviour as a trail | Typical fit |
|---|---|---|
| 10 EMA | Very tight; exits on the first real pause | Momentum bursts, news-driven moves, short holds |
| 20 EMA | Balanced; common default | Swing trades on H1 to H4, steady trends |
| 50 EMA or SMA | Loose; survives deeper pullbacks | Longer swings on H4 and daily |
| 100 to 200 SMA | Very loose; gives back a lot | Position trades on daily or weekly charts |
EMAs react faster than SMAs of the same length because they weight recent prices more heavily, so an EMA trail tightens a little sooner. The EMA versus SMA guide shows the difference with numbers. Neither is objectively better for trailing; consistency matters more than the type.
Also match the timeframe. Trailing an H4 trade with the M15 20 EMA is effectively a very tight stop and will end the trade during normal intraday noise.
Step 2: decide the buffer
Price often pierces a moving average by a few pips before resuming the trend. A stop placed exactly on the MA gets taken by those wicks. A buffer solves this.
- ATR-based buffer: stop = MA − (0.25 to 0.5 × ATR) for a long. This scales with volatility. The ATR stop-loss guide explains the indicator.
- Fixed-pip buffer: for example 10 pips on H4 EUR/USD. Simple, but too tight on volatile pairs like GBP/JPY and too loose on quiet ones like EUR/CHF.
- Spread allowance: on short positions, remember that sell positions are closed at the ask, so the stop must sit above the MA by at least the spread or it will trigger on spread widening alone. This is a frequent cause of the puzzle covered in why stops get hit without price touching them.
Step 3: pick the exit style
There are two distinct ways to use an MA as a trail, and they produce different results.
Option A: hard stop beyond the MA
After each candle closes, move the stop-loss order to MA minus buffer (for longs). The order sits in the market, so an intrabar spike through the level closes the trade even if the candle later recovers.
Option B: exit on a close beyond the MA
Keep a wider protective stop in place (for example the original stop or the last swing low), and close the trade manually or by EA only when a candle closes beyond the MA. This ignores wicks but can exit at a worse price if the closing candle is large.
Option A is easier to automate and protects you if you are away from the screen. Option B tends to hold trends longer but requires discipline at every close. Many traders use B with a hard stop far enough away to cap disaster risk.
Worked example: a GBP/USD long on H4
A trader buys GBP/USD at 1.2600 after a pullback, with an initial stop at 1.2550 (50 pips, which is 1R). They trail with the H4 20 EMA minus a 10-pip buffer using Option A, moving the stop at each candle close, never lower.
| Candle close | Close price | 20 EMA | EMA − 10 pips | Stop after update | Locked-in result |
|---|---|---|---|---|---|
| Entry | 1.2600 | 1.2560 | 1.2550 | 1.2550 | −50 pips (−1R) |
| 1 | 1.2622 | 1.2570 | 1.2560 | 1.2560 | −40 pips |
| 2 | 1.2648 | 1.2585 | 1.2575 | 1.2575 | −25 pips |
| 3 | 1.2680 | 1.2602 | 1.2592 | 1.2592 | −8 pips |
| 4 | 1.2710 | 1.2625 | 1.2615 | 1.2615 | +15 pips |
| 5 | 1.2735 | 1.2650 | 1.2640 | 1.2640 | +40 pips |
| 6 | 1.2722 | 1.2668 | 1.2658 | 1.2658 | +58 pips |
| 7 | 1.2690 | 1.2680 | 1.2670 | 1.2670 | +70 pips |
| 8 | Price dips to 1.2665 intrabar; stop at 1.2670 fills. Result +70 pips, or +1.4R. | ||||
Three points stand out. The trade spent four candles at risk before the stop crossed break-even, which is normal for MA trails: they are slow to protect early. The peak close was 1.2735, so 65 pips of open profit were given back. And with a 0.20-lot position (a $10,000 account risking 1%, or $100, over 50 pips at $10 per pip per standard lot), the outcome was about $140 before costs. Had the trader used a fixed 1:1 target at 1.2650 the result would have been $100; had the trend run for another three days, the trail would have captured far more.
Trailing stops are not guaranteed exits. A stop-loss becomes a market order when triggered. Over a weekend gap or a fast news release, the fill can be well beyond your level. Only a guaranteed stop, which some brokers sell for a premium, removes that risk. Leverage magnifies these gaps; most retail forex and CFD accounts lose money, and no exit technique changes that on its own.
Doing it on MT4, MT5, cTrader and TradingView
- MetaTrader 4 and 5: the built-in trailing stop (right-click the position, Trailing Stop) follows price by a fixed number of points and only works while the terminal is running. It cannot follow an MA. Options are manual updates at each candle close, or an EA that modifies the stop based on the MA value. Many free MA-trailing EAs exist; test any on demo first, and see the guide to installing an expert advisor on MT4 if needed.
- cTrader: includes a trailing stop option on positions, also distance-based. MA logic requires a cBot.
- TradingView: you can set alerts when price closes below an MA, then manage the stop manually with your connected broker. Strategy scripts can also backtest an MA trail.
- VPS: if an EA manages your trail, it must run continuously. A home PC that sleeps will stop updating stops.
Testing which MA suits your trades
Take your last 50 to 100 trend trades, or replay historical setups, and apply three trails to the same entries: 20 EMA, 50 EMA and a fixed 2R target. Record for each:
| Measure | What it tells you |
|---|---|
| Average R per trade | Overall payoff of the exit method |
| Share of trades stopped below break-even | How often the trail is too tight early |
| Largest winner in R | Whether the trail catches the big trends |
| Average giveback from peak | Cost of waiting for the MA to be crossed |
The same entries can produce very different results by exit method alone. Many traders find that a looser trail lowers the win rate but raises average R, which is exactly the trade-off trend following accepts. The trend-following strategy guide explains why that profile is normal.
Common mistakes when trailing with an MA
- Moving the stop backwards. If the MA dips, the stop stays where it was. A trailing stop that loosens is not a trailing stop.
- Updating intrabar. The MA's current value changes with every tick. Moving the stop mid-candle chases noise. Use closed values.
- Switching MAs mid-trade. Changing from the 20 to the 50 because price is about to hit the 20 is moving the stop to avoid a loss. Decide before entry.
- Trailing in ranges. In a sideways market, price crosses the MA constantly, and every trail exits for a small loss. MA trailing is a trend tool.
- Forgetting the spread on shorts. Short stops trigger on the ask; spread widening at rollover can hit a stop sitting right at the MA.
- No hard stop in Option B. Exiting on a close is fine, but always keep a protective order in the market in case you are away or the platform disconnects.
Frequently asked questions
Which moving average is best for a trailing stop?
The one price has respected during the current trend on your trading timeframe. The 20 EMA is a common default for swing trades on H1 to H4, and the 50 EMA or SMA suits slower trends on H4 and daily. Test a few on your own past trades and choose before entry, not during the trade.
Should I place the stop exactly on the moving average?
Usually not. Price often pierces an MA briefly before the trend resumes, so a stop right on the line is taken by small wicks. Most traders add a buffer, such as a quarter to half of the ATR or a fixed number of pips, and allow for the spread on short positions.
Can MT4 trail a stop along a moving average automatically?
Not with the built-in trailing stop, which only follows price by a fixed distance. You need either to move the stop manually after each candle closes or to use an expert advisor that reads the MA value and modifies the stop. The EA must run continuously, which often means a VPS.
When should I start trailing with the moving average?
Some traders trail from entry; others wait until the trade reaches a set profit, such as 1R, or until the MA moves beyond the original stop. Starting later protects trades from being stopped out early but leaves the initial risk in place for longer. Test both on past trades.
Is trailing with a moving average better than a fixed take profit?
Neither is better in every case. MA trailing captures large trends but gives back profit and stops out more often near break-even. Fixed targets give steadier results but cap the winners. Your choice should come from testing on the pairs and timeframe you trade, using average R per trade rather than win rate.
Does a trailing stop protect against weekend gaps?
No. If the market opens beyond your stop after the weekend, the order fills at the first available price, which can be well past your level. Only a guaranteed stop-loss, offered by some brokers at extra cost, ensures the exact exit price. Reducing size before major weekend risks is the other option.
This article is general information, not personal financial advice. Figures such as spreads, fees, leverage and rules change; confirm them with the provider and check the provider is authorised for your country of residence.