本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MohaveTrader
// Precision VWAP Chase [MohaveTrader] (VWAPChase)
// Version History
// v1.0 — October 2026
// • Initial release
//
// Measures live price displacement from session VWAP in units of fixed 5-minute Wilder ATR(7). Positive readings are above VWAP; negative readings are below. Colors identify near-VWAP, moderate, extended and parabolic displacement on either side.
// Above VWAP: green = moderate, yellow = extended, magenta = parabolic. Below VWAP: orange = below, red = extended below, magenta = parabolic below. Gray = near VWAP.
//
// HOW TO USE
// Use on intraday charts with extended hours on so premarket counts in VWAP.
// The reading updates live with price on any intraday chart. The ATR updates every 5 minutes.
// Uses a fixed 5-minute Wilder ATR(7) as the volatility ruler, so the extension reading remains consistent when switching chart timeframes.
// Adjust the Near VWAP, Extended and Parabolic limits to taste. Each limit applies to both sides of VWAP.
// Optional upper (+Extended, +Parabolic) and lower (-Extended, -Parabolic) threshold lines show where the label changes state. They use the same fixed 5-minute ATR as the live reading and move with session VWAP. Thresholds are moving volatility boundaries, not support or resistance.
// Set Label Position to Above or Below to move the text off other indicators' lines. The label stays anchored to VWAP.
// The value is also in the Data Window and can be used as a Pine Screener column.
//@version=6
indicator("Precision VWAP Chase", "VWAPChase", overlay = true, max_labels_count = 5)
nearLim = input.float(0.5, "Near VWAP Limit (ATR)", minval = 0, step = 0.1, group = "Tiers")
extLim = input.float(2.0, "Extended Limit (ATR)", minval = 0, step = 0.1, group = "Tiers")
paraLim = input.float(4.0, "Parabolic Limit (ATR)", minval = 0, step = 0.1, group = "Tiers")
showVwap = input.bool(true, "Show VWAP", group = "VWAP")
vwapCol = input.color(color.white, "VWAP Color", group = "VWAP")
vwapW = input.int(2, "VWAP Width", minval = 1, maxval = 5, group = "VWAP")
showUpTh = input.bool(false, "Show Upper Thresholds", group = "Thresholds")
showDnTh = input.bool(false, "Show Lower Thresholds", group = "Thresholds")
thW = input.int(1, "Threshold Width", minval = 1, maxval = 5, group = "Thresholds")
showLbl = input.bool(true, "Show Label", group = "Label")
lblOff = input.int(3, "Label Offset (bars)", minval = 0, group = "Label")
lblPos = input.string("On", "Label Position", options = ["On", "Above", "Below"], group = "Label")
lblSize = input.string(size.normal, "Label Size", options = [size.tiny, size.small, size.normal, size.large, size.huge], group = "Label")
colNear = input.color(#B0BEC5, "At VWAP", group = "Label")
colGood = input.color(#39FF14, "Moderate", group = "Label")
colExt = input.color(#FFFF33, "Extended", group = "Label")
colPara = input.color(#FF2EFF, "Parabolic", group = "Label")
colBelow = input.color(#FF9F1C, "Below VWAP", group = "Label")
colExtDn = input.color(#FF3131, "Extended Below", group = "Label")
chartSec = timeframe.in_seconds()
chartAtr = ta.atr(7)
vw = ta.vwap(hlc3)
var float atr5 = na
if timeframe.isintraday
if chartSec < 300
atr5 := request.security(syminfo.tickerid, "5", ta.atr(7))
else if chartSec > 300
ltfAtr = request.security_lower_tf(syminfo.tickerid, "5", ta.atr(7), ignore_invalid_timeframe = true)
if array.size(ltfAtr) > 0
atr5 := array.last(ltfAtr)
else
atr5 := chartAtr
ok = timeframe.isintraday and atr5 > 0
dist = ok ? (close - vw) / atr5 : na
r = math.round(dist, 1)
col = na(r) ? color.silver : r >= paraLim ? colPara : r >= extLim ? colExt : r > nearLim ? colGood : r >= -nearLim ? colNear : r > -extLim ? colBelow : r > -paraLim ? colExtDn : colPara
drawOk = timeframe.isintraday and not timeframe.change("D")
plot(showVwap and drawOk ? vw : na, "VWAP", vwapCol, vwapW, plot.style_linebr)
plot(showUpTh and drawOk and ok ? vw + extLim * atr5 : na, "Upper Extended Threshold", colExt, thW, plot.style_linebr)
plot(showUpTh and drawOk and ok ? vw + paraLim * atr5 : na, "Upper Parabolic Threshold", colPara, thW, plot.style_linebr)
plot(showDnTh and drawOk and ok ? vw - extLim * atr5 : na, "Lower Extended Threshold", colExtDn, thW, plot.style_linebr)
plot(showDnTh and drawOk and ok ? vw - paraLim * atr5 : na, "Lower Parabolic Threshold", colPara, thW, plot.style_linebr)
plot(dist, "VWAP Chase (ATR)", display = display.data_window)
f_px(v) =>
a = math.abs(v)
a >= 1e12 ? str.tostring(v / 1e12, "0.###") + "T" : a >= 1e9 ? str.tostring(v / 1e9, "0.###") + "B" : a >= 1e6 ? str.tostring(v / 1e6, "0.###") + "M" : str.tostring(v, format.mintick)
lblStyle = lblPos == "Above" ? label.style_label_lower_left : lblPos == "Below" ? label.style_label_upper_left : label.style_label_left
var label lb = na
if barstate.islast
label.delete(lb)
lb := na
if showLbl
if not timeframe.isintraday
lb := label.new(bar_index + lblOff, close, "VWAPChase: intraday charts only", style = label.style_label_left, color = color.new(color.black, 100), textcolor = color.silver, size = lblSize)
else if na(vw)
lb := label.new(bar_index + lblOff, close, "VWAPChase: no volume data for VWAP", style = label.style_label_left, color = color.new(color.black, 100), textcolor = color.silver, size = lblSize)
else if not ok
lb := label.new(bar_index + lblOff, vw, "VWAP " + f_px(vw) + " waiting for 5m ATR", style = lblStyle, color = color.new(color.black, 100), textcolor = color.silver, size = lblSize)
else
txt = "VWAP " + f_px(vw) + " " + (r >= 0 ? "+" : "") + str.tostring(r, "0.0") + " ATR"
lb := label.new(bar_index + lblOff, vw, txt, style = lblStyle, color = color.new(color.black, 100), textcolor = col, size = lblSize)