WhitmanTrading

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:

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.

SPY daily closes from January to October 2026 with the UT Bot trail drawn as a stepped amber line and green and red markers at each of the 27 buy and sell signals.
SPY daily closes and the UT Bot Alerts trail on default settings (Key Value 1, ATR Period 10), 2 Jan to 2 Oct 2026, with its 27 signals marked. Source: Yahoo Finance, SPY daily bars (m63-spy-ut-bot-default-signals-1993-2026.csv).

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.

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.

Horizontal bars of UT Bot signals per year on SPY daily bars for Key Value 1, 2 and 3: 37.7, 16.2 and 8.5 a year, with median gaps of 5, 10 and 24 sessions.
UT Bot Alerts signals per year on SPY daily bars by Key Value, ATR Period 10, 16 Feb 1993 to 2 Oct 2026. Source: Yahoo Finance, SPY daily bars (m63-spy-ut-bot-default-signals-1993-2026.csv).

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.

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.

The practical check

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.