Skip to content

Free MT5 indicator

ATR Trailing Stop

ATR-based trailing stop line for MT5 that ratchets with the trend, changes colour on direction flips and can alert on closed bars.

Trendv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Non-repainting signals Alerts

What it does

This indicator draws a single stop line that follows price at a distance based on the Average True Range. In an uptrend the line sits below price in green and can only move up; in a downtrend it sits above price in red and can only move down. When price closes through the line, the stop flips to the other side and an arrow marks the change.

It is useful both as a trend filter and as a guide for where a volatility-adjusted stop-loss could sit.

How it works

  • True range = the largest of: high - low, |high - previous close|, |low - previous close|.
  • ATR = previous ATR + (true range - previous ATR) / ATR period (Wilder smoothing).
  • Offset = multiplier x ATR.
  • If the current and previous close are both above the previous stop, the new stop = max(previous stop, close - offset).
  • If both closes are below the previous stop, the new stop = min(previous stop, close + offset).
  • Otherwise price has crossed the line: the stop resets to close - offset (if price is above) or close + offset (if below).
  • Direction is up when the close is above the stop, down otherwise. A flip arrow prints on the closed bar where the direction changes.

The live bar's line moves with price until the bar closes; arrows and alerts use closed bars only.

How to use it

As a trend filter, many traders only look for buy setups while the line is green and sell setups while it is red. As a trade-management tool, the line shows where a trailing stop would be if it were set at the chosen ATR multiple. A multiplier of 2 trails tightly and flips often; 3 to 4 gives trends more room.

Because the distance is measured in ATR, it adapts automatically to quiet and volatile instruments. Use the Position Size Calculator with the distance between your entry and the line to keep risk per trade consistent. For background on why volatility matters for stops, see the volatility lesson.

Settings

InputDefaultWhat it changes
ATR period14Smoothness of the volatility estimate
ATR multiplier3.0Larger values trail further away and flip less often
Show flip arrowstrueTurns the flip arrows on or off
Popup alert / Push notificationfalseAlerts once per bar on a closed-bar flip

Limitations

  • In sideways markets the line flips back and forth, producing a series of small losses if used as an entry signal.
  • The stop reacts after price moves; it will never exit at the top or bottom of a move.
  • A sudden volatility spike widens the ATR, but the ratchet rule keeps the stop from moving backwards.
  • The indicator does not place or modify orders; it only displays a level.

Key inputs

Key inputs of ATR Trailing Stop
InputDefaultDescription
ATR period14Bars used for the Wilder-smoothed Average True Range.
ATR multiplier3.0Distance of the stop from price in ATR units.
Show flip arrowstrueDraws an arrow on the bar where the stop changes side.
Popup alert on a direction flipfalseShows an MT5 alert once per bar when the trend flips.

Educational tools, not advice. Indicators and Expert Advisors describe price; they do not predict it, and past behaviour does not guarantee future results. Test everything on a demo account first and never risk money you cannot afford to lose. See our disclaimer.

Keep exploring

Related mt5 indicators