本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Pure UT Bot - Signals Only", overlay=true)
// --- Settings ---
// These are the "Golden" settings for fast intraday signals
keyValue = input.float(1.0, "Sensitivity (Lower = More Signals)")
atrPeriod = input.int(10, "ATR Period")
// --- UT Bot Core Logic ---
xATR = ta.atr(atrPeriod)
nLoss = keyValue * xATR
var float trailingStop = 0.0
trailingStop := close > nz(trailingStop[1], 0) and close[1] > nz(trailingStop[1], 0) ? math.max(nz(trailingStop[1]), close - nLoss) :
close < nz(trailingStop[1], 0) and close[1] < nz(trailingStop[1], 0) ? math.min(nz(trailingStop[1]), close + nLoss) :
close > nz(trailingStop[1], 0) ? close - nLoss : close + nLoss
// --- Signal Generation ---
// Buy when price crosses above the invisible trailing stop
buySignal = ta.crossover(close, trailingStop)
// Sell when price crosses below the invisible trailing stop
sellSignal = ta.crossunder(close, trailingStop)
// --- Visuals (ONLY BUY/SELL LABELS) ---
plotshape(buySignal, title="BUY", style=shape.labelup, location=location.belowbar, color=color.new(#26a69a, 0), text="BUY", textcolor=color.white, size=size.small)
plotshape(sellSignal, title="SELL", style=shape.labeldown, location=location.abovebar, color=color.new(#ef5350, 0), text="SELL", textcolor=color.white, size=size.small)
// Alert triggers for your phone/desktop
alertcondition(buySignal, "UT Buy Signal", "UT Bot BUY")
alertcondition(sellSignal, "UT Sell Signal", "UT Bot SELL")