Skip to content

Free MT5 Expert Advisor

Chandelier Exit EA

MT5 Expert Advisor that trades Chandelier Exit direction flips with a 200 EMA filter, stop at the Chandelier line and optional trailing.

Trendv1.0MetaTrader 5 (MQL5) Compiles with 0 errors Non-repainting signals Stop-loss on every trade
Strategy
Buys when the Chandelier Exit flips from short to long on a closed bar while price is above the 200 EMA, and sells the mirror image. The stop-loss sits at the Chandelier line and can trail along it.
Risk model
1% of balance per trade (configurable), stop-loss on every order, one position at a time

What it does

The Chandelier Exit hangs a stop a few ATRs below the highest high of recent bars (for longs) or above the lowest low (for shorts). When price closes through the opposite line, the direction flips. This EA trades those flips, but only in the direction of the 200 EMA.

The active line becomes the stop-loss and, with trailing on, follows the trend as it makes new extremes.

How it works

The lines are rebuilt from the last 300 closed bars on each new bar:

  • Long line = highest high of the last 22 bars - 3 x ATR(22). Short line = lowest low of the last 22 bars + 3 x ATR.
  • The long line only rises while the previous close is above it; the short line only falls while it is below.
  • Direction turns long on a close above the previous short line and short on a close below the previous long line.
  • Buy: direction is long on the last closed bar and was short on the bar before, and that close is above the 200 EMA. Filtered flips are logged.
  • Sell: the mirror with the close below the EMA.
  • Stop-loss: the active line on the signal bar (plus an optional buffer). Signals with a stop more than 5 x ATR away are skipped.
  • Trailing: on every tick the stop moves to the latest closed-bar line if that improves it.
  • Exit: a flip against the position at a bar close closes it. No fixed target by default.

How to use it

Because the line hangs from the extreme rather than the bar midpoint, the Chandelier Exit gives trends more room than many trailing methods. It suits instruments that trend for long stretches, such as major pairs and gold on H1 and H4.

A lower multiplier trails tighter; a higher one stays in longer. The volatility lesson explains why ATR-based distances adapt to market conditions.

Settings

InputDefaultWhat it changes
ATR period22ATR length used for the Chandelier lines.
Highest high / lowest low lookback22Bars searched for the extreme the line hangs from.
Chandelier ATR multiplier3.0Distance of the line from the extreme, in ATRs.
Trend filter EMA period200Flips are taken only on the matching side of this EMA.
Take-profit (R multiple)0.0Optional fixed target; 0 lets the line manage the exit.
Maximum stop (x ATR)5.0Skips a flip if the line is unusually far from price.
Use trailing stoptrueMoves the stop to the Chandelier line as it advances.
Bars used to rebuild the lines300History used for the recursive calculation.
Extra stop buffer (points)0Places the stop slightly beyond the line.
Exit on fliptrueCloses the trade when the direction turns against it.
Risk per trade (% of balance)1.0Share of balance risked between entry and stop.
Fixed lots0Fixed volume instead of risk %; 0 = risk-based.
Maximum spread (points)20Skips signals when the spread is wider; 0 = off.
Trading start / end hour7 / 20Server-time window for new trades; equal values = 24 hours.
Move stop to break-eventrueStop to entry + 20 points once profit reaches 1R.
Magic number2611015Identifies this EA's trades.

Limitations

  • Flips come after the turn in price, so entries are late by design.
  • The stop is often wide, which means small position sizes or skipped signals.
  • In ranges the lines are crossed repeatedly and produce a series of losses.
  • The 200 EMA filter skips early trades in a new trend.

Before you run it live

Test on a demo account and in the MetaTrader 5 Strategy Tester over several years first. No backtest results are published for this EA, and any test describes the past only.

  • Match the spread limit and trading hours to your broker's spreads, stop level and session times, and include commission and swap in tests.
  • Start with 1% risk or less and check the lot sizes in the Experts log; the Position Size Calculator is a useful cross-check.
  • Use a different magic number on each chart, and keep the terminal (or a VPS) running so stops are managed.

Compare tester runs with trailing on and off.

Key inputs

Key inputs of Chandelier Exit EA
InputDefaultDescription
ATR period22ATR length used for the Chandelier lines.
Highest high / lowest low lookback22Bars searched for the extreme the line hangs from.
Chandelier ATR multiplier3.0Distance of the line from the extreme, in ATRs.
Trend filter EMA period200Flips are taken only on the matching side of this EMA.
Take-profit (R multiple)0.0Optional fixed target; 0 lets the line manage the exit.
Maximum stop (x ATR)5.0Skips a flip if the line is unusually far from price.
Use trailing stoptrueMoves the stop to the Chandelier line as it advances.

Educational tools, not advice. Automated trading can lose money quickly. 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 expert advisors