The UT Bot Indicator uses advanced algorithms to identify key support and resistance levels.
This code gives signals based upon the ATR Trailing Stop calculated with HeikinAshi candlesticks.
As a trend analysis tool, it provides the general direction of where an equity is heading.
mod note:
Here is the most updated version of the UT Bot For ThinkOrSwim
This particular UT Bot was written for use on: 4 hour, Daily, 3 Day and Weekly time frames
However, many members are using it on shorter aggregations. Read through this thread to find out what modifications other members have found useful when applying to lower timeframes.
Appreciation to @ttsdmagic for all the support provided in this thread.
(his original version is in the next post below)
[/COLOR]
This code gives signals based upon the ATR Trailing Stop calculated with HeikinAshi candlesticks.
As a trend analysis tool, it provides the general direction of where an equity is heading.
mod note:
Here is the most updated version of the UT Bot For ThinkOrSwim
This particular UT Bot was written for use on: 4 hour, Daily, 3 Day and Weekly time frames
However, many members are using it on shorter aggregations. Read through this thread to find out what modifications other members have found useful when applying to lower timeframes.
Appreciation to @ttsdmagic for all the support provided in this thread.
(his original version is in the next post below)

CSS:
# ATR Trailing Stop
# https://usethinkscript.com/threads/ut-bot-for-thinkorswim.12640/#post-116615
input Key_Vaule = 1.0;
def a = key_vaule;# input(1, title = "Key Vaule. 'This changes the sensitivity'")
input atr_period = 10;
def c = atr_period; # input(10, title = "ATR Period")
input Signals_from_Heikin_Ashi_Candles = no;
def h = signals_from_Heikin_Ashi_Candles; # input(false, title = "Signals from Heikin Ashi Candles")
input SignalStyle = {Default "Arrow", "Label", "None"};
def na = Double.NaN;
defineglobalColor("Green", color.Green);
defineglobalcolor("Red", color.Red);
def arrow = SignalStyle==SignalStyle."Arrow";
def Label = SignalStyle==SignalStyle."Label";
def SigStyle = if arrow then 1 else if Label then -1 else 0;
def xATR = atr(c);
def nLoss = a * xATR;
def src = if h then (open + high + low + close) / 4 else close;
script nz{
input x = close;
input y = 0;
plot result = if isnan(x) then y else x;
}
#xATRTrailingStop = 0.0
def xATRTrailingStop =compoundValue(1, if(src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), src - nLoss),
if(src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), src + nLoss),
if(src > nz(xATRTrailingStop[1], 0), src - nLoss, src + nLoss))),0);
#pos = 0
def pos = compoundValue(1, if(src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0), 1,
if(src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0))) , 0);
def ema = expaverage(src,1);
def above = crosses(ema, xATRTrailingStop, crossingDirection.ABOVE);
def below = crosses(xATRTrailingStop, ema, crossingDirection.ABOVE);
def buy = src > xATRTrailingStop and above ;
def sell = src < xATRTrailingStop and below;
def barbuy = src > xATRTrailingStop ;
def barsell = src < xATRTrailingStop ;
plot ArrowUp = if Arrow and buy then low - ATR(5)/10 else na;
ArrowUp.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ArrowUp.SetDefaultColor(globalColor("Green"));
ArrowUp.SetLineWeight(2);
plot ArrowDn = if Arrow and sell then high + ATR(5)/10 else na;
ArrowDn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ArrowDn.SetDefaultColor(globalColor("Red"));
ArrowDn.SetLineWeight(2);
addchartbubble(Label and buy, low, "B", globalColor("Green"), no);
addchartbubble(Label and sell, high, "S", globalColor("Red"), yes);
input price_color_on = yes;
assignPriceColor(if !price_color_on then color.current else if barbuy then globalColor("Green") else color.CURRENT);
assignpriceColor(if !price_color_on then color.current else if barsell then globalColor("Red") else color.currENT);
input alert_sound_on = no;
alert(buy, "UT Long", alert.bar,if alert_sound_on then sound.ring else sound.NoSound);
alert(sell, "UT Short", alert.bar,if alert_sound_on then sound.bell else sound.NoSound);
Last edited by a moderator: