OPEN-SOURCE SCRIPT

Anchored VWAP Engine [Quantum Algo]

3 924
Anchored VWAP Engine [Quantum Algo]
====================================================

🔶 OVERVIEW

Anchored VWAP Engine is a multi-stream anchored Volume Weighted Average Price indicator that removes the hardest part of trading with anchored VWAP: choosing the anchor. The engine runs up to seven independently anchored VWAP streams that place and reset their own anchors automatically — the week open (the default stream), session open, month open, confirmed swing highs and swing lows, the highest-volume bar in a lookback, and a liquidity-sweep anchor that re-anchors from the exact bar where a stop run occurred. On top of the streams it adds volume-weighted deviation bands, automatic confluence cluster zones where multiple streams converge, band-rejection signals, and a stability metric that names which VWAP the market is currently respecting most.

Out of the box the chart shows a single clean line: the week-anchored Volume Weighted Average Price with its deviation bands. Every additional stream is one checkbox away.

🔶 WHAT IS AN ANCHORED VWAP?

The Volume Weighted Average Price is the average price of an instrument weighted by traded volume — the closest public approximation of the average position price of everyone who transacted since a chosen starting point. An anchored VWAP starts that calculation from a meaningful event rather than an arbitrary date: a weekly open, a swing low, a high-volume climax bar. Price above an anchored VWAP means the average participant since that event is in profit; price returning to it often behaves as a decision level, because it is where the average position breaks even. The power of the tool depends entirely on where it is anchored — which is exactly what this engine automates.

🔶 WHY THIS SCRIPT IS ORIGINAL

1. Automatic multi-anchor engine. Seven streams anchor and re-anchor themselves from objectively defined events — no manual anchor placement, no stale anchors, no guessing.

2. The liquidity-sweep anchor. When a swing level is wicked through and rejected — a stop run — the sweep stream re-anchors from that exact bar and colors itself by implication: the accumulation tone after a sell-side sweep, the distribution tone after a buy-side raid. Averaging from the stop-run bar tracks the entry basis of the participants who engineered it. To our knowledge this anchor type has not been published before.

3. Exact swing anchoring. Swing-anchored streams rebuild their sums retroactively from the true pivot bar once the pivot confirms, so the calculation is mathematically identical to a VWAP hand-anchored on the swing itself — not started late at the confirmation bar.

4. Confluence clusters. When two or more active streams converge within an Average True Range tolerance, the engine draws a cluster zone and labels its strength. Multiple independent volume-weighted averages agreeing on one price is the strongest form of VWAP confluence, detected automatically.

5. The In Control metric. An exponentially decayed crossing-rate measures how cleanly price is respecting each stream; the dashboard names the stream currently in control. Users learn which anchor matters today instead of watching all of them equally.

6. True volume-weighted deviation bands. The bands are built from the volume-weighted variance of the primary stream — not a simple price standard deviation — at two configurable widths, with band-rejection signals printed as a single σ character whose full context lives in the hover tooltip, protected by a signal cooldown.

7. Quiet by default. One stream, one set of bands, capped signals, and a compact dashboard. The engine detects everything; the chart shows only what is asked of it.

🔶 HOW IT WORKS

Streams: Each stream maintains volume-weighted price and variance sums that reset on its anchor event — new week, new session, new month, a confirmed swing, a lookback volume record, or a qualified liquidity sweep. Between events the sums accumulate bar by bar, producing the stream's live anchored VWAP.

Sweep detection: A sweep qualifies when price wicks through the last confirmed swing level but closes back inside it, with per-level memory so the same level cannot re-trigger. The sweep stream then re-anchors from that bar.

Deviation bands: The primary stream (selectable; week open by default) carries inner and outer bands at configurable sigma multiples computed from its own volume-weighted variance, with softly tinted zones between them.

Signals: A wick beyond the outer band with a close back inside, on the correct side of the VWAP, prints the σ rejection signal — reversion bias toward the average — evaluated on closed bars only and rate-limited by the cooldown.

Clusters: On the live bar the engine groups all active stream values within the tolerance and draws a labeled zone for each group of two or more.

Dashboard: A fully themeable panel lists every stream with its live distance from price in Average True Range units and side, plus the In Control stream, active cluster count, and the current band width.

Non-repainting: Anchors use confirmed events, sweeps and signals are evaluated at bar close, and swing streams rebuild exactly rather than approximately.

🔶 HOW TO USE IT

1. Works on any market with reliable volume — cryptocurrency, stocks, indices, futures. On the default settings, read the week-anchored VWAP as the institutional benchmark: above it with rising distance means the average weekly participant is in profit.
2. Treat the VWAP itself as the decision level and the outer bands as stretch: σ rejections at the outer band carry a reversion bias back toward the average.
3. Enable the swing and sweep anchors to study reactions: price returning to a sweep-anchored VWAP is returning to the average entry of the stop-run — a level worth watching.
4. Cluster zones are the highest-value levels the engine produces: several independent volume-weighted averages agreeing on one price. Watch how price behaves on first touch.
5. Use the In Control row to pick which stream deserves your attention today, and the distance column to see what is nearby before it is hit.
6. Intraday traders can switch the primary stream to Session Open; swing traders can promote Month Open.

🔶 SETTINGS

- Anchors: independent toggles for all seven streams, swing pivot length, highest-volume lookback. Default: Week Open only.
- Primary stream selection with inner and outer band multiples.
- Cluster detection with Average True Range tolerance.
- Signals: toggle, cooldown, and signals to keep.
- Individual colors for every stream plus accent and neutral colors.
- Themeable dashboard: position, four text sizes, title band, background, frame, grid, and three text colors.

🔶 ALERTS

- Bullish / Bearish Band Rejection — price rejected the outer deviation band of the primary stream.
- Price Crossed Above / Below Primary VWAP.
- VWAP Cluster Formed — two or more streams converged into a confluence zone.
- Sweep Anchor Reset — a liquidity sweep occurred and the sweep stream re-anchored from the stop-run bar.

🔶 FREQUENTLY ASKED QUESTIONS

Does the indicator repaint? No. Anchor events are confirmed before they act, swing streams rebuild exactly from the confirmed pivot bar, and signals are evaluated on closed bars. Swing confirmation carries its standard pivot lag by design.

Why do I only see one line? By default only the week-anchored stream is enabled for a clean first chart. Every other anchor is a checkbox in settings.

What makes the sweep anchor special? It averages price and volume from the exact bar where stops were run — the basis of the participants who engineered the move — rather than from a calendar date or swing alone.

Why is there no cluster or In Control reading? Both features compare multiple streams; enable two or more anchors and they activate.

Which markets should avoid it? Any Volume Weighted Average Price tool is only as good as the volume feed. On symbols with unreliable or synthetic volume reporting, treat every stream with caution.

🔶 CREDITS

The Volume Weighted Average Price was introduced by Stephen Berkowitz, Dennis Logue and Eugene Noser (1988), and the anchored application was popularized by Brian Shannon, whose work established anchoring from meaningful events as a discipline. This script gratefully acknowledges both. The multi-stream auto-anchoring engine, the liquidity-sweep anchor, the exact retroactive swing rebuild, confluence clustering, the In Control stability metric, and all code in this script are original work — no third-party or open-source script code was reused.

🔶 LIMITATIONS

Volume quality determines VWAP quality; symbols with unreliable volume produce unreliable averages. Deviation bands need bars to mature after each re-anchor. Cluster detection reports convergence, not a guarantee of reaction. The In Control metric measures recent respect, not future behavior. No indicator replaces independent analysis.

🔶 DISCLAIMER

This script is provided strictly for educational and informational purposes. It is not financial advice, an investment recommendation, or a solicitation to buy or sell any financial instrument. Past behavior of any average, band, or cluster does not guarantee future results. Trading involves substantial risk. Always do your own research and manage risk independently.

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.