- 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
| Input | Default | What it changes |
|---|---|---|
| ATR period | 22 | ATR length used for the Chandelier lines. |
| Highest high / lowest low lookback | 22 | Bars searched for the extreme the line hangs from. |
| Chandelier ATR multiplier | 3.0 | Distance of the line from the extreme, in ATRs. |
| Trend filter EMA period | 200 | Flips are taken only on the matching side of this EMA. |
| Take-profit (R multiple) | 0.0 | Optional fixed target; 0 lets the line manage the exit. |
| Maximum stop (x ATR) | 5.0 | Skips a flip if the line is unusually far from price. |
| Use trailing stop | true | Moves the stop to the Chandelier line as it advances. |
| Bars used to rebuild the lines | 300 | History used for the recursive calculation. |
| Extra stop buffer (points) | 0 | Places the stop slightly beyond the line. |
| Exit on flip | true | Closes the trade when the direction turns against it. |
| Risk per trade (% of balance) | 1.0 | Share of balance risked between entry and stop. |
| Fixed lots | 0 | Fixed volume instead of risk %; 0 = risk-based. |
| Maximum spread (points) | 20 | Skips signals when the spread is wider; 0 = off. |
| Trading start / end hour | 7 / 20 | Server-time window for new trades; equal values = 24 hours. |
| Move stop to break-even | true | Stop to entry + 20 points once profit reaches 1R. |
| Magic number | 2611015 | Identifies 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.

