ATR Trailing Stop Indicator: Three Times The Bar Range

Written by Dominic Walsh · Published · Last updated

The atr trailing stop indicator gives you a stop that moves with the market. It sits three range units from the middle of each bar. While the trend holds the line only tightens, and a close through it flips the whole thing.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from XAUUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Main price chart
Plots 4: Trail up, Trail down, Buy, Sell
Alerts popup, push notification, email, sound
Inputs 9

What the ATR Trailing Stop Indicator draws on the chart

`Trail up` runs lime green while the stop sits below price.

`Trail down` runs red while it caps price from above.

`Buy` prints arrow 233 at a flip up, and `Sell` prints 234 at a flip down.

Marks sit `ArrowOffsetPoints` `30` points from the candle.

  • Trail up: line, lime green, width 2
  • Trail down: line, red, width 2
  • Buy: arrow, lime, width 3, arrow code 233
  • Sell: arrow, red, width 3, arrow code 234
Atr trailing stop indicator ratcheting line and flip arrows on the XAUUSD H1 chart.
Atr trailing stop indicator ratcheting line and flip arrows on the XAUUSD H1 chart.

How the ATR Trailing Stop Indicator calculates its values

The midpoint anchors it

Each bar takes its high plus low over two. `Mult` `3.0` times the reading from `AtrPeriod` `10` then hangs a candidate stop either side of that midpoint.

Only one direction of travel

In an uptrend the code keeps the higher of the new candidate and the previous stop. So the line climbs or holds. A downtrend keeps the lower of the two instead.

The flip resets the stop

A close through the line reverses direction and jumps the stop to the opposite band. That reset is why the tool is always on one side or the other.

How to read the signals

The colour of the line is the current direction.

Distance between price and the line is your open risk on that idea.

`AtrPeriod` `10` is shorter than the usual fourteen, so the band reacts quickly.

The screenshot note picks XAUUSD, where the flips show clearly.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

`EnableAlerts` controls every flip alert and arrives true with `EnablePopup`. Switch `EnablePushNotify` for a phone buzz, `EnableEmail` for mail, or `EnableSound` to play `SoundFile`. Those three begin false. A side change reports once a bar.

Every ATR Trailing Stop Indicator input

Core settings

Setting What it does Default
AtrPeriod Window behind the range measure, default `10`. 10
Mult Range units between midpoint and stop, default `3.0`. 3.0

Display settings

Setting What it does Default
ArrowOffsetPoints How far a flip mark sits off the wick, in points, default `30`. 30

Alert settings

Setting What it does Default
EnableAlerts Single control over every flip alert, default `true`. on
EnablePopup Dialog box when the line changes sides, default `true`. on
EnablePushNotify Phone buzz when the line changes sides, default `false`. off
EnableEmail Email when the line changes sides, default `false`. off
EnableSound Audio cue when the line changes sides, default `false`. off
SoundFile Audio file the cue uses, default `”alert.wav”`. alert.wav
Atr trailing stop indicator inputs panel showing AtrPeriod and Mult.
Atr trailing stop indicator inputs panel showing AtrPeriod and Mult.

Settings that fit your chart

The screenshot note picks XAUUSD H1, where gold trends hard enough to show the ratchet. EURUSD H1 gives a slower version. Higher timeframes turn this into a position tool with very few flips.

When the ATR Trailing Stop Indicator fails

Three range units is wide, so a flip gives back a lot of the move.

A sideways market flips the line repeatedly and each flip costs.

`AtrPeriod` `10` reacts quickly, which can tighten the stop into noise.

Copy the compiled ATR Trailing Stop Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Download the ATR Trailing Stop Indicator for MT4 and MT5

The zip holds the compiled ATR Trailing Stop Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

Why does Mult 3.0 use the bar midpoint?

Because the midpoint is steadier than the close. Hanging the band from high plus low over two means a single sharp close cannot drag the stop, which keeps the ratchet smoother.

What makes the Trail up line ratchet?

While direction reads up, the code keeps whichever is higher between the new candidate stop and the previous one. That rule means the line can only rise, which turns it into a trailing stop.

How does AtrPeriod 10 differ from 14?

Ten bars reacts faster to a change in conditions, so the band narrows sooner after a quiet stretch begins. That gives tighter stops and slightly more flips than the more common fourteen.

Can I use this line as an actual stop?

Many traders do, and that is what it was built for. Bear in mind it moves every bar and it is wide at three range units, so position size has to account for that distance.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the ATR Trailing Stop Indicator as one input. Always backtest before trading live.

Category: this is part of our Volatility collection. Thus, truly, yet, browse more Volatility for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment