All scripts
Pro Β· Invite-only on TradingView
Free Β· Open source
ATR Trailing Stop
A stop that breathes with volatility β for long and short, with fewer false flips in sideways phases.
- Type
- Trailing stop + exit reference
- Replaces
- ATR Β· Supertrend
- Recommended
- 4h and daily chart
- Price
- Free, open source
ATR Trailing Stop trails a stop behind price whose distance follows the current volatility: tighter in quiet phases, wider in wild ones. It only moves in the direction of the trade, switches sides when price closes beyond it, and requires extra distance in sideways phases before it flips. A small table shows you the current stop distance in ATR and percent. This page explains every feature β and above all, what you do with it and why.
Overview
At a glance
What does it do?
It draws a stop below price (long, green) or above price (short, red) whose distance depends on volatility and which only moves in the direction of the trade.
What do I do with it?
You use the line as the exit for running trades, as a reference for the initial stop and β via the stop distance β for position sizing.
Why?
A fixed percentage stop ignores how much a market is currently swinging. Too tight, and normal noise throws you out. Too wide, and you give back too much. ATR adapts the distance to the market.
What do I get?
Clear, rule-based exits instead of gut feeling β and stops that fit the current market, not a number you set weeks ago.
On your chart in 3 minutes
Quickstart
- 01
Open the script page
The button at the top of this page takes you to the script page on TradingView. The script is free and open source β you can read the code there too.
- 02
Add it to your favorites
On the script page, click Add to favorites (the star icon).
- 03
Add it to your chart
At the top of the chart, click Indicators, choose Favorites on the left and click ATR Trailing Stop. Alternatively, search for βIndicatrβ in the same window.
- 04
Pick a market and timeframe
Start with a market that forms trends, for example Bitcoin, gold or a large-cap stock, on 4h or the daily chart. The defaults (ATR 14 Γ 3, lookback 22) are the classic chandelier values.
The chart explained
What you see on the chart
- 1Long stop Green line below price: direction long. It moves up as price rises.
- 2Short stop Red line above price: direction short. It moves down as price falls.
- 3Turned long Triangle below the candle: price closed above the short stop, the direction is now long.
- 4Turned short Triangle above the candle: price closed below the long stop, the direction is now short.
- 5Table Direction, stop distance in ATR and percent, status of the range filter.
Elements 1 and 2
The stop line: distance based on volatility
The line always sits a volatility-based distance away from price β below it when long, above it when short.
What does it do?
In chandelier style (default) the line hangs from the highest high of the recent candles, a few ATR below it β for shorts, mirrored from the lowest low. In midpoint style it hangs from the middle of the candle, similar to a Supertrend. The line only moves in the direction of the trade.
What do I do with it?
You use the line as your exit: if price closes on the wrong side, the trade is over according to this rule. For a new trade, it gives you the distance for the initial stop.
Why?
ATR measures the average candle size. A stop three ATR away sits outside normal noise β it only gets hit when something really changes.
What do I get?
You let winners run without constantly trailing the stop by gut feeling, and you donβt give back more than the marketβs volatility justifies.
| Style | Behavior | Suits |
|---|---|---|
| Chandelier (default) | Hangs from the extreme of the recent candles. After a new high (or low) the stop follows immediately; in consolidations it stays put. | Trend trades you want to let run for a long time. |
| Midpoint | Hangs from the middle of the current candle, similar to a Supertrend. | Traders used to a Supertrend-like stop. |
Elements 3 and 4
Direction changes and the range filter
When price closes beyond the stop, the line switches sides β long becomes short and vice versa. The triangles mark these moments.
What does it do?
A flip happens when price closes on the other side of the stop. If ADX shows no trend, the range filter requires extra distance β half an ATR by default β before the direction changes.
What do I do with it?
A flip against your trade is your exit. A flip into the new direction is not automatically an entry β it only shows that the old trend is over according to this rule.
Why?
In sideways phases price swings around the stop. Without a filter the line keeps jumping back and forth, and every flip costs spread and nerves.
What do I get?
Fewer false flips in sideways phases β and still clear exits as soon as a trend really breaks.
Element 5
The table: stop distance in ATR and percent
| Row | What it tells you |
|---|---|
| Direction | Current direction: Long (green) or Short (red). |
| Stop distance | Distance from the current price to the stop β in ATR and as a percentage of price. |
| Range filter | Active (no trend): ADX is below the threshold, a flip needs extra distance. Off (trending): the market is trending, the line flips without extra distance. |
In practice
How to work with the script
- 01
Enter with your own method
The script deliberately gives no entry signals. You enter with your own setup β for example a pullback in a trend.
- 02
Read the initial stop
If the line points in your trade direction, itβs a sensible initial stop. If it points the other way, youβre trading against the current direction β then you need your own stop and a good reason.
- 03
Calculate position size
Position size follows from the stop distance in percent and your risk per trade (for example 0.5 to 1% of the account).
- 04
Trail the stop
After each finished candle, move your stop at the broker to the new value of the line β only in the trade direction, never back.
- 05
Exit
If price closes beyond the line, the trade is over according to the rule. An alert on Turned long or Turned short lets you know.
Recommendations
Which markets fit β and which donβt
A trailing stop earns in trends and loses in sideways phases. So what matters is whether a market forms lasting trends β and whether it trades without big gaps, so the stop triggers where it sits. Volume plays no role for the script.
| Market | Timeframe | Fit | Why |
|---|---|---|---|
| Bitcoin | 4h, daily | Strong, long trends. Trades around the clock, so no overnight gaps. ATR adapts the distance to the high volatility. | |
| Gold | 4h, daily | Long, macro-driven trends lasting months. Very liquid. | |
| Large-cap stocks (e.g. NVIDIA, Apple) | Daily | Good trends, but earnings and news create overnight gaps that jump over the stop. | |
| S&P 500 / Nasdaq | Daily | Long uptrends, but fast, deep pullbacks. Intraday, indices often revert to the middle. | |
| EUR/USD | Daily | Trends build over weeks, not hours. Lots of back and forth on small timeframes. | |
| GBP/NZD | all | Long sideways phases with sudden spikes β many false flips, plus wide spreads. |
Assessment based on market characteristics and behavior on the chart, not a backtest. βββ good fit, βββ with limitations, βββ difficult.
Good examples: Bitcoin and gold
Bitcoin
4h and daily chart
- Long trends: Bitcoin often moves in one direction for weeks. Thatβs exactly when a trailing stop pays off β as in November 2026 on the chart above.
- No overnight gaps: trading runs around the clock, so the stop usually triggers where it sits.
- High volatility: a fixed percentage stop would constantly be too tight or too wide here. ATR adapts.
- But: sideways phases like late September happen here too β then the line flips often.
Gold
Daily chart and 4h
- Macro trends: the dollar, real yields and central-bank buying often drive gold in one direction for months.
- High liquidity and more even candles than Bitcoin β the stop works more calmly.
Bad example: GBP/NZD
GBP/NZD
all timeframes
- Sideways instead of trend: the pair often swings back and forth for weeks. Price crosses the stop again and again β even the range filter canβt prevent every flip.
- Two central banks and a commodity currency pull in different directions. Short spikes flip the direction without a trend following.
- Thin and expensive: wide spreads make every false flip even more costly.
Stocks through earnings
Daily chart
- Trends are often clean β but a gap after earnings can open far beyond the stop.
- The stop on the chart is then only theory; the fill is much worse.
- Tip: reduce the position or take profits before earnings.
Which timeframe?
- Daily chart: the calmest. Few flips, big trends, good for swing trades over weeks.
- 4h: a good compromise for active traders, especially on Bitcoin and gold.
- 1h: more flips, more costs. Only with a clear trend on the higher timeframe.
- Below 1h: noise, session opens and spread lead to many false flips. If at all, then with a higher multiplier.
Both directions
Long and short
The script is always either long or short. When long, the green line sits below price and moves up; when short, the red line sits above price and moves down. In the Bitcoin example you can see a clean short in November 2026: the red line follows falling price step by step.
The part that makes the difference
How to manage the trades
Before the entry
- Trend or range? If triangles have piled up over recent weeks, the market is moving sideways. Then a trailing stop is expensive.
- Check the calendar. Before central-bank decisions, jobs and inflation data or earnings, price can jump over your stop.
- Check intermarket. Gold reacts to the dollar and real yields, tech stocks to bond yields, Bitcoin to risk sentiment in equity markets.
- Size the position from the stop. Always the same risk per trade. The script deliberately doesnβt calculate the size β the free Risk & Position Planner does that.
While the trade is running
- Only trail the stop in the trade direction. Never move it back βbecause the market is about to turnβ.
- Consider partial profits. If you take part off at a first target, you can hold the rest more calmly until the trailing stop.
- Watch the table. When the distance in ATR gets very small, price is close to the stop β a normal swing is then enough to exit.
Over weeks and months
- Many flips in a row? Then the market has turned from trend to sideways. Pause instead of readjusting.
- Note how much each trade gave back before the exit. That shows you whether your multiplier fits your market.
Donβt miss a thing
Setting up alerts
- 01
Open the alert window
At the top of the chart, click Alert or press
Alt + A. - 02
Choose the condition
Under Condition, select βATR Stop [Indicatr]β and below it the alert you want.
- 03
Trigger
Choose βOnce per bar closeβ β the line and direction can still change on the current candle.
- 04
Notification
Choose app, email or webhook and save.
| Alert | When it fires |
|---|---|
| Turned long | The direction changes from short to long: price closed above the short stop (with an active range filter, plus the extra distance). |
| Turned short | The direction changes from long to short: price closed below the long stop. |
Reference
All settings
Double-click the name βATR Stopβ at the top left of the chart to open the settings. Everything is on one page in three groups: Stop, Range filter and Display.
Stop, range filter and display
- Stop styleDefault: Chandelier (highest/lowest)
- Chandelier: the stop hangs from the highest high (long) or lowest low (short) of the recent candles. Midpoint (hl2, Supertrend-like): the stop hangs from the middle of the current candle and behaves much like a Supertrend.
- ATR lengthDefault: 14
- Over how many candles the average candle size is measured. Shorter = the distance adapts faster to new volatility.
- ATR multiplierDefault: 3
- The most important setting: the stop distance in ATR. Higher = more room, fewer flips, but more give-back. Lower = tighter, more stop-outs.
- Chandelier lookbackDefault: 22
- How many candles the chandelier style looks back for the highest high and lowest low. Chandelier style only.
- Chandelier: use closes instead of highs/lowsDefault: off
- Uses closes instead of highs and lows as the reference. Individual long wicks then no longer pull the stop along. Chandelier style only.
- Require extra distance to flip when not trendingDefault: on
- The range filter: if ADX shows no trend, a flip needs extra distance. When off, the line flips on every close beyond the stop β and the table then always shows βOff (trending)β.
- ADX lengthDefault: 14
- Period for the trend strength the range filter uses to decide.
- ADX trend thresholdDefault: 20
- Below this ADX the market counts as not trending, and the extra distance applies. Higher = the filter kicks in more often.
- Extra flip distance (x ATR)Default: 0.5
- How far beyond the stop price must close in sideways phases. Higher = fewer false flips, but later exits on real reversals. At 0 the filter has no effect.
- Long stop Β· Short stopDefault: Green / Red
- Colors of the line and the triangles.
- Mark direction changesDefault: on
- Show or hide the triangles at each direction change. The alerts stay active.
- Show stop distance (ATR / %)Default: on
- Show or hide the table at the top right.
From practice
Common mistakes
- Taking every flip as an entry. A triangle says the old trend is over according to this rule β not that a new one is starting.
- Moving the stop back. If you ignore the line βjust this onceβ, you no longer have a trailing stop.
- Too tight a multiplier. With 1 or 1.5 ATR youβll constantly get stopped out on normal pullbacks.
- Using a trailing stop in sideways phases. Lots of triangles close together cost money on every flip.
- Forgetting gaps. Overnight, over the weekend or after earnings, price can open far beyond the stop.
- Not placing the stop at the broker. A stop that only exists on the chart doesnβt protect you.
FAQ
Does the script repaint?
No. On the current candle the line can still move and the direction can change. Once the candle closes, the line and triangles are fixed.
Whatβs the difference from Supertrend?
The midpoint style behaves much like a Supertrend. The default chandelier style, on the other hand, hangs from the extreme of the recent candles and follows new highs or lows immediately. On top of that come the range filter against false flips and the table with the stop distance.
Why does the line still flip so often in sideways phases?
The range filter requires extra distance but doesnβt prevent flips. If price swings far enough back and forth, the line still flips. Thatβs a sign the market isnβt trending right now.
Does the script give entry signals?
No, deliberately not. The triangles mark direction changes of the stop. For the entry you need your own setup β the script gives you the stop and the distance for it.
Which multiplier is right?
3 is the classic value for 4h and daily charts. For short-term trades 2 to 2.5 can fit, for very volatile markets even more. Check it on your marketβs chart: how often would you have been stopped out on normal pullbacks?
Is the script really free?
Yes. ATR Trailing Stop is free and open source on TradingView. The button on this page takes you to the script page. After Add to favorites youβll find it on the chart under Indicators β Favorites.
How do you like ATR Trailing Stop?
Your vote tells us what to work on next.
Support
Report a problem or share feedback
Something off with the script, unclear in the docs, or you have an idea? Write to us. We reply by email.
ATR Trailing Stop
Volatility-based trailing stop for long and short with a range filter against whipsaw flips and a live readout of the stop distance.
For educational and analytical purposes only. Not financial advice. Stops, direction changes and marks are not recommendations to buy or sell. Past behavior is no guarantee of future results. Trading involves a risk of loss.