本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
// Unhyped Trend Ribbon v6.0
// The four lines of the Unhyped chart legend in one indicator slot:
// 8 EMA (optional, white 50%, width 1), 21 EMA (amber, width 2), 50 EMA (cyan, width 2), 200 SMA (stark white, width 3).
// Optional higher-timeframe lock reads the last CONFIRMED higher-timeframe bar, so lines never repaint.
indicator("Unhyped Trend Ribbon", shorttitle = "Unhyped Ribbon", overlay = true)
show8 = input.bool(false, "Show 8 EMA (momentum, impulse days only)")
show200 = input.bool(true, "Show 200 SMA (regime line)")
lockTf = input.timeframe("", "Lock lines to timeframe (blank = chart, e.g. 'D' on a 4H chart)")
showTag = input.bool(true, "Show regime tag on last bar")
maSet() =>
[ta.ema(close, 8), ta.ema(close, 21), ta.ema(close, 50), ta.sma(close, 200)]
[c8, c21, c50, c200] = maSet()
useLock = lockTf != ""
reqTf = useLock ? lockTf : timeframe.period
[h8, h21, h50, h200] = request.security(syminfo.tickerid, reqTf, [ta.ema(close, 8)[1], ta.ema(close, 21)[1], ta.ema(close, 50)[1], ta.sma(close, 200)[1]], lookahead = barmerge.lookahead_on)
e8 = useLock ? h8 : c8
e21 = useLock ? h21 : c21
e50 = useLock ? h50 : c50
s200 = useLock ? h200 : c200
plot(show8 ? e8 : na, "8 EMA", color = color.new(#FFFFFF, 50), linewidth = 1)
plot(e21, "21 EMA", color = #FFAB00, linewidth = 2)
plot(e50, "50 EMA", color = #00B0FF, linewidth = 2)
plot(show200 ? s200 : na, "200 SMA", color = #FFFFFF, linewidth = 3)
var label tag = na
if showTag and barstate.islast
label.delete(tag)
bull = close >= s200
aligned = bull ? e21 > e50 : e21 < e50
txt = (bull ? "ABOVE 200 SMA" : "BELOW 200 SMA") + (aligned ? " | 21/50 ALIGNED" : " | 21/50 MIXED")
tag := label.new(bar_index + 3, s200, txt, style = label.style_label_left, color = color.new(#161B22, 10), textcolor = bull ? #00E676 : #FF1744, size = size.small)