Trailing Stop Loss Smart Indicator: A Chandelier Stop

Written by Dominic Walsh · Published · Last updated

The trailing stop loss smart indicator draws a stop that only ever moves in your favour. It anchors to the highest high or lowest low of the last `ChannelPeriod` bars, backs off by `AtrMult` times ATR, and refuses to loosen. When price closes through the active line, the stop flips to the other side.

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

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Main price chart
Plots 4: Long Stop, Short Stop, Buy Flip, Sell Flip
Alerts popup, push notification, email, sound
Inputs 11

What the Trailing Stop Loss Smart Indicator draws on the chart

Long Stop is the lime green line trailing below price while the trend reads long.

Short Stop is the orange red line trailing above price while it reads short.

Buy Flip and Sell Flip mark the bar where the direction changed.

`ShowFlipArrows` turns those marks off if you want the lines on their own.

  • Long Stop: line, lime green, width 2
  • Short Stop: line, orange red, width 2
  • Buy Flip: arrow, lime green, width 2, arrow code 233
  • Sell Flip: arrow, orange red, width 2, arrow code 234
Trailing stop loss smart indicator on EURUSD H1 with the ratcheting chandelier line
Trailing stop loss smart indicator on EURUSD H1 with the ratcheting chandelier line

How the Trailing Stop Loss Smart Indicator calculates its values

Measuring the stop distance

tr holds the true range for each bar. The first ATR value takes a plain mean over `AtrPeriod` `22` bars, and later bars use Wilder smoothing. dist then takes `AtrMult` `3.0` times that ATR. So the stop always sits three average ranges away from its anchor.

Anchoring to the channel

hh and ll scan `ChannelPeriod` `22` bars for the highest high and the lowest low. longBasic takes hh minus dist and shortBasic takes ll plus dist. That pairing is the chandelier arrangement: the stop hangs from the extreme of the recent range rather than from the current close.

Ratcheting and flipping

While the previous close sat above the long stop, longF takes the higher of the new value and the old one. The short side takes the lower. Neither line can retreat. A flip needs a close through the opposite line, at which point the code switches TrendBuf and marks the bar.

How to read the signals

One line shows at a time, and its colour tells you the current direction.

The gap between price and the line is roughly three ATR at the moment of a flip.

A line that has stopped rising means the channel extreme has stopped extending.

Flips cluster in a range, which is the honest signature of any trailing stop.

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

`EnableAlerts` ships on with `EnablePopup` carrying the message. `EnablePushNotify`, `EnableEmail` and `EnableSound` are off by default, and `SoundFile` names the clip. The flip check runs on a closed bar, so one message follows each completed bar.

Every Trailing Stop Loss Smart Indicator input

Core settings

Setting What it does Default
AtrPeriod ATR length for the stop distance. Bars in the ATR average, default `22`. 22
AtrMult ATR multiplier (stop distance). Stop distance in ATR units, default `3.0`. Lower it for a tighter stop and more flips. 3.0
ChannelPeriod Highest/Lowest lookback for the anchor. Bars scanned for the anchor extreme, default `22`. Widen it to hang the stop from an older high or low. 22

Display settings

Setting What it does Default
ArrowGapPts Arrow gap from the bar (in points). Flip mark clearance from the bar in points, default `12`. 12
ShowFlipArrows Draw arrows on each trend flip. Draws a mark on each flip, default `true`. on

Alert settings

Setting What it does Default
EnableAlerts Master alert switch, default `true`. on
EnablePopup Terminal popup, default `true`. on
EnablePushNotify Mobile push, default `false`. off
EnableEmail Mail delivery, default `false`. off
EnableSound Sound playback, default `false`. off
SoundFile Clip played when sound is on, default `alert.wav`. alert.wav
Trailing stop loss smart indicator inputs: AtrPeriod, AtrMult, ChannelPeriod
Trailing stop loss smart indicator inputs: AtrPeriod, AtrMult, ChannelPeriod

Settings that fit your chart

A ratcheting stop rewards markets that run. EURUSD H1 is the reference chart, where `ChannelPeriod` at `22` covers roughly a day of bars. On M5 the line flips often enough to be tiring. On H4 and daily the stop holds through pullbacks, which is what a three-ATR distance is designed for.

When the Trailing Stop Loss Smart Indicator fails

A trailing stop cannot anticipate. It only ever reacts to a close that has already happened.

In a sideways market the line flips back and forth and gives up its distance each time.

`AtrMult` at `3.0` is generous. A tighter setting exits sooner but flips far more often.

Copy the compiled Trailing Stop Loss Smart 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.

Related on forexmt4systems.com: Smart Money Concepts Strategy.

Download the Trailing Stop Loss Smart Indicator for MT4 and MT5

The zip holds the compiled Trailing Stop Loss Smart 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

What does AtrMult at 3.0 actually set?

The distance between the anchor and the stop, measured in average true ranges. At `3.0` on a chart where ATR reads 20 pips, the line sits 60 pips from the channel extreme. Lower it for a tighter stop that flips more often, or raise it to sit through deeper pullbacks.

Why does ChannelPeriod anchor the line?

Because a chandelier stop hangs from a recent extreme rather than from the current price. hh and ll scan `ChannelPeriod` `22` bars for that extreme, then the ATR distance comes off it. Widening the period hangs the stop from an older high or low, which loosens it.

Can the Long Stop line ever move down?

No, not while the trend reads long. longF takes the higher of the freshly calculated value and the previous one, so the line can hold or rise but never retreat. It only leaves that position when price closes through it and the direction flips.

What turns off the Buy Flip marks?

Set `ShowFlipArrows` to false. The Long Stop and Short Stop lines carry on exactly as before, and the alerts still fire. That suits a chart where you want the trailing line as a visual reference without extra symbols cluttering the candles.

Are results guaranteed?

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

Category: this is part of our Trend collection. Browse more Trend 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