本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=5
indicator("EMA + SuperTrend + UT Bot + VWAP + Today Pivot (UT BUY/SELL)", overlay=true)
//━━━━━━━━━━━━━━━━━━━━━━
// EMA
//━━━━━━━━━━━━━━━━━━━━━━
ema10 = ta.ema(close, 10)
ema20 = ta.ema(close, 20)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
//━━━━━━━━━━━━━━━━━━━━━━
// SUPERTREND
//━━━━━━━━━━━━━━━━━━━━━━
stATRLen = input.int(10, "SuperTrend ATR Length")
stFactor = input.float(3.0, "SuperTrend Multiplier")
[superTrend, _] = ta.supertrend(stFactor, stATRLen)
stBull = close > superTrend
//━━━━━━━━━━━━━━━━━━━━━━
// UT BOT
//━━━━━━━━━━━━━━━━━━━━━━
utFactor = input.float(1.0, "UT Bot Sensitivity")
utATRLen = input.int(10, "UT Bot ATR Length")
atr = ta.atr(utATRLen)
var float utStop = na
if na(utStop[1])
utStop := close - utFactor * atr
else
utStop := close > utStop[1] ? math.max(utStop[1], close - utFactor * atr) : math.min(utStop[1], close + utFactor * atr)
utBull = close > utStop
utBear = close < utStop
buySignal = utBull and not utBull[1]
sellSignal = utBear and not utBear[1]
//━━━━━━━━━━━━━━━━━━━━━━
// VWAP
//━━━━━━━━━━━━━━━━━━━━━━
vwapVal = ta.vwap
//━━━━━━━━━━━━━━━━━━━━━━
// TODAY PIVOT
//━━━━━━━━━━━━━━━━━━━━━━
dHigh = request.security(syminfo.tickerid, "D", high)
dLow = request.security(syminfo.tickerid, "D", low)
dClose = request.security(syminfo.tickerid, "D", close)
todayPivot = (dHigh + dLow + dClose) / 3
//━━━━━━━━━━━━━━━━━━━━━━
// CHECKLIST PANEL
//━━━━━━━━━━━━━━━━━━━━━━
var table panel = table.new(position.top_right, 2, 10, border_width=1)
headerBg = color.rgb(25,25,25)
rowBg1 = color.rgb(35,35,35)
rowBg2 = color.rgb(45,45,45)
if barstate.isfirst
table.cell(panel, 0, 0, "Indicator", bgcolor=headerBg, text_color=color.white)
table.cell(panel, 1, 0, "Status", bgcolor=headerBg, text_color=color.white)
// Generic YES / NO row
f_row(row, name, cond) =>
bg = row % 2 == 0 ? rowBg1 : rowBg2
table.cell(panel, 0, row, name, bgcolor=bg, text_color=color.white)
table.cell(panel, 1, row, cond ? "YES" : "NO", bgcolor=bg, text_color = cond ? color.lime : color.red)
// UT Bot BUY / SELL row
f_ut_row(row, name, isBull) =>
bg = row % 2 == 0 ? rowBg1 : rowBg2
table.cell(panel, 0, row, name, bgcolor=bg, text_color=color.white)
table.cell(panel, 1, row, isBull ? "BUY" : "SELL", bgcolor=bg, text_color = isBull ? color.lime : color.red)
// Rows
f_row(1, "EMA 10", close > ema10)
f_row(2, "EMA 20", close > ema20)
f_row(3, "EMA 50", close > ema50)
f_row(4, "EMA 200", close > ema200)
f_row(5, "SuperTrend", stBull)
f_ut_row(6, "UT Bot", utBull)
f_row(7, "VWAP", close > vwapVal)
f_row(8, "Today Pivot", close > todayPivot)
//━━━━━━━━━━━━━━━━━━━━━━
// PLOTS
//━━━━━━━━━━━━━━━━━━━━━━
plot(ema10, "EMA 10", color=color.orange, linewidth=2)
plot(ema20, "EMA 20", color=color.blue, linewidth=2)
plot(ema50, "EMA 50", color=color.green, linewidth=2)
plot(ema200, "EMA 200", color=color.red, linewidth=2)
plot(stBull ? superTrend : na, "SuperTrend Up", color=color.lime, linewidth=2)
plot(stBull ? na : superTrend, "SuperTrend Down", color=color.red, linewidth=2)
plot(utStop, "UT Bot", color = utBull ? color.lime : color.red, linewidth=2)
plot(vwapVal, "VWAP", color=color.purple, linewidth=2)
plot(todayPivot, "Today Pivot", color=color.yellow, linewidth=2)
// UT Bot BUY / SELL arrows
plotshape(buySignal, title="BUY", style=shape.labelup, location=location.belowbar, color=color.lime, text="BUY", textcolor=color.black)
plotshape(sellSignal, title="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, text="SELL", textcolor=color.white)