OPEN-SOURCE SCRIPT
Atualizado

VWAP Suite [ChartSmith]

387
Pine Script®
Notas de Lançamento
VWAP Suite is a precision VWAP engine with multi-band standard deviation envelopes, flexible anchor periods, and per-band candle coloring — built for futures traders who need clean, correctly-reset VWAPs across every session boundary.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ANCHOR PERIODS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Every VWAP is only as reliable as its reset logic. This suite anchors to the actual session boundaries futures traders care about — not midnight UTC or an arbitrary daily open.

ETH Session — Resets at 18:00 ET each evening (CME session open). The standard anchor for ES, NQ, CL, and other CME futures.

RTH Session — Resets at 9:30 AM ET. All plots and candle colors are automatically masked outside of regular trading hours (9:30–16:15 ET), keeping pre-market and after-hours bars at their default chart color.

Weekly — Resets at Sunday 18:00 ET (CME week open). Falls back to the first Monday bar on equity charts that don't trade Sunday.

Monthly — Resets at 18:00 ET on the last calendar day of the month. Includes a DST-safe look-ahead to prevent the anchor from firing a day early during daylight saving transitions.

Quarterly — Resets on the first bar of each new quarter.

Yearly — Resets on the first bar of the new year.

Manual override: Enable Override Anchor Time and enter any HHMM value in 24-hour US Eastern Time to set a custom reset — useful for non-standard session windows or non-US markets.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STANDARD DEVIATION BANDS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Three fully independent band layers sit above and below the VWAP line. Each band has its own multiplier, line color, fill region, and candle coloring settings.

Band 1 (default 1.0×) — Inner fair-value zone. The typical mean-reversion boundary within a session.
Band 2 (default 2.0×) — Extended range. Marks price stretch relative to session value area.
Band 3 (default 3.0×) — Outer extreme. High-probability exhaustion zone.

Fill regions shade the space between adjacent layers:
- Band 1 ↔ VWAP (inner zone)
- Band 2 ↔ Band 1 (middle zone)
- Band 3 ↔ Band 2 (outer zone)

All multipliers adjust in 0.25 increments. Bands are always calculated regardless of line visibility, so candle coloring works even when a band's lines are turned off.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CANDLE COLORING
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

When enabled on any band, candles are painted based on where the close sits relative to that band's upper and lower levels. Each band distinguishes between up candles (close ≥ open) and down candles — four color slots per band, twelve total across all three.

Priority cascade (highest wins):
Band 3Band 2Band 1 → default chart color

This means if Band 3 coloring is active and price closes beyond the Band 3 level, that color takes precedence over any Band 1 or Band 2 color that would otherwise apply.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
PRICE SOURCE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The price component used in the VWAP accumulation is fully selectable:

OHLC/4 (default) · HLC/3 (typical price) · HL/2 (median) · Close · Open · High · Low

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
METHODOLOGY
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

The indicator accumulates three running sums — ΣPV, ΣP²V, and ΣV — reset at every anchor boundary. Standard deviation is derived from the population variance:

VWAP = ΣPV / ΣV
Variance = ΣP²V / ΣV − VWAP²
σ = √max(Variance, 0)

The max(Variance, 0) guard prevents floating-point rounding from producing a negative radicand on flat or low-volume bars. Zero-volume bars are floored to a near-zero value to avoid division-by-zero on synthetic instruments or data gaps.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
USAGE NOTES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

- Line width and style (solid, dashed, dotted) are controlled through TradingView's Style tab — no extra inputs needed.
- Add multiple instances of this script with different anchor periods to build a full multi-timeframe VWAP stack on one chart.
- The RTH Session anchor automatically hides all output outside market hours — no manual toggling required.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.