本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("WMA 200: 1H-4H-D-W", overlay=true)
// ─────────────────────────────────────────────
// Inputs
// ─────────────────────────────────────────────
length = input.int(200, "WMA Length", minval=1)
show1H = input.bool(true, "Show 1H")
show4H = input.bool(true, "Show 4H")
show1D = input.bool(true, "Show 1D")
show1W = input.bool(true, "Show 1W")
smoothDaily = input.bool(true, "Smooth daily WMA")
dailySmoothHours = input.float(8.0, "Daily visual smoothing (hours)", minval=1.0)
// ─────────────────────────────────────────────
// Native 200 WMAs
// ─────────────────────────────────────────────
wma1H = request.security(
syminfo.tickerid,
"60",
ta.wma(close, length),
gaps=barmerge.gaps_off,
lookahead=barmerge.lookahead_off)
wma4H = request.security(
syminfo.tickerid,
"240",
ta.wma(close, length),
gaps=barmerge.gaps_off,
lookahead=barmerge.lookahead_off)
wma1D = request.security(
syminfo.tickerid,
"1D",
ta.wma(close, length),
gaps=barmerge.gaps_off,
lookahead=barmerge.lookahead_off)
wma1W = request.security(
syminfo.tickerid,
"1W",
ta.wma(close, length),
gaps=barmerge.gaps_off,
lookahead=barmerge.lookahead_off)
// ─────────────────────────────────────────────
// Daily visual smoothing
// Keeps smoothing duration roughly constant
// across intraday chart timeframes
// ─────────────────────────────────────────────
chartMinutes = timeframe.in_seconds() / 60.0
dailySmoothBarsRaw = dailySmoothHours * 60.0 / chartMinutes
dailySmoothBars = math.max(1, int(math.round(dailySmoothBarsRaw)))
wma1D_visual = smoothDaily ? ta.ema(wma1D, dailySmoothBars) : wma1D
// ─────────────────────────────────────────────
// Plots
// ─────────────────────────────────────────────
plot(
show1H ? wma1H : na,
title="200 WMA 1H",
color=color.rgb(145, 235, 240),
linewidth=1)
plot(
show4H ? wma4H : na,
title="200 WMA 4H",
color=color.rgb(255, 240, 150),
linewidth=2)
plot(
show1D ? wma1D_visual : na,
title="200 WMA 1D",
color=color.rgb(255, 185, 135),
linewidth=2)
plot(
show1W ? wma1W : na,
title="200 WMA 1W",
color=color.rgb(235, 155, 235),
linewidth=3)