UT Bot Alerts explained: what the code actually computes

UT Bot Alerts is a free, open-source TradingView script published by QuantNomad in 2020. It adds alerts to "UT Bot" by Yo_adriiiiaan, who credits HPotter for the original code. Because the code is open, nothing has to be guessed. It is about 40 lines and does one thing: it keeps an ATR trailing stop on the close and labels the bar where price crosses it.

What it computes

On every bar (our paraphrase, not the original code):

loss = Key Value x ATR(ATR Period)
price = close (or the Heikin Ashi close, if that option is on)
if price and previous price are both above the previous stop: stop = max(previous stop, price - loss)   (can only rise)
else if both are below it: stop = min(previous stop, price + loss)   (can only fall)
else (price has just crossed the previous stop): stop = price - loss if price is above it, otherwise price + loss
"Buy" label: the bar where price moves from below the stop to above it
"Sell" label: the reverse
bar colour: green above the stop, red below

Three details many write-ups get wrong:

What the settings change

There is no best setting. A pair that looks good on a chart was usually picked after looking at that chart. What you choose is how many ATRs of give-back you accept before the label changes side.

Does UT Bot Alerts repaint?

Heikin Ashi and backtests

UT Bot Alerts places no orders. QuantNomad's separate "UT Bot Strategy" runs the same logic, going long at each Buy label and reversing to short at each Sell. On a normal candle chart the Heikin Ashi option only changes when orders trigger; fills are still at real prices. Synthetic fills come from setting the chart itself to Heikin Ashi candles, unless "Fill orders using standard OHLC" is ticked in the strategy's properties. The published strategy also sets no commission or slippage.

UT Bot vs Supertrend

Both are ATR trailing stops that ratchet with the move, flip when a close crosses them, and have two states with no neutral one. The differences:

The audit version on TradingView

We rebuilt this stop from scratch and published it free and open source: Taught to Trade - ATR Trailing Stop with Flip Audit. At a distance of 1 and an ATR length of 10 on the close, it draws the same stop and the same flip bars as UT Bot Alerts. It adds what the original leaves out: the stop line drawn on the chart, fractional distances, flips confirmed only once the bar closes, Heikin Ashi computed consistently, and a panel that counts how many flips were undone within a few bars. That last number is the cost of a tight setting, on your own chart.

Where it fails

The Teardown Letter

The monthly Teardown Letter takes one popular indicator apart per issue in the same way: what it computes, what follows from the arithmetic, and where it misleads. Issues so far: RSI, MACD, order blocks, Fibonacci and Supertrend. New subscribers get every past issue.

Also explained: VWAP, Supertrend, RSI, UT Bot Alerts

Subscribe to the Teardown Letter: $19/moBack to Taught to Trade