OPEN-SOURCE SCRIPT
ที่อัปเดต:

VWAP+ [Y.Algo]

1 735
VWAP+ [Y.Algo] — Five Anchored VWAPs, Rolling Multi-Exchange VWAP Bands, Previous-Period Zones & Session Initial Balance

VWAP+ layers up to nine independent VWAP structures on a single chart — five freely anchored VWAPs (Day through Year), four rolling-window VWAPs with optional cross-exchange aggregated volume, a snapshot of the previous completed period's VWAP channel, and a session Initial Balance box — so you can read fair value across every timeframe you trade at once, without switching charts or stacking multiple indicators.

Fully open-source (CC BY-NC-SA 4.0) — every calculation is documented below and visible in the script.

🔶 USAGE

VWAP+ is built as a multi-timeframe fair-value reference wall rather than a single-signal indicator. Instead of one VWAP, you can stack five independently anchored VWAPs (assign each to Day, Week, Month, Quarter, or Year) alongside four rolling VWAPs on any day-count window you like, and watch how price behaves against all of them at once. When several VWAPs converge into a tight band, that price zone tends to act as a stronger confluence support/resistance; when they fan apart, the market is caught between competing fair-value references on different horizons.

Anchored VWAPs are best for framing swing/position bias — set slots to Week, Month, Quarter and Year to see at a glance whether price sits above or below the "institutional" fair value on each horizon simultaneously, and treat a reclaim or loss of any of them as a potential regime shift on that timeframe. Rolling VWAPs behave differently: because they use a fixed trailing time window instead of resetting at a period boundary, they never gap at a session or period open, which makes them a smoother, more consistent reference on 24-hour markets like crypto.

The Previous VWAP Markers extend a fixed snapshot of the last (or second-to-last) completed period's VWAP channel to the right edge of the chart, giving you a static historical reference band to judge whether current price is trading rich or cheap relative to where the market closed out its last day, week, month, quarter, or year. Combine this with the Initial Balance box — built from the first hour of the Tokyo session — as a session-range reference, and use the touch alerts so you don't have to watch every VWAP manually.

🔹 Background Mode — Three-Way Color Management
VWAP+ carries no bull/bear theme, since it's a reference-line tool rather than a trend/signal indicator. Instead, a single three-way Background Mode switch governs the color of every VWAP, deviation band, previous-period marker, and Initial Balance box at once. Dark Background and Light Background each lock in a fixed palette tuned for that chart tone and override every individual color picker below, so most users can flip one switch and never worry about visibility again. Switching to Custom releases that lock — every color you've set on each VWAP, band, marker, and the IB box is used exactly as configured, putting visibility fully in your hands. In total, 36 individual color settings across five anchored VWAPs, four rolling VWAPs, eight previous-period markers, and the Initial Balance box are governed by this one switch.

🔹 Five Independent Anchored VWAPs
Five separate VWAP slots (VWAP1–VWAP5) can each be assigned its own anchor period — Day, Week, Month, Quarter, or Year — and toggled on independently, all off by default so you build exactly the combination you need. Each slot plots its own VWAP line plus a 1-standard-deviation upper/lower band with a fillable zone, all in fully customizable colors, letting you view several timeframes' fair value simultaneously on one chart.

🔹 Previous-Period VWAP Zone Markers
Eight independent toggles (previous day, week, two-back week, month, two-back month, quarter, two-back quarter, and year) each draw the corresponding completed period's VWAP channel — upper band, lower band, and VWAP line — as a box and labeled line projected to the right edge of the chart. This is a frozen historical snapshot, not a live-updating series, giving you a stable reference to compare current price against where the market's fair value settled in a prior period.

🔹 Rolling VWAP with Optional Multi-Exchange Aggregated Volume
Four independent rolling-window VWAPs (7D/30D/90D/365D by default, but each day-count is fully adjustable from a preset list) compute a true trailing-window VWAP that never resets at a period boundary. An optional aggregated-volume mode combines volume from up to four separately configured symbols (defaulting to BTC pairs across four major exchanges, but changeable to any instrument) before feeding the VWAP calculation — useful for markets where volume is fragmented across multiple venues. Deviation bands around each rolling VWAP can be switched between a percentage-based Symmetrical mode and a statistical Standard (standard-deviation) mode, with an adjustable multiplier controlling band width.

🔹 Initial Balance Range (Tokyo Session)
A box is drawn from the Tokyo trading session (09:00–15:00), with its high/low seeded by the first hour of that session (09:00–10:00) — the classic "Initial Balance" concept from auction market theory. The box extends across the full session and a configurable number of recent days remain visible on the chart, letting you gauge whether the current session is breaking out of, or staying contained within, its opening-hour range.

🔹 Touch Alert System
Nine independently toggleable alerts fire the instant price wicks touch any enabled anchored VWAP (VWAP1–VWAP5) or rolling VWAP (7D/30D/90D/365D), regardless of approach direction — a direction-agnostic heads-up that price has reached a fair-value reference worth reviewing, delivered once per bar close.

🔶 DETAILS

VWAP+ is fully open-source (CC BY-NC-SA 4.0). Here is exactly how it works.

Background palette — Dark and Light modes each route every color input through a single switch function into one of two hard-coded palettes: a high-transparency white-based set for Dark backgrounds, or a darker navy/grey set for Light backgrounds. While either fixed mode is active, the color pickers below are still evaluated but their values are discarded. Selecting Custom short-circuits that switch and returns each color input unchanged, so every picker takes effect.

Anchored VWAPs — Each of the five slots calls Pine Script's built-in ta.vwap(source, new-period-flag, 1) on hlc3, where the new-period flag fires on timeframe.change('D'/'W'/'M'/'3M'/'12M') depending on the chosen anchor. The VWAP and its bands reset to zero accumulation at the start of each anchor period; the multiplier of 1 draws bands at one volume-weighted standard deviation of price around the VWAP, widening or narrowing as the period progresses.

Previous-period markers — On every bar the script caches the just-completed period's upper band, lower band, and VWAP value (sampled one bar before the reset). Once the chart reaches its last bar, these cached values are drawn once as a static box, a dotted VWAP line, and three labels — they do not update afterward; they are a fixed snapshot, not a live series.

Rolling VWAP — Unlike the anchored VWAPs, this path uses the PineCoders ConditionalAverages library to sum price×volume, volume, and volume×price² over a fixed trailing time window (the day-count converted to milliseconds), computed fresh on every bar: VWAP = Σ(price·volume)/Σvolume, variance = Σ(volume·price²)/Σvolume − VWAP² (floored at zero), σ = √variance. In Standard mode, bands = VWAP ± multiplier×σ. In Symmetrical mode, bands = VWAP ± (multiplier/100)×VWAP — a flat percentage envelope rather than a statistical one.

Aggregated volume — When enabled, the script pulls volume via request.security from up to four independently configured symbols and sums them before it feeds the rolling VWAP formula above, in place of using only the current chart's own volume. This is designed for instruments whose real volume is fragmented across multiple venues (the default four fields point at the same crypto pair listed on four different exchanges), but the symbol fields can be changed to any ticker.

Initial Balance — Two Tokyo-time session windows are compared bar-by-bar: a 1-hour opening range (09:00–10:00) that seeds a box's high/low the moment it starts, and the surrounding full session (09:00–15:00) across which that box's right edge is extended. A rolling array retains only the most recent N day-boxes (the configured day count), deleting the oldest box once that limit is exceeded.

Alerts — Every alert fires at most once per bar close, formatted as: VWAP+|{ticker} {timeframe} {price}|{event name}.

🔶 SETTINGS

🔹 Background Mode
  • Background Mode: Dark Background (default) / Light Background / Custom. Dark and Light each lock every VWAP, band, previous-period marker, and IB color to a fixed palette tuned for that background tone — the color pickers below have no effect in these two modes. Custom releases the lock and uses exactly the color you've set on each line.


🔹 Anchored VWAP Settings (VWAP1–VWAP5, five independent slots)
  • VWAP1 / VWAP2 / VWAP3 / VWAP4 / VWAP5: Enables that slot; all five are off by default.
  • Anchor Period: Day / Week / Month / Quarter / Year — sets when that slot's VWAP resets.
  • VWAP: Line color for that slot.
  • Bands: Color for the 1-standard-deviation upper/lower bands.
  • Fill: Color for the band-fill zone.


🔹 Previous VWAP Markers
  • pDay / pWeek / ppWeek / pMonth / ppMonth / pQuarter / ppQuarter / pYear: Each toggle draws that completed period's VWAP channel (box + line + labels) projected to the right of the chart; all off by default.
  • Color (per marker): Sets the box/line/label tint for that specific marker.


🔹 Rolling VWAP
  • 7D / 30D / 90D / 365D: Enables that rolling-window slot; all four are on by default.
  • Day Count: Choose the rolling window length from a preset list (1/3/5/7/14/21/28/30/60/90/182/365 days) — independent of the slot's label.
  • RVWAP: Line color for that slot's rolling VWAP.
  • Bands: Color for that slot's deviation bands.
  • Fill: Color for that slot's band-fill zone.


🔹 Rolling VWAP StdDev Bands
  • Use Aggregated Volume: Combines volume from the checked exchanges below into the rolling VWAP calculation instead of using only the current chart's volume.
  • Deviation Bands: Symmetrical (flat percentage bands around VWAP) or Standard (statistical standard-deviation bands).
  • Multiplier: Scales band width (minimum 0.5, in steps of 0.5).
  • Exchange 1 / 2 / 3 / 4: Toggles whether that symbol's volume is included in the aggregate.
  • Symbol fields (Exchange 1–4): Set which instrument's volume feeds each exchange slot — default to the same pair across four major exchanges, but any symbol can be used.


🔹 Initial Balance Range
  • Show IB Range: Toggles the Initial Balance box, built from the Tokyo session (09:00–15:00, with the 09:00–10:00 opening range defining the box's high/low).
  • Days: How many days of IB boxes stay visible before the oldest is removed.
  • Color: Box border/fill tint.


🔹 Alerts
  • VWAP1–VWAP5 Touch: Fires once per bar close the instant price wicks touch that anchored VWAP, regardless of direction (that VWAP must be enabled).
  • 7D/30D/90D/365D RVWAP Touch: Same touch logic for each enabled rolling VWAP.


🔶 DISCLAIMER

This indicator and all its signals, markers, and alerts are provided for technical analysis study and research reference only. They do not constitute investment advice, financial advice, trading recommendations, or solicitations to buy or sell any asset. Financial market trading involves substantial risk; investors may lose part or all of their principal. Past performance does not represent and does not guarantee future results. All trading decisions made using this indicator are the sole responsibility of the user. The author and publishing platform assume no legal liability. Please fully understand market rules and your own risk tolerance, and consult a licensed professional financial advisor when necessary.


━━━━━━━━━━━━━━━━━━━━━━━━━━━━
中文版本 CHINESE VERSION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━

VWAP+ | 多重VWAP通道 [Y.Algo] — 5組獨立錨定VWAP、滾動多交易所VWAP帶、前期區間標記與時段初始平衡

VWAP+ 在同一張圖表上疊加最多九組獨立的 VWAP 結構——五組可自由錨定的 VWAP(日至年)、四組可選聚合多交易所成交量的滾動 VWAP、前一完整週期 VWAP 通道的靜態快照,以及一個時段初始平衡箱型——讓你不必切圖或疊多個指標,就能同時讀懂各個你在交易的時框上的公允價值。

完全開源(CC BY-NC-SA 4.0)——以下完整說明每一項計算,原始碼公開可查。

🔶 用途說明

VWAP+ 的設計是一整面「多時框公允價值參考牆」,而非單一訊號指標。你可以疊上五組獨立錨定的 VWAP(各自指定日/週/月/季/年),再搭配四組可自訂天數窗口的滾動 VWAP,同時觀察價格對所有這些線的相對位置。當多條 VWAP 收斂成一條窄帶,該價格區往往形成較強的支撐壓力匯聚;當它們彼此散開,代表市場正被不同時框的公允價值參考拉扯。

錨定 VWAP 較適合用來框定波段/部位偏向——把插槽設定為週、月、季、年,即可一眼看出價格是否同時站在(或跌破)各個時框的「機構級」公允價值之上,並把任一條線的站回或跌破視為該時框上潛在的盤勢轉換。滾動 VWAP 的行為不同:因為它以固定的回看時間窗滾動、而非在週期邊界重置,所以不會在時段或週期開盤時跳空,在加密貨幣這類 24 小時市場上是更平滑、更一致的參考線。

前期 VWAP 標記會把上一個(或上上一個)已完整結束週期的 VWAP 通道,以固定快照的形式投影到圖表右側,讓你有一條靜態的歷史參考帶,用來判斷目前價格相對於市場上次收在哪個公允價值區間是偏貴還是偏便宜。搭配以東京時段第一小時建立的初始平衡箱型作為時段區間參考,再啟用觸及警報,就不必手動盯著每一條 VWAP。

🔹 背景模式——三段式配色管理
VWAP+ 沒有多空主題色(因為它是參考線工具,不是趨勢/訊號指標),改用「背景模式」三選一,一次管理所有 VWAP、標準差帶、前期標記與 IB 框的顏色。黑色背景與白色背景各自鎖定一組對應該背景色調的固定配色,並會覆蓋下方每一條線的個別顏色設定,讓大多數人一鍵切換就不必煩惱可見度。切到「自訂」則解除鎖定,完全依你在每條 VWAP、每組標準差帶、每個前期標記與 IB 框個別設定的顏色顯示,可見度自己把關。全指標共 36 個顏色設定點——5 條錨定 VWAP、4 條滾動 VWAP、8 個前期 VWAP 標記、1 個 IB 區間框——皆由這個開關統一控管。

🔹 5組獨立錨定 VWAP
五個獨立的 VWAP 插槽(VWAP1–VWAP5)各自可指定錨定週期——日、週、月、季、年——並各自獨立開關,預設全部關閉,讓你自由組合出所需的時框組合。每個插槽各自繪製其 VWAP 線,搭配 1 個標準差的上下帶與可填色區域,顏色皆可完全自訂,讓你在同一張圖上同時檢視多個時框的公允價值。

🔹 前期 VWAP 區間標記
八個獨立開關(前日、前週、前前週、前月、前前月、前季、前前季、前年)各自會把對應已結束週期的 VWAP 通道——上帶、下帶與 VWAP 線——以箱型加標籤線的形式投影到圖表右側。這是一個凍結的歷史快照,而非即時更新的序列,提供一條穩定的參考帶,用來比較目前價格相對於市場上一個週期收在哪個公允價值區間。

🔹 4組滾動 VWAP(可選聚合多交易所成交量)
四組獨立的滾動窗口 VWAP(預設 7D/30D/90D/365D,天數皆可從預設清單自由調整)計算真正的「回看時間窗」VWAP,不隨任何週期邊界重置。可選的聚合成交量模式會合併最多四個獨立設定標的的成交量(預設指向四大交易所的 BTC 交易對,但可改為任何標的)後再送入 VWAP 計算——適合成交量分散在多個交易場所的市場。每組滾動 VWAP 周圍的偏差帶,可在「百分比對稱」與「統計標準差」兩種模式間切換,並可用倍數調整帶寬。

🔹 初始平衡區間(東京時段)
以東京交易時段(09:00–15:00)畫出箱型,其高低點由該時段的第一小時(09:00–10:00)決定——這正是拍賣市場理論中經典的「初始平衡(Initial Balance)」概念。箱型會延伸涵蓋整個時段,且可設定保留在圖表上的天數,讓你判斷當前時段是正在突破、還是仍被限制在開盤第一小時的區間內。

🔹 觸及警報系統
九個獨立開關的警報,會在價格影線碰觸任一啟用中的錨定 VWAP(VWAP1–VWAP5)或滾動 VWAP(7D/30D/90D/365D)的瞬間觸發,不分逼近方向——單純提醒你價格已到達一條值得關注的公允價值參考線,於每根 K 棒收盤時最多觸發一次。

🔶 技術細節

VWAP+ 完全開源(CC BY-NC-SA 4.0),以下完整說明運作方式。

背景配色——黑色與白色模式皆透過同一個切換函數,把每個顏色設定對應到兩組寫死的固定配色之一:黑色背景使用高透明度的白階配色,白色背景使用較深的藏青/灰階配色。固定模式生效時,下方的顏色選擇器仍會被讀取,但其數值會被捨棄不用。選擇自訂則直接跳過此切換,原樣傳回你所設定的每個顏色,讓每個選色器都實際生效。

錨定 VWAP——五個插槽各自呼叫 Pine Script 內建函數 ta.vwap(source, 週期起始旗標, 1),以 hlc3 為價格來源;週期起始旗標依所選錨定週期由 timeframe.change('D'/'W'/'M'/'3M'/'12M') 觸發。VWAP 與其帶線會在每個錨定週期開始時重置累積歸零;倍數 1 代表帶線畫在「以量價加權的價格標準差」1 倍處,隨週期推進而擴張或收窄。

前期標記——每根 K 棒都會快取剛結束週期的上帶、下帶與 VWAP 值(於重置前一根取樣)。當圖表來到最後一根 K 棒時,這些快取值會被一次性繪製為靜態箱型、一條虛線 VWAP 線與三個標籤——之後不再更新,是固定快照而非即時序列。

滾動 VWAP——與錨定 VWAP 不同,此路徑使用 PineCoders ConditionalAverages 函式庫,在固定的回看時間窗(天數換算為毫秒)內加總 price×volume、volume 與 volume×price²,每根 K 棒重新計算:VWAP = Σ(price·volume)/Σvolume,變異數 = Σ(volume·price²)/Σvolume − VWAP²(下限為零),σ = √變異數。Standard 模式下,帶線 = VWAP ± 倍數×σ;Symmetrical 模式下,帶線 = VWAP ± (倍數/100)×VWAP——為一個固定百分比包絡,而非統計性帶線。

聚合成交量——啟用時,腳本會透過 request.security 從最多四個獨立設定的標的抓取成交量並加總,取代僅使用目前圖表自身的成交量,再送入上述滾動 VWAP 公式。此設計是為了成交量分散於多個交易場所的商品(預設四個欄位指向同一加密貨幣交易對在四家交易所的成交量),但欄位可改為任何標的代碼。

初始平衡——逐根 K 棒比較兩個東京時區時段窗口:一個 1 小時的開盤區間(09:00–10:00),在其開始時決定箱型的高低點;以及涵蓋整個時段的 09:00–15:00 區間,箱型的右緣會延伸至此範圍內。一個滾動陣列僅保留最近 N 個日箱型(依所設定天數),超過上限時刪除最舊的箱型。

警報——每個警報於每根 K 棒收盤時最多觸發一次,格式為:VWAP+|{標的} {時框} {價格}|{事件名稱}。

🔶 設定說明

🔹 背景模式
  • 背景模式:黑色背景(預設)/白色背景/自訂。黑色與白色背景會將所有 VWAP、帶、前期標記與 IB 框的顏色鎖定為對應該背景的固定配色,此時下方各條線的顏色設定不生效;切到自訂則解除鎖定,完全依你為每條線分別設定的顏色顯示。


🔹 主要 VWAP 設定(VWAP1–VWAP5,五組獨立插槽)
  • VWAP1 / VWAP2 / VWAP3 / VWAP4 / VWAP5:啟用該插槽;五組預設皆為關閉。
  • 錨定週期:日/週/月/季/年——設定該插槽 VWAP 的重置時機。
  • VWAP:該插槽 VWAP 線的顏色。
  • Bands:1 個標準差上下帶的顏色。
  • Fill:帶線填色區域的顏色。


🔹 前期 VWAP 標記
  • 前日 / 前週 / 前前週 / 前月 / 前前月 / 前季 / 前前季 / 前年:各自開關會將該已結束週期的 VWAP 通道(箱型+線+標籤)投影至圖表右側;預設皆為關閉。
  • 顏色(各標記):設定該標記的箱型/線/標籤色調。


🔹 滾動 VWAP
  • 7D / 30D / 90D / 365D:啟用該滾動窗口插槽;四組預設皆為開啟。
  • 天數:從預設清單(1/3/5/7/14/21/28/30/60/90/182/365 天)自由選擇該插槽的滾動窗口長度,與插槽標籤無關。
  • RVWAP:該插槽滾動 VWAP 線的顏色。
  • Bands:該插槽偏差帶的顏色。
  • Fill:該插槽帶線填色區域的顏色。


🔹 滾動 VWAP 標準差帶
  • 使用聚合成交量:合併下方勾選交易所的成交量計算滾動 VWAP,取代僅使用目前圖表的成交量。
  • 偏差帶模式:Symmetrical(VWAP 上下對稱的百分比帶)或 Standard(統計標準差帶)。
  • 倍數:調整帶寬(最小 0.5,以 0.5 為單位遞增)。
  • 交易所 1 / 2 / 3 / 4:開關該標的成交量是否納入聚合計算。
  • 標的欄位(交易所 1–4):設定每個交易所插槽所抓取的成交量標的,預設為同一交易對在四大交易所的成交量,可改為任何標的。


🔹 初始平衡區間
  • 顯示 IB 區間:開關初始平衡箱型,以東京時段(09:00–15:00)繪製,其高低點由 09:00–10:00 的開盤區間決定。
  • 天數:圖表上保留幾天的 IB 箱型,超過後自動刪除最舊的一個。
  • 顏色:箱型邊框/填色色調。


🔹 警報
  • VWAP1–VWAP5 觸及:價格影線碰到該錨定 VWAP 即於當根 K 棒收盤時觸發一次,不分逼近方向(該 VWAP 需先啟用)。
  • 7D/30D/90D/365D RVWAP 觸及:同樣的觸及邏輯,適用於每一組已啟用的滾動 VWAP。


🔶 免責聲明

本指標及其所產生之所有信號、標記與警報,僅供技術分析學習與研究參考,不構成任何形式之投資建議、財務建議、交易推薦或買賣邀約。金融市場交易涉及高度風險,投資人可能損失部分或全部本金。過去表現不代表亦不保證未來結果。使用本指標之任何交易決策均由使用者自行判斷並承擔完全責任,作者與發布平台不負任何法律責任。請充分了解市場規則與自身風險承受能力,必要時諮詢具備合法資質的專業財務顧問。
Release Note
滾動 VWAP 自訂週期

滾動 VWAP 的 4 組週期欄位(原本標示 7D / 30D / 90D / 365D)現在可直接輸入任意天數(1~3650 天),不再限定於預設選項清單。圖表標籤會自動顯示你輸入的實際天數,4 組欄位互不影響,可各自設成任何週期並列比較。


Rolling VWAP Custom Period

The 4 Rolling VWAP period fields (previously labeled 7D / 30D / 90D / 365D) now accept any custom day count (1–3650 days) instead of being limited to a preset dropdown. The on-chart label automatically reflects whatever day count you enter, and each of the 4 slots is independent — set them to any periods you want and compare side by side.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน