Indicator · Pine Script v6 · On the chart

UT Bot Alerts 2026 Elite Edition

by qtu11· code credited to Jahigginsenterprises

A price-chart indicator based on the UT Bot ATR trailing stop, with separate buy and sell engines that each have their own key value and ATR period, so long and short signals can react at different speeds.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code160
Settings12inputs
LicenceNone statedfile: MPL-2.0
Last update2 months ago20 Aug 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

160 lines of Pine Script v6 from src/app/indicator/UT Bot Alerts.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

UT Bot Alerts.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Jahigginsenterprises
// Original Logic Credit: QuantNomad

//@version=6
indicator("UT Bot Alerts [2026 Elite Edition]", shorttitle="UT Bot 2026", overlay=true, max_labels_count=500, max_lines_count=500)

// ══════════════════════════════════════════════════════════════════════════════
// 1. CONFIGURATION & INPUTS
// ══════════════════════════════════════════════════════════════════════════════

// Group: Buy Settings
grp_buy    = "🟢 BUY SETTINGS (Long)"
buy_key    = input.float(2.0, "Buy Key Value (Sensitivity)", minval=0.1, group=grp_buy, tooltip="Multiplier for the Buy Signal calculation.")
buy_atr    = input.int(300, "Buy ATR Period", minval=1, group=grp_buy, tooltip="Lookback period for Buy signals. Higher = Slower/Smoother.")
buy_col    = input.color(color.new(#00E676, 0), "Buy Line Color", group=grp_buy)
buy_shape  = input.string("Label Up", "Buy Signal Shape", options=["Label Up", "Triangle Up", "Arrow Up", "Diamond"], group=grp_buy)

// Group: Sell Settings
grp_sell   = "🔴 SELL SETTINGS (Short)"
sell_key   = input.float(2.0, "Sell Key Value (Sensitivity)", minval=0.1, group=grp_sell, tooltip="Multiplier for the Sell Signal calculation.")
sell_atr   = input.int(1, "Sell ATR Period", minval=1, group=grp_sell, tooltip="Lookback period for Sell signals. Lower = Faster/Responsive.")
sell_col   = input.color(color.new(#FF5252, 0), "Sell Line Color", group=grp_sell)
sell_shape = input.string("Label Down", "Sell Signal Shape", options=["Label Down", "Triangle Down", "Arrow Down", "Diamond"], group=grp_sell)

// Group: General Settings
grp_gen    = "⚙️ GENERAL & VISUALS"
use_ha     = input.bool(false, "Use Heikin Ashi Candles", group=grp_gen, tooltip="Calculates signals based on Heikin Ashi Close rather than standard Close.")
show_dash  = input.bool(true, "Show Info Dashboard", group=grp_gen)
line_width = input.int(2, "Trailing Stop Line Width", minval=1, maxval=5, group=grp_gen)
bar_paint  = input.bool(true, "Color Candles", group=grp_gen)

// ══════════════════════════════════════════════════════════════════════════════
// 2. SMART CALCULATIONS (Dual Engine)
// ══════════════════════════════════════════════════════════════════════════════

// Source Handling (Standard vs Heikin Ashi)
// In v6, we prefer request.security only if strictly necessary, but for HA on same timeframe, 
// using the ticker's HA variant is the cleanest method.
ticker_id = use_ha ? ticker.heikinashi(syminfo.tickerid) : syminfo.tickerid
src = request.security(ticker_id, timeframe.period, close, lookahead = barmerge.lookahead_off)

// Engine 1: Buy Logic (Waiting for Price to cross UP)
// We use the Buy Parameters to calculate the "Ceiling" (Resistance)
xATR_Buy  = ta.atr(buy_atr)
nLoss_Buy = buy_key * xATR_Buy

// Engine 2: Sell Logic (Waiting for Price to cross DOWN)
// We use the Sell Parameters to calculate the "Floor" (Support)
xATR_Sell  = ta.atr(sell_atr)
nLoss_Sell = sell_key * xATR_Sell

// ══════════════════════════════════════════════════════════════════════════════
// 3. STATE MACHINE
// ══════════════════════════════════════════════════════════════════════════════

var float xATRTrailingStop = 0.0
var int pos = 0

// Current Stop Logic:
// If we are LONG (pos=1), we use the SELL parameters (Floor) to trail price up.
// If we are SHORT (pos=-1), we use the BUY parameters (Ceiling) to trail price down.

float prev_stop = nz(xATRTrailingStop[1])
int prev_pos    = nz(pos[1])

// Dynamic switching logic
if prev_pos == 1 // Currently Long
    // Use Sell Engine for the Floor
    float new_floor = src - nLoss_Sell
    if src < prev_stop // Stop Hit! Switch to Short
        xATRTrailingStop := src + nLoss_Buy // Initialize Ceiling
        pos := -1
    else // Still Long, trail up
        xATRTrailingStop := math.max(prev_stop, new_floor)
        pos := 1
else // Currently Short (or start)
    // Use Buy Engine for the Ceiling
    float new_ceiling = src + nLoss_Buy
    if src > prev_stop // Stop Hit! Switch to Long
        xATRTrailingStop := src - nLoss_Sell // Initialize Floor
        pos := 1
    else // Still Short, trail down
        xATRTrailingStop := math.min(prev_stop, new_ceiling)
        pos := -1

// ══════════════════════════════════════════════════════════════════════════════
// 4. SIGNALS & PLOTTING
// ══════════════════════════════════════════════════════════════════════════════

// Detection
bool buy_signal  = pos == 1 and prev_pos == -1
bool sell_signal = pos == -1 and prev_pos == 1

// Dynamic Colors
color current_color = pos == 1 ? buy_col : sell_col
color text_col_dyn  = color.white

// Plot Trailing Stop Line
plot(xATRTrailingStop, "Trailing Stop", color=current_color, linewidth=line_width, style=plot.style_line)

// Candle Coloring
barcolor(bar_paint ? current_color : na)

// Helper for Shapes
get_shape(style_str) =>
    switch style_str
        "Label Up"      => shape.labelup
        "Label Down"    => shape.labeldown
        "Triangle Up"   => shape.triangleup
        "Triangle Down" => shape.triangledown
        "Arrow Up"      => shape.arrowup
        "Arrow Down"    => shape.arrowdown
        "Diamond"       => shape.diamond
        => shape.circle

// Plot Buy Signal
plotshape(buy_signal, title="Buy Signal", style=get_shape(buy_shape), location=location.belowbar, color=buy_col, text="BUY", textcolor=text_col_dyn, size=size.tiny)

// Plot Sell Signal
plotshape(sell_signal, title="Sell Signal", style=get_shape(sell_shape), location=location.abovebar, color=sell_col, text="SELL", textcolor=text_col_dyn, size=size.tiny)

// ══════════════════════════════════════════════════════════════════════════════
// 5. DASHBOARD (2026 Feature)
// ══════════════════════════════════════════════════════════════════════════════

var table hud = table.new(position.top_right, 2, 4, bgcolor=color.new(color.black, 50), border_width=1)

if show_dash and barstate.islast
    // Header
    table.cell(hud, 0, 0, "UT BOT 2026", text_color=current_color, text_size=size.small, bgcolor=color.new(color.black, 0))
    table.merge_cells(hud, 0, 0, 1, 0)
    
    // Status
    table.cell(hud, 0, 1, "Status:", text_color=color.white, text_size=size.small, text_halign=text.align_left)
    table.cell(hud, 1, 1, pos == 1 ? "LONG 🟢" : "SHORT 🔴", text_color=current_color, text_size=size.small, text_halign=text.align_right)
    
    // Stop Price
    table.cell(hud, 0, 2, "Stop Price:", text_color=color.white, text_size=size.small, text_halign=text.align_left)
    table.cell(hud, 1, 2, str.tostring(xATRTrailingStop, format.mintick), text_color=color.gray, text_size=size.small, text_halign=text.align_right)
    
    // Active ATR
    float active_atr = pos == 1 ? xATR_Sell : xATR_Buy
    table.cell(hud, 0, 3, "Active ATR:", text_color=color.white, text_size=size.small, text_halign=text.align_left)
    table.cell(hud, 1, 3, str.tostring(active_atr, format.mintick), text_color=color.gray, text_size=size.small, text_halign=text.align_right)

// ══════════════════════════════════════════════════════════════════════════════
// 6. ALERTS
// ══════════════════════════════════════════════════════════════════════════════

// Legacy Alerts (for simple setup)
alertcondition(buy_signal, "UT Bot Buy", "UT Bot Buy Signal Detected")
alertcondition(sell_signal, "UT Bot Sell", "UT Bot Sell Signal Detected")

// Dynamic Alerts (JSON format for bots)
if buy_signal
    alert('{"type": "buy", "price": ' + str.tostring(close) + ', "ticker": "' + syminfo.ticker + '"}', alert.freq_once_per_bar_close)

if sell_signal
    alert('{"type": "sell", "price": ' + str.tostring(close) + ', "ticker": "' + syminfo.ticker + '"}', alert.freq_once_per_bar_close)

Overview

Signals print as selectable label, triangle, arrow or diamond shapes, and the trailing line and candles can be coloured. Heikin Ashi input is optional and an information dashboard can be shown. Alerts are included.

Details

Published by

qtu11 on GitHub

Code credit

Jahigginsenterprises, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Buy Key Value (Sensitivity)float2.0buy_key
Buy ATR Periodint300buy_atr
Buy Line Colorcolorcolor.new(#00E676, 0)buy_col
Buy Signal ShapestringLabel Upbuy_shape
Sell Key Value (Sensitivity)float2.0sell_key
Sell ATR Periodint1sell_atr
Sell Line Colorcolorcolor.new(#FF5252, 0)sell_col
Sell Signal ShapestringLabel Downsell_shape
Use Heikin Ashi Candlesboolfalseuse_ha
Show Info Dashboardbooltrueshow_dash
Trailing Stop Line Widthint2line_width
Color Candlesbooltruebar_paint
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Chandelier Exit

by everget
947 stars

This indicator plots an ATR-based Chandelier Exit trailing stop on the price chart. It tracks a long stop under recent highs and a short stop above recent lows, then switches direction when price crosses the opposite stop. Buy and sell labels mark those flips.

Indicator v6 Volatility & bandsTrend Repaints
Updated 11 days ago · GPL-3.0 GitHub repository of Chandelier Exit

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
330 stars

Range Filter [Alorse] is a technical indicator overlay for TradingView designed to filter market volatility and identify price trends. It calculates a smoothed range based on historical volatility using a configurable sampling period and multiplier applied to

Indicator v5 TrendVolatility & bands
Updated 2 months ago · None stated GitHub repository of Range Filter [Alorse]
318 stars

This indicator calculates an ATR trailing stop line derived from the highest high minus an average true range multiple over a specified lookback period. It plots the trailing stop line directly on the price chart and colors price bars based on whether the clos

Indicator v5 TrendVolatility & bands
Updated 2 months ago · MIT GitHub repository of ATR Trailing Stoploss

NVDA Trend Ribbon

by longsurf-ai
280 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated 2 days ago · MIT GitHub repository of NVDA Trend Ribbon

[RS]Donchian Fans

by ricardosantos79
261 stars

This indicator plots Donchian Channel boundary lines along with dynamic fan projections directly on the price chart. It calculates the highest high, lowest low, and median price over a customizable lookback period. Whenever price establishes a new channel high

Indicator v4 Support & resistanceTrend
Updated 4 years ago · None stated GitHub repository of [RS]Donchian Fans

More Trend scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers