UT Bot v2 - ATR Trailing Stop
Jun 6, 2026

The UT Bot v2 - ATR Trailing Stop tool provides a systematic trend-following framework by using an adaptive trailing stop based on market volatility to identify potential trend reversals and entry points.
Usage
The UT Bot v2 - ATR Trailing Stop can be used to identify the prevailing market trend and manage trade exits. When the price crosses above the calculated trailing stop level, a "Buy" signal is generated, indicating a transition to a bullish trend. Conversely, when the price crosses below the trailing stop level, a "Sell" signal is generated, indicating a bearish trend.
Traders often use the trailing stop line as a dynamic support or resistance level. In a bullish trend, the line sits below the price and moves upward as price increases; in a bearish trend, the line sits above the price and moves downward as price decreases. The "Color Bars by Trend" feature provides an immediate visual cue of the current market state, helping users stay aligned with the directional momentum.
Details
The script is a modernized implementation of the original UT Bot logic by QuantNomad. It utilizes the Average True Range (ATR) to measure market volatility and determine the distance of the trailing stop from the price.
The core calculation involves:
- Calculating the ATR over a user-defined period.
- Multiplying the ATR by a sensitivity factor (Multiplier).
- Calculating the Trailing Stop Level (TSL). The TSL is designed to move only in the direction of the trend unless a breakout occurs. If the price crosses the TSL, the trend state flips and the TSL begins calculating from the opposite side of the price.
This methodology ensures the stop is wide enough to avoid "whipsaws" during minor fluctuations while remaining tight enough to capture significant trend shifts. It is important to note that as a trend-following tool, the indicator performs optimally during trending market conditions and may produce false signals during sideways or low-volatility ranges.
Settings
Config
- Multiplier: Controls the distance of the trailing stop. Higher values create wider stops, resulting in fewer signals and less sensitivity to minor price movements.
- ATR Period: Defines the number of bars used to calculate market volatility via the Average True Range.
- Source: Determines the price source (e.g., close, high, low) used for the trailing stop calculations.
Display
- Show Buy/Sell Signals: Toggles the visibility of the "Buy" and "Sell" label markers on the chart.
- Color Bars by Trend: When enabled, the chart bars will be colored based on the current trend state (green for bullish, red for bearish).
- Show Trailing Stop Line: Toggles the visibility of the dynamic ATR trailing stop line.
FAQ
What market conditions are best for this indicator?
The UT Bot v2 is a trend-following tool and performs best in markets with sustained directional moves. It may generate frequent signals during consolidating or ranging markets.
Can this script be used for automated strategy testing?
Yes, the script includes integrated strategy logic for backtesting, allowing users to evaluate the performance of the ATR trailing stop methodology over historical data.
How can I access this tool?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.