UT Bot Alerts: The ATR Trail Behind the Signals
UT Bot Alerts is a free, open-source TradingView indicator that draws a trailing stop one 10-bar average true range from the close and prints Buy or Sell when the close crosses it. On default settings it signals often: 1,266 times on SPY's daily bars from 1993 to 2 October 2026.
UT Bot Alerts is a free community indicator on TradingView. This page reads its published source, rebuilds it line for line, and counts what the default settings do on real SPY bars, daily since 1993 and five-minute for the last 60 sessions.
How it works
The script is short. QuantNomad published UT Bot Alerts on 8 February 2020 as an open-source Pine Script version 4 study. Its description credits the original UT Bot to the TradingView user Yo_adriiiiaan and the idea of the original code to HPotter, and says this version adds alerts to QuantNomad’s earlier UT Bot strategy script.
It has three inputs. A Key Value (spelled “Key Vaule” in the script, described as the sensitivity), default 1; an ATR Period, default 10; and a switch to take signals from Heikin Ashi candles, off by default. This page describes the logic in its own words and does not republish the code.
The trail is the whole indicator. Each bar the script sets a loss distance equal to Key Value times the ATR, Pine’s built-in average true range over the ATR Period. Then:
- If this close and the last close are both above yesterday’s trail, the trail becomes the higher of yesterday’s trail and the close minus the loss distance, so it can only rise.
- If both closes are below yesterday’s trail, the trail becomes the lower of yesterday’s trail and the close plus the loss distance, so it can only fall.
- If the close has just crossed the trail, the trail jumps to the other side: close minus the distance after an upward cross, close plus the distance after a downward cross.
A Buy prints when the close crosses above the trail, and a Sell when it crosses below. The script’s two alert conditions are named “UT Long” and “UT Short”. The bars are also painted green above the trail and red below it.
That is an ATR trailing stop that always holds a side. It is close kin to the Supertrend, which builds its trail from the bar’s midpoint rather than from the close, and to the chandelier exit, which hangs its stop from the highest high.
A worked example
SPY in September 2026, default settings, daily bars. On 16 September SPY closed at $754.05, below that day’s trail of $760.5973, so the indicator was on a Sell.
On 17 September SPY closed at $762.60. That is above the previous trail, and the previous close was below it, so the close had crossed: a Buy. The 10-bar ATR that day was $6.8446, so the new trail was $762.60 minus $6.8446, or $755.7554.
Then the trail ratcheted up. On 21 September SPY closed at $773.50 with an ATR of $7.2808, and $773.50 minus $7.2808 is $766.2192, higher than $755.7554, so the trail rose to $766.2192. On 22 September the close of $773.38 minus an ATR of $6.8098 gave $766.5702, a little higher again. Through 25 September the closes stayed above it and the trail held at $766.5702.
On 28 September SPY closed at $765.61, below $766.5702: a Sell. The trail flipped to $765.61 plus the day’s ATR of $6.7332, or $772.3432. Four sessions later, on 2 October, SPY closed at $769.64 above the previous trail of $769.2236, and the indicator printed a Buy again.
That month shows the default’s character. From 1 September to 2 October 2026 it printed 8 signals, and the opposite signal came after 2, 2, 3, 2, 2, 7 and 4 sessions.
The original data
The rebuild. Every SPY daily bar from Yahoo Finance from 29 January 1993 to 2 October 2026, 8,477 bars, prices not adjusted for dividends. The ATR is the 10-bar true range smoothed the way Pine’s atr() function smooths it, a running average that starts from a simple average of the first 10. Signals follow the script’s buy and sell conditions exactly, on the close. SPY’s bars on a TradingView chart come from its own data feed, so a count made there can differ slightly.
- 1,266 signals: 633 Buys and 633 Sells, the first on 16 February 1993. Over 33.62 years that is 37.7 a year.
- The median gap between one signal and the next was 5 sessions (mean 6.7).
- The opposite signal came within 5 sessions after 718 of 1,265 signals (56.76%), and within 2 sessions after 295 (23.32%).
- From the first signal on, the indicator was on a Buy for 5,313 of 8,466 sessions (62.76%).
- In 2026 through 2 October it printed 27 signals.
Every signal is in the published signal table: date, side, close, trail, ATR, and the date and close of the next signal.
Key Value is the setting that matters. Over the same 8,477 bars, with the ATR Period left at 10:
| Key Value | Signals | Per year | Median sessions between | Opposite signal within 5 sessions |
|---|---|---|---|---|
| 1 (default) | 1,266 | 37.7 | 5 | 56.76% |
| 2 | 546 | 16.2 | 10 | 22.57% |
| 3 | 287 | 8.5 | 24 | 6.29% |
Doubling the Key Value cut the signal count by more than half, and tripling it cut the count to under a quarter. The quick reversals fell faster still. None of that says which setting is better; it says how much the defaults trade.
On five-minute bars the defaults fire many times a day. Over the 60 regular-hours sessions from 10 July to 2 October 2026, run as one continuous chart the way TradingView draws it, the default settings printed 562 signals: 9.37 a session, a median of 9, never fewer than 4 and as many as 14. The median gap was 6 bars, and 45.45% of signals met the opposite signal within 5 bars. Sixty sessions is a small sample, but it is the timeframe the script is most often shown on.
For comparison, the topic is thinly covered. In the 24,971 trading videos measured for this site, 5 have “UT Bot” in the title, at a median of 941 views.
What the settings change
Key Value moves the trail away from price. At 1 the trail sits one ATR from the close, about $6.82 on SPY on 2 October 2026; at 3 it sits three times that. A wider trail needs a larger move against the position before it flips.
ATR Period changes how fast the distance adapts. A shorter period lets one wide bar widen the trail quickly; a longer one smooths it.
Heikin Ashi signals change the price being tested. With the switch on, the script compares the trail with the Heikin Ashi close requested from the same chart, which is an average of the bar’s open, high, low and close, while the ATR still comes from the ordinary bars. On SPY’s daily bars that cut the count from 1,266 signals to 998. The other counts on this page use the switch off.
Setting alerts on it
The alerts fire on the script’s conditions, not on the painted labels. On TradingView you add the indicator, then create an alert and choose UT Long or UT Short as the condition; the TradingView alerts guide covers the steps. An alert set to fire once per bar close matches the counts on this page; one set to fire intrabar can trigger on a cross that the close later undoes.
When it fails
In a sideways market it flips back and forth. A 1-ATR trail is crossed by ordinary noise, which is why more than half of the daily signals met the opposite signal within a week of sessions.
On fast timeframes the cost line takes over. At the mean of 9.37 flips a session on five-minute SPY bars, 252 sessions come to about 2,361 flips, and every flip that is traded pays the spread.
A gap can carry price far past the trail. The trail is checked on the close, so a gap through it fills wherever the market opens, not at the trail.
And the signal is late by design. It needs a close beyond the trail, so the move has already run roughly one trail distance from the best close before the label appears.
Related
ATR trailing stop is the general rule this script packages. Supertrend is the closest relative, built from the bar’s midpoint. And ATR explains the volatility measure that sets the trail’s distance.
Before turning on any alert, count how many times it would have fired on the chart and timeframe you trade over the last year. Then multiply that by your round-trip cost. A UT Bot alert on default settings fires often enough that the cost line can matter more than the signal.
— Michael Whitman
This page is educational, not financial advice. Test every idea on your own charts before risking money.