OPEN-SOURCE SCRIPT

Luxy VWAP Magic - MTF Projection Engine

243
This indicator transforms the classic VWAP into a comprehensive trading system. Instead of switching between multiple indicators, you get everything in one place: multi-timeframe analysis, statistical bands, momentum detection, volume profiling, session tracking, and divergence signals.

What Makes This Different
Traditional VWAP indicators show a single line. This tool treats VWAP as a foundation for complete market analysis. The indicator automatically detects your asset type (stocks, crypto, forex, futures) and adjusts its behavior accordingly. Crypto traders get 24/7 session tracking. Stock traders get proper market hours handling. Everyone gets institutional-grade analytics.

Anchor Period Options

The anchor period determines when VWAP resets and recalculates. You have three categories of options:
Time-Based Anchors:
  • Session - Resets at market open. Best for intraday stock trading where you want fresh VWAP each day.
  • Day - Resets at midnight UTC. Standard option for most traders.
  • Week / Month / Quarter / Year - Longer reset periods for swing traders and position traders who want broader context.


Rolling Window Anchors:
  • Rolling 5D - A sliding 5-day window that never resets. Solves the Monday problem where weekly VWAP equals daily VWAP on first day of week.

  • Rolling 21D - Approximately one month of trading data in continuous calculation. Excellent for crypto and forex markets that trade 24/7 without clear session breaks.


Event-Based Anchors:
  • Dividends - Resets on ex-dividend dates. Track institutional cost basis from dividend events.
  • Splits - Resets on stock split dates. Useful for analyzing post-split trading behavior.
  • Earnings - Resets on earnings report dates. See where volume-weighted trading occurred since last quarterly report.


cuplikan


Standard Deviation Bands

Three sets of bands surround the main VWAP line:
  • Band 1 (Aqua) - Plus and minus one standard deviation. Approximately 68% of price action occurs within this range under normal distribution. Touches suggest minor extension.
  • Band 2 (Fuchsia) - Plus and minus two standard deviations. Only 5% of trading should occur outside this range statistically. Touches here indicate significant overextension and high probability of mean reversion.
  • Band 3 (Purple) - Plus and minus three standard deviations. Touches are rare (0.3% probability) and represent extreme conditions. Often marks climax moves or panic selling/buying.


Each band can be toggled independently. Most traders show Band 1 by default and add Band 2 and 3 for specific setups or volatile instruments.

cuplikan


Multi-Timeframe VWAP System
The MTF section plots previous period VWAPs as horizontal support and resistance levels:
  • Daily VWAP - Previous day's final VWAP value. Key intraday reference level.
  • Weekly VWAP - Previous week's final VWAP. Important for swing traders.
  • Monthly VWAP - Previous month's final VWAP. Institutional benchmark level.
  • Quarterly VWAP - Previous quarter's final VWAP. Major support/resistance for position traders.
  • Previous Day VWAP - Yesterday's closing VWAP specifically, separate from current daily calculation.


The Confluence Zone percentage setting determines how close multiple VWAPs must be to trigger a confluence alert. When two or more timeframe VWAPs converge within this threshold, you get a high-probability support/resistance zone.

cuplikan


Session VWAPs for Global Markets
For forex, crypto, and futures traders who operate in 24/7 markets, the indicator tracks three major global sessions:
  • Asia Session - UTC 21:00 to 08:00. Gold colored line. Typically lower volatility, range-bound action that sets overnight levels.
  • London Session - UTC 08:00 to 17:00. Orange colored line. Often determines daily direction with high volume European participation.
  • New York Session - UTC 13:00 to 22:00. Blue colored line. Highest volume session globally. Sharp directional moves common.


Previous session VWAP values display as horizontal lines when each session closes, acting as intraday support and resistance. The table shows which sessions are currently active with checkmarks.

On-Chart Labels and Signals
The indicator plots several types of labels directly on price action when significant events occur:

Volume Spike Labels
Fire when current bar volume exceeds configurable thresholds relative to both the previous bar and the 20-bar average. Default settings require 300% of previous bar AND 200% of average volume. Green labels indicate bullish candles. Red labels indicate bearish candles. These spikes often mark institutional entry points.

Momentum Shift Labels
Appear when VWAP acceleration changes direction. The Slowing label warns when an active trend loses steam, often preceding reversal. The Accelerating label confirms trend continuation or potential bottom during downtrends. Filters available to show only reversal signals in existing trends.

VWAP Squeeze Labels
Detect when standard deviation bands contract relative to ATR (Average True Range). Low volatility compression often precedes explosive breakout moves. When the squeeze fires (releases), a label appears with directional prediction based on VWAP slope.

Divergence Labels
Mark price/volume divergences using CVD (Cumulative Volume Delta) analysis:
  • Bullish divergence: Price makes lower low, but CVD makes higher low. Hidden accumulation despite price weakness.
  • Bearish divergence: Price makes higher high, but CVD makes lower high. Hidden distribution despite price strength.


cuplikan


Dynamic VWAP Coloring

The main VWAP line changes color based on its slope direction:
  • Green - VWAP is rising. Institutional buying pressure. Volume-weighted price increasing.
  • Red - VWAP is falling. Institutional selling pressure. Volume-weighted price decreasing.
  • Gray - VWAP is flat. Consolidation or balance between buyers and sellers.

This coloring can be disabled for a static blue line if you prefer cleaner visuals. The VWAP label next to the line shows the current trend direction and delta percentage.

Calculated Projection Cone

One of the most powerful features is the Calculated Projection Cone. Unlike traditional extrapolation methods that simply extend a trend line forward, this system analyzes what actually happened in similar market conditions throughout the chart's history.

How It Works:
The system classifies each bar into one of 27 unique market states:
  • Z-Score Level - LOW (oversold), MID (fair value), or HIGH (overbought) based on configurable thresholds
  • Trend Direction - DOWN, FLAT, or UP based on VWAP slope
  • Volume Profile - LOW (below 80%), NORMAL (80-150%), or HIGH (above 150%) relative volume


When you look at the current bar, the indicator:
1. Identifies the current market state (e.g., LOW Z-Score + UP Trend + HIGH Volume)
2. Searches through all historical bars on the chart that had the same state
3. Calculates what happened in those bars X bars later (where X is your projection horizon)
4. Shows you the probability of up/down and the average move size

Visual Elements:
  • Probability Cone - Colored green (bullish probability above 55%), red (bearish below 45%), or gold (neutral). The cone width represents the historical range of outcomes (roughly the 20th to 80th percentile).
  • Center Line - Shows the average expected price based on historical outcomes in similar conditions.
  • Probability Label - Displays direction probability and average move. Example: "67% UP (+0.8%)" means 67% of similar past cases moved up, averaging 0.8% gain.


Fallback System:
When the exact 27-state match has insufficient historical data:
  • First fallback: Uses Z-Score plus Trend only (9 broader states, ignoring volume)
  • Second fallback: Uses Z-Score only (3 states)
  • When fallback is active, confidence automatically adjusts


Settings:
  • Projection Horizon - How many bars forward to analyze outcomes (5, 10, 15, or 20 bars, default 10)
  • Lookback Period - Historical data window in days (30-252, default 60)
  • Minimum Samples - Cases needed before using fallback (5-30, default 10)
  • Z-Score Threshold - Bucket boundary for LOW/MID/HIGH classification (1.0, 1.5, or 2.0 sigma)
  • Cloud Transparency - Adjust visibility (50-95%)
  • Colors - Customize bullish, bearish, and neutral cone colors


Confidence Levels:
  • HIGH - 30 or more similar historical cases found
  • MEDIUM - 15-29 similar cases
  • LOW - Fewer than 15 cases (more uncertainty)


cuplikan


IMPORTANT DISCLAIMER:
The Calculated Projection is based on past patterns only. It is NOT a price prediction or financial advice. Similar market states in the past do not guarantee similar outcomes in the future. The probability shown is historical frequency, not a guarantee. Always combine with other analysis and never rely solely on projections for trading decisions.

Alert Conditions
The indicator includes over 20 pre-built alert conditions:
Price vs VWAP:
  • Price crosses above VWAP
  • Price crosses below VWAP


Band Touches:
  • Price touches plus or minus one sigma band
  • Price touches plus or minus two sigma band (extreme)
  • Price touches plus or minus three sigma band (very extreme)


Z-Score Extremes:
  • Z-Score crosses above plus two (overbought extreme)
  • Z-Score crosses below minus two (oversold extreme)


Momentum and Trend:
  • Momentum slowing
  • Momentum accelerating
  • Trend turns bullish/bearish/neutral


Volume:
  • Volume spike detected


CVD Direction:
  • Buyers take control
  • Sellers take control


High Probability Signals:
  • Bullish reversal signal (oversold plus accelerating momentum)
  • Bearish reversal signal (overbought plus slowing momentum)


MTF and Special:
  • MTF confluence zone entry
  • VWAP squeeze fired
  • Bullish/Bearish divergence detected
  • Any significant signal (catch-all)


All signals use confirmed bar data to prevent false alerts from incomplete candles.

cuplikan


Settings Overview
Settings are organized into logical groups:
VWAP Settings
  • Anchor Period selection
  • Show/Hide VWAP line
  • Dynamic coloring toggle
  • VWAP label visibility


Bands Visibility
  • Toggle each of three bands independently


Info Table
  • Show/Hide table
  • Table position (9 options)
  • Text size
  • Volume spike label settings with adjustable thresholds
  • Momentum label settings with filters
  • Signal labels limited to 5 most recent (auto-managed)
  • Probability engine lookback period


Multi-Timeframe VWAP
  • Enable/Disable MTF system
  • Show MTF in table
  • Show MTF lines on chart
  • Individual timeframe toggles
  • Confluence zone threshold
  • Squeeze detection toggle


Session VWAPs
  • Enable/Disable session tracking
  • Apply to all assets option
  • Show session labels


Divergence Detection
  • Enable/Disable divergence
  • Pivot lookback period
  • Show divergence labels


Calculated Projection
  • Enable/Disable projection cone
  • Projection horizon (5, 10, 15, or 20 bars)
  • Lookback period in days (30-252)
  • Minimum samples threshold
  • Z-Score classification threshold (1.0, 1.5, or 2.0 sigma)
  • Cloud transparency adjustment
  • Bullish, bearish, and neutral colors



The Info Table - Your Trading Dashboard
The right side of your chart displays a compact table with up to twelve metrics.

cuplikan

cuplikan


Row-by-Row Breakdown:
  1. Asset and Period - Shows what the indicator detected (US Stock, Crypto, Forex, etc.) and your selected anchor period. The detection happens automatically based on exchange data, so VWAP resets and calculations match your actual trading instrument.
  2. Delta Percentage - How far current price sits from VWAP, expressed as a percentage. Positive means price trades above fair value. Negative means below. Large delta values (beyond 1-2%) often precede mean reversion moves. Day traders watch this for overextension.
  3. Z-Score - Statistical deviation from VWAP measured in standard deviations. Unlike raw delta, Z-Score accounts for volatility. A 2% move in a volatile biotech stock differs from 2% in a stable utility. Z-Score normalizes this. Values beyond plus or minus two sigma occur only 5% of the time statistically.
  4. Trend Direction - Whether VWAP itself is rising, falling, or flat. Rising VWAP means the volume-weighted average price is increasing, which indicates institutional accumulation. Falling VWAP suggests distribution. This differs from price trend since it weights by volume.
  5. Momentum State - Is the trend accelerating or slowing down? This measures the rate of change in VWAP slope. When an uptrend shows slowing momentum, it often precedes reversal. Accelerating momentum in a downtrend can signal capitulation and potential bottom.
  6. Relative Volume - Current bar volume compared to the 20-bar average, shown as percentage. Values above 150% indicate above-average activity. Spikes above 200-300% often mark institutional involvement. Low volume (below 80%) warns of potential fake moves.
  7. MTF Bias - Four checkmarks or X marks showing whether price sits above or below Daily, Weekly, Monthly, and Quarterly VWAP. Four checkmarks means strong bullish alignment across all timeframes. Four X marks indicates bearish alignment. Mixed readings suggest consolidation or transition.
  8. Band Probabilities - Historical statistics showing how often price touched each standard deviation band over your lookback period. This helps you understand if mean reversion or trend following works better for your specific instrument.
  9. Session Status - Which global trading sessions are currently active (Asia, London, New York). Shows checkmarks for active sessions. Important for forex and crypto traders who need to know when major liquidity windows open and close.
  10. Divergence State - Whether the indicator detects bullish or bearish divergence between price and cumulative volume delta. Bullish divergence occurs when price makes lower lows but buying pressure (CVD) makes higher lows, suggesting hidden accumulation.
  11. Confidence Score - A weighted composite of all factors displayed as a progress bar and percentage. Combines MTF alignment, Z-Score, trend direction, volume delta, momentum, and relative volume into a single 0-100 score. Higher scores indicate stronger conviction setups.
  12. Calculated Projection - When the Projection Cone is enabled, shows the historical probability of price direction and expected move. For example: "▲ 67% (+0.8%)" means in similar market states historically, price moved up 67% of the time with an average gain of 0.8%. The system analyzes 27 unique market states based on Z-Score, Trend, and Volume conditions.



Recommended Use Cases
Day Trading Stocks:
Use Session anchor with Band 1 visible. Watch for price returning to VWAP after morning move. Volume spikes near VWAP often mark institutional accumulation zones.
Swing Trading:
Use Weekly or Rolling 21D anchor. Enable MTF lines for Daily and Weekly levels. Trade pullbacks to these levels in direction of MTF bias.
Crypto and Forex:
Enable Session VWAPs. Use Rolling anchors to avoid artificial resets. Monitor session transitions for breakout opportunities.
Mean Reversion:
Focus on Z-Score reaching plus or minus two. Add Band 2 visibility. Combine with slowing momentum for highest probability reversals.
Trend Following:
Watch MTF bias alignment. Four checkmarks plus accelerating momentum plus high volume confirms trend continuation setups.

Projection Planning:
Enable the Calculated Projection to see what happened historically in similar market conditions. Use 5-10 bars for intraday setups, 15-20 bars for swing trade planning. Focus on high probability readings (above 60%) with HIGH confidence (30 or more samples). The cone shows the probable range of outcomes based on actual historical data. Combine with other factors like MTF alignment and volume for higher conviction setups.


Important Notes

  • The indicator does not repaint. MTF values use previous period's confirmed data.
  • Rolling VWAP works best on 15-minute timeframes and above due to bar lookback requirements.
  • Session VWAPs apply to global markets by default (forex, crypto, futures). Enable the all-assets option for stocks if desired.
  • Volume data for forex represents tick volume, not actual traded volume.
  • All alert conditions fire only on confirmed (closed) bars to prevent false signals.
  • The Calculated Projection updates each bar as market state changes. This is expected behavior. The projection shows probabilities based on similar past conditions, not a fixed prediction.



Q AND A

Q: Does this indicator repaint?
A: No. The main VWAP calculation uses standard TradingView VWAP methodology. Multi-timeframe values use previous period's confirmed data with appropriate lookahead settings. All alert signals require bar confirmation.

Q: Why does my Rolling VWAP look different on 1-minute versus 15-minute charts?
A: Rolling VWAP calculates across a fixed number of trading days. On very short timeframes, the bar lookback may hit TradingView limits. For best Rolling VWAP accuracy, use 15-minute or higher timeframes.

Q: Can I use this on any instrument?
A: Yes. The indicator automatically detects asset type and adjusts behavior. Stocks use standard market hours. Crypto uses 24/7 calculations. Forex uses tick volume. Everything adapts automatically.

Q: What does the Confidence Score actually measure?
A: The score combines six weighted factors: MTF alignment (25%), Z-Score position (20%), Trend direction (20%), CVD pressure (15%), Momentum state (10%), and Relative volume (10%). Higher scores indicate more factors aligned in one direction.

Q: Why are Session VWAPs not showing on my stock chart?
A: Session VWAPs apply to 24-hour markets by default (forex, crypto, futures). For stocks, enable the Use for All Assets option in Session VWAP settings.

Q: The Divergence labels appear delayed. Is this a bug?
A: Divergence detection requires pivot confirmation, which needs bars on both sides of the pivot point. The label appears at the actual pivot location (several bars back) once confirmed. This is intentional and prevents false signals.

Q: Can I change the band colors?
A: Yes. Each of the three bands has its own color input setting. You can customize Band 1, Band 2, and Band 3 colors to match your preferences. The defaults are Aqua, Fuchsia, and Purple. The main VWAP line color adapts dynamically based on slope direction or can be set to static blue.

Q: How do I set up alerts?
A: Right-click on the chart, select Add Alert, choose this indicator, and select your desired condition from the dropdown. All conditions include descriptive alert messages with relevant data.

Q: What is the Probability Engine lookback period?
A: This setting determines how many trading days the indicator analyzes to calculate band touch rates and mean reversion statistics. Default is 60 days (approximately 3 months). Longer periods provide more stable statistics but may miss recent behavior changes.

Q: Why do I see fewer labels than expected?
A: Signal labels (Volume, Momentum, Squeeze, Divergence) are limited to 5 most recent labels on the chart to keep it clean. When a new label appears, the oldest one is automatically removed. Additionally, momentum labels have several filters: check the slope multiplier setting (higher values require stronger trends) and the Only Reversal Signals option (when enabled, labels only appear for potential reversals, not trend confirmations).

Q: What is the Calculated Projection and how accurate is it?
A: The Calculated Projection analyzes what happened in past market conditions similar to the current state. It classifies each bar by Z-Score level, Trend direction, and Volume profile (27 unique states), then shows the historical probability of up vs down and the average move size. It is NOT a price prediction or guarantee. The probability shown is how often similar conditions led to up/down moves historically, not a future guarantee. Always use it as one input among many.

Q: Why does the Projection probability change?
A: The projection updates on each bar as market state changes. If Z-Score moves from LOW to MID, or trend shifts from UP to FLAT, the system looks up a different historical category. This is expected behavior. The projection shows what happened in similar past conditions to the current bar's state.

Q: The Projection shows LOW confidence. What does that mean?
A: Confidence levels indicate sample size: HIGH means 30 or more historical cases found, MEDIUM means 15-29 cases, LOW means fewer than 15 cases. When sample size is low, the system uses a fallback: first aggregating by Z-Score plus Trend only (ignoring volume), then by Z-Score only. LOW confidence means less statistical reliability, so weight other factors more heavily in your decision.

Q: Why does the cone sometimes show 50/50 probability?
A: A 50/50 reading means that in similar past market states, price moved up roughly half the time and down half the time. This indicates a neutral or balanced condition where historical patterns provide no directional edge. Consider waiting for a higher probability setup or using other analysis methods.


CREDITS AND ACKNOWLEDGMENTS

Methodology Foundation:
  • VWAP (Volume Weighted Average Price) - Standard institutional benchmark calculation, widely used since the 1980s for algorithmic execution and fair value assessment
  • Standard Deviation Bands - Statistical volatility measurement applying normal distribution principles to price deviation from mean
  • Z-Score Analysis - Classic statistical normalization technique for comparing values across different volatility regimes
  • Cumulative Volume Delta (CVD) - Order flow analysis concept measuring aggressive buying versus selling pressure


Concept Integration:
  • Mean reversion probability engine - Custom historical statistics tracking for band touch rates
  • Momentum acceleration detection - Second derivative analysis of VWAP slope changes
  • VWAP Squeeze - Volatility compression concept adapted from TTM Squeeze methodology applied to VWAP bands versus ATR
  • Confidence scoring system - Weighted composite scoring combining multiple technical factors
  • Calculated Projection Cone - Probability-based projection using 27-state market classification (Z-Score, Trend, Volume) with historical outcome analysis and weighted fallback system


All calculations use standard public domain formulas and TradingView built-in functions. No proprietary third-party code was used.

For questions, feedback, or feature requests, please comment below or send a private message.

Happy Trading!

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.