OPEN-SOURCE SCRIPT
Professional Anchored VWAP with Multi Level Standard Bands

一、指标概述
本指标是一款基于成交量加权的进阶量化分析工具,核心功能是将 VWAP 的计算起点“锚定”到您自行选择的任意历史时间点,并围绕该基准自动生成六级标准差概率通道(±0.5σ、±1.0σ、±1.5σ、±2.0σ、±2.5σ、±3.0σ),形成完整的市场价格分布监测体系。
与每日开盘重置的传统 VWAP 不同,锚定 VWAP 将计算起点固定在某个具有战略意义的时间节点——例如重大宏观事件(FOMC 决议、CPI 发布)、公司基本面事件(财报披露)、技术结构节点(趋势起点、摆动高点/低点、突破点)或任何您认为值得跟踪的时点。这种设计让您能够持续追踪“自该事件发生以来,市场真正的平均成本”,从而更精准地识别机构级支撑阻力、评估趋势健康度、捕捉均值回归机会。
本指标适用于股票、ETF、期货、加密货币等所有具备真实成交量数据的品种,并且可加载于任意时间框架(1分钟、5分钟、日线、周线等)。
二、核心理念与设计逻辑
- 从每日重置到事件锚定的升级
传统 VWAP 在每个交易日开盘时重新计算,对日内交易者非常实用,但对于持仓数日、数周甚至更长的波段或趋势交易者,每日重置意味着关键历史参考的丢失。AVWAP 通过固定锚点,解决了这一局限,让您能够以特定事件为原点,持续衡量市场参与者的平均成本变化。 - 从价格位置到统计概率的跃迁
单一的 VWAP 线只能告诉您价格在基准线上方还是下方,而本指标引入“成交量加权标准差”,将价格偏离转化为具有统计意义的概率度量。±1σ 通道覆盖约 68% 的价格分布,定义常态波动区间;±2σ 通道覆盖约 95%,反映显著偏离;±3σ 通道覆盖约 99.7%,触及此区域通常意味着极端情绪定价,均值回归的概率显著升高。这使得价格分析从“高低判断”升级为“价格在统计分布中的位置判断”,为决策提供可量化的概率依据。
三、计算方法简述
AVWAP 的计算采用典型价格(即最高价、最低价、收盘价的算术平均值)与成交量的乘积进行累加,再除以累计成交量,得到自锚点以来的成交量加权平均价格。标准差则基于价格平方与成交量的加权累加,结合方差公式 E(P²)‑E(P)² 计算得出,整个过程仅需单次数据遍历,确保在大时间窗口下的计算效率。各通道带即为 AVWAP 数值加上或减去对应倍数(0.5、1.0、1.5、2.0、2.5、3.0)的标准差值。
四、实战应用指南
- 趋势方向判断
当价格持续运行于 AVWAP 上方,表明自锚点以来多头占据主导,市场平均成本低于现价,多头持仓整体盈利;反之,价格持续运行于 AVWAP 下方,则空头占据主导。若价格频繁穿越 AVWAP,则市场处于震荡均衡状态。 - 动态支撑与阻力
AVWAP 线本身是最重要的动态支撑/阻力位。上升趋势中,价格回踩 AVWAP 并获得支撑,往往是趋势延续的信号;下降趋势中,价格反弹至 AVWAP 并遇阻,往往意味着趋势延续。各标准差通道带同样构成次级支撑/阻力区域,可作为分批建仓或止盈的参考位置。 - 均值回归交易
当价格延伸至外层通道(如 ±2.5σ 或 ±3.0σ)时,价格已显著偏离成交量加权公允值,历史上表现出强烈的回归倾向。触及上轨极端区域可考虑短线做空或获利了结;触及下轨极端区域可考虑短线做多或回补仓位。需注意,在强单边趋势中,价格可能在极端区域停留较长时间,建议结合其他趋势指标进行过滤。 - 趋势延续确认
价格在突破 +1σ 上轨后持续运行于该通道之上,并伴随成交量放大,确认强势多头趋势;反之,价格跌破 -1σ 下轨后持续运行于下方并放量,确认强势空头趋势。 - 多时间框架共振
建议在日线级别确定主要锚点和长期趋势方向,在小时或分钟级别寻找精确入场时机。当短周期 AVWAP 与长周期 AVWAP 方向一致时,信号可靠性显著增强。
五、锚点选择建议
良好的锚点选择是 AVWAP 有效性的前提。以下为推荐的锚点类型及示例:
- 宏观事件型:适用于重大政策或数据发布后的市场重定价,例如 FOMC 决议日、CPI 或非农数据发布日。
- 公司事件型:适用于基本面催化剂后的趋势跟踪,例如财报发布日、并购公告日。
- 技术结构型:适用于趋势跟踪与结构分析,例如显著摆动高点/低点、趋势起点、关键突破点。
- 时间节点型:适用于周期性基准参考,例如年初、月初、周初。
核心原则:锚点应选择对标的资产具有显著价格影响且市场参与者广泛关注的时间节点。
六、参数配置说明
您可以通过以下输入参数灵活控制指标显示:
- 锚定日期:分别设置年、月、日(默认为 2024 年 9 月 24 日)。
- 显示控制:您可以选择独立开启或关闭每一级标准差通道(±0.5σ、±1.0σ、±1.5σ、±2.0σ、±2.5σ、±3.0σ),按需保持图表简洁。
颜色编码体系:
- 蓝色基准线:AVWAP 主参考线。
- 绿色通道(±0.5σ、±1.0σ):常态波动区间。
- 橙色通道(±1.5σ、±2.0σ):中等级别偏离区间。
- 红色通道(±2.5σ、±3.0σ):极端偏离 / 均值回归关注区间。
七、适用交易者类型
- 日内交易者:可将锚点设为当日开盘,利用 AVWAP 作为日内公允值参考与均值回归信号。
- 波段交易者:将锚点设为关键事件或摆动点,识别中期支撑/阻力区域。
- 趋势交易者:将锚点设为趋势起点,持续跟踪趋势健康度与方向。
- 机构与专业交易者:追踪市场平均成本,识别机构级买卖区域。
八、注意事项与风险提示
- 成交量数据质量直接影响 AVWAP 的参考价值,在低流动性品种上建议谨慎使用。
- 锚点选择必须基于合理逻辑(如重大事件),随机选取的日期可能导致指标失去参考意义。
- 标准差通道基于历史数据计算,不构成对未来走势的确定性预测,通道边界是概率参考而非硬性边界。
- 均值回归策略在强劲单边市场中可能面临较大风险,建议结合趋势强度指标进行过滤。
- 本指标仅供技术分析参考,所有交易决策应由您独立判断并自行承担风险。
九、开源说明
本指标以开源方式发布在 TradingView 社区。所有代码均可供您审阅、验证功能逻辑,并基于自身需求进行修改与优化。欢迎在评论区分享使用心得、改进建议或问题反馈。
价格告诉你发生了什么,成交量告诉你谁在推动它,AVWAP 告诉你市场的真实成本在哪里。
1. Indicator Overview
This indicator is an advanced quantitative analysis tool based on volume weighting. Its core functionality is to anchor the starting point of VWAP calculation to any historical timestamp you choose, and automatically generate six levels of standard deviation probability bands (±0.5σ, ±1.0σ, ±1.5σ, ±2.0σ, ±2.5σ, ±3.0σ) around that benchmark, forming a complete market price distribution monitoring system.
Unlike the traditional VWAP which resets at the open of each trading day, the Anchored VWAP fixes the calculation origin at a strategically significant point in time – for example, major macroeconomic events (FOMC decisions, CPI releases), company‑specific events (earnings announcements), technical structure nodes (trend starts, swing highs/lows, breakout points), or any moment you consider worth tracking. This design allows you to continuously monitor "the true average cost of the market since that event occurred," enabling more precise identification of institutional support/resistance, assessment of trend health, and capturing mean‑reversion opportunities.
This indicator is suitable for all instruments with genuine volume data, including stocks, ETFs, futures, cryptocurrencies, and can be applied on any timeframe (1‑minute, 5‑minute, daily, weekly, etc.).
2. Core Concepts & Design Logic
- Upgrade from Daily Reset to Event Anchoring
Traditional VWAP recalculates at the open of each trading day, which is highly useful for intraday traders. However, for swing or trend traders who hold positions for days, weeks, or longer, the daily reset means the loss of critical historical context. AVWAP overcomes this limitation by fixing the anchor, allowing you to measure the evolution of market participants’ average cost from a specific event onwards. - From Price Position to Statistical Probability
A single VWAP line only tells you whether price is above or below the benchmark. This indicator introduces "volume‑weighted standard deviation," converting price deviations into statistically meaningful probability measures. The ±1σ band covers approximately 68% of the price distribution, defining the normal fluctuation range; ±2σ covers about 95%, reflecting significant deviations; ±3σ covers about 99.7%, and touches at this level typically indicate extreme sentiment pricing, with mean‑reversion probability rising markedly. This elevates price analysis from a simple "high/low" judgment to a "position within the statistical distribution" framework, providing quantifiable probabilistic grounds for decision‑making.
3. Brief Calculation Methodology
AVWAP is computed by accumulating the product of the typical price (arithmetic average of high, low, and close) and volume, then dividing by the cumulative volume to obtain the volume‑weighted average price since the anchor. The standard deviation is derived from the volume‑weighted accumulation of squared prices, combined with the variance formula E(P²)‑E(P)². The entire process requires only a single pass through the data, ensuring computational efficiency even over large time windows. Each band is simply the AVWAP value plus or minus the corresponding multiple (0.5, 1.0, 1.5, 2.0, 2.5, 3.0) of the standard deviation.
4. Practical Application Guide
- Trend Direction Bias
When price consistently trades above AVWAP, it indicates that bulls have been dominant since the anchor, as the average market cost is below the current price and long positions are in profit. Conversely, sustained trading below AVWAP suggests bearish dominance. Frequent crossovers of AVWAP imply a range‑bound/equilibrium state. - Dynamic Support & Resistance
The AVWAP line itself is the most important dynamic support/resistance level. In an uptrend, a pullback that finds support at AVWAP often signals trend continuation; in a downtrend, a bounce that meets resistance at AVWAP also indicates continuation. The standard deviation bands also serve as secondary support/resistance zones, useful for scaling entries or taking partial profits. - Mean‑Reversion Trading
When price extends to the outer bands (e.g., ±2.5σ or ±3.0σ), it has significantly deviated from the volume‑weighted fair value, historically exhibiting a strong tendency to revert. Touching the upper extreme zone may be considered for short‑term selling or profit‑taking; touching the lower extreme zone may suggest short‑term buying or covering shorts. Note that in strong trending markets, price may linger in extreme zones for extended periods; it is advisable to combine with other trend‑strength filters. - Trend Continuation Confirmation
If price breaks above the +1σ upper band and continues trading above it with rising volume, it confirms a strong bullish trend. Conversely, if price breaks below the -1σ lower band and continues below it with volume expansion, it confirms a strong bearish trend. - Multi‑Timeframe Confluence
It is recommended to determine the primary anchor and longer‑term trend direction on the daily chart, and then seek precise entry signals on hourly or minute charts. When the shorter‑timeframe AVWAP aligns with the longer‑timeframe AVWAP, signal reliability increases significantly.
5. Anchor Selection Recommendations
Proper anchor selection is a prerequisite for AVWAP effectiveness. Below are recommended anchor types with examples:
- Macro‑Event Type: Suitable for market re‑pricing after major policy/data releases, e.g., FOMC decision days, CPI or Non‑Farm Payroll release days.
- Company‑Event Type: Suitable for trend following after fundamental catalysts, e.g., earnings release days, M&A announcement days.
- Technical‑Structure Type: Suitable for trend‑following and structural analysis, e.g., significant swing highs/lows, trend starting points, key breakout levels.
- Time‑Based Type: Suitable for periodic benchmark references, e.g., start of the year, month, or week.
Core Principle: The anchor should be chosen at a point in time that had a notable price impact on the asset and is widely observed by market participants.
6. Input Parameter Settings
You can flexibly control the indicator display with the following inputs:
- Anchor Date: Set year, month, and day separately (default is 2024‑09‑24).
- Display Controls: You can independently enable or disable each standard deviation band (±0.5σ, ±1.0σ, ±1.5σ, ±2.0σ, ±2.5σ, ±3.0σ) to keep your chart as clean as needed.
Color Coding System:
- Blue baseline: AVWAP main reference line.
- Green bands (±0.5σ, ±1.0σ): Normal fluctuation range.
- Orange bands (±1.5σ, ±2.0σ): Moderate deviation range.
- Red bands (±2.5σ, ±3.0σ): Extreme deviation / mean‑reversion focus zone.
7. Suitable Trader Types
- Day traders: Can set the anchor to the day's open, using AVWAP as an intraday fair‑value reference and mean‑reversion signal.
- Swing traders: Anchor to key events or swing points to identify intermediate support/resistance areas.
- Trend traders: Anchor to the trend’s starting point to continuously monitor trend health and direction.
- Institutional / professional traders: Track the average market cost to identify institutional‑grade accumulation/distribution zones.
8. Important Notes & Risk Disclaimers
- The quality of volume data directly affects the reference value of AVWAP; use with caution on low‑liquidity instruments.
- Anchor selection must be based on sound logic (e.g., significant events); randomly chosen dates may render the indicator meaningless.
- Standard deviation bands are computed from historical data and do not constitute a deterministic prediction of future price movements; band boundaries are probabilistic references, not hard edges.
- Mean‑reversion strategies carry higher risk in strong trending markets; it is advisable to incorporate trend‑strength filters.
- This indicator is for technical analysis reference only. All trading decisions should be made independently by the user, who bears full responsibility for their actions.
9. Open Source Statement
This indicator is published as open source in the TradingView community. All code is available for you to review, verify its functional logic, and modify or optimise according to your own needs. Feedback, usage experiences, and suggestions for improvement are warmly welcomed in the comments section.
*“Price tells you what happened, volume tells you who is driving it, and AVWAP tells you where the market’s true cost lies.”*
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.