OPEN-SOURCE SCRIPT

Order Flow VWAP Deviation [NeBlok]

1 407
ORDER FLOW VWAP DEVIATION [NeBlok]

Order Flow VWAP Deviation shows where price sits relative to fair value (VWAP) and who is in control, buyers or sellers, at each price level. It combines an anchored VWAP, deviation bands weighted by order flow, a 3D buy/sell volume profile with imbalance detection, band-rejection signals and a live dashboard. Everything is drawn in flat neon colors with large, readable labels.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
HOW IT WORKS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

1) ANCHORED VWAP (cyan line)
VWAP resets at the start of each Session, Week or Month (your choice). It is the volume-weighted average price for that period and works as the "fair value" line. Price above VWAP means buyers have control of the period. Price below means sellers do. A yellow background marks each reset bar.

2) ORDER-FLOW DEVIATION BANDS (red upper / green lower)
Standard VWAP bands are symmetric. These are not. Each bar's volume is split into estimated buy volume and sell volume using lower-timeframe (intrabar) data:
- The UPPER bands measure how far price has traveled from VWAP, weighted by BUY volume.
- The LOWER bands measure the same distance, weighted by SELL volume.
When aggressive buyers are active far above VWAP, the upper band widens more than the lower band, and the reverse is true for sellers. The bands expand toward the side where participation is strongest.

Two bands are drawn on each side:
- Inner band (1σ by default): normal rotation zone
- Outer band (2σ by default): extended or stretched zone
The flat neon fill between the inner and outer band highlights the extreme zones.

3) 3D ORDER-FLOW VOLUME PROFILE (right side of chart)
The profile covers the current anchor period. Each row is split into:
- Green segment = estimated buy volume
- Pink segment = estimated sell volume
Rows inside the Value Area are bright. Rows outside it are dimmed. A 3D extrusion adds depth and can be turned off.

Profile markings:
- POC: the price row with the most volume, drawn as a yellow line extending back across the period
- VAH / VAL: the top and bottom of the Value Area (70% of volume by default), drawn as purple dashed lines
- IMBALANCE ROWS: rows where one side outweighs the other by 1.5× or more get an orange outline and a label such as "2.2× BUY" or "1.8× SELL"
- ★ TOP IMBALANCE: the strongest imbalance row gets a yellow outline and a star

4) PERIOD HIGH / LOW
Dashed white lines mark the high and low of the current period, with price labels.

5) BAND REJECTION SIGNALS
- REJ ▼ (red): price tagged the upper band, closed back below it, and the bar had sell-dominant delta
- REJ ▲ (green): price tagged the lower band, closed back above it, and the bar had buy-dominant delta
Signals use the outer band by default, fire only on closed bars, have a cooldown, and are ignored for the first few bars after a reset, while the bands are still too tight to mean anything.

6) DASHBOARD
- VWAP and POC prices
- Price vs VWAP in σ units (shows "EXTENDED" beyond the outer band)
- σ Up / σ Down: current band widths in points
- Band Skew: above 1.15× = BUY-SIDE participation, below 0.87× = SELL-SIDE, otherwise BALANCED
- Period Δ: cumulative estimated buy minus sell volume, with % of total volume
- Flow Data: which intrabar timeframe is being used

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
HOW TO USE IT
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

MEAN REVERSION
When price pushes into the outer band and prints a REJ signal, the move is stretched and the aggressive side is losing control. Common targets are the inner band, the POC, or VWAP.

TREND CONTINUATION
In a strong trend, price holds between VWAP and the inner band on pullbacks. A pullback to VWAP that holds, with band skew favoring the trend side, suggests continuation. Closes beyond the outer band with heavy delta in the same direction show strength, not exhaustion. Don't fade those blindly.

READING BAND SKEW
If the upper band is much wider than the lower band (BUY-SIDE skew), buyers have been doing their work at extended prices. If the lower band is wider (SELL-SIDE skew), sellers have. Skew that disagrees with price direction is a warning sign.

USING THE PROFILE
- POC and high-volume rows act as magnets and support/resistance
- Low-volume gaps between rows tend to get crossed quickly
- Imbalance rows show where one side was aggressive. A BUY imbalance below price can act as support on retests, and a SELL imbalance above price can act as resistance
- Price trading outside the Value Area often tries to return to it (or accepts outside and trends)

CONFLUENCE
The strongest setups line up several pieces: an outer-band rejection INTO a POC, VAH/VAL or imbalance row, with delta confirming.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SETTINGS GUIDE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

VWAP & DEVIATION
- Anchor Period: Session (intraday), Week or Month (swing)
- Inner / Outer Band σ: band multipliers (default 1.0 / 2.0)
- Show/hide inner bands, outer bands, fill, glow and reset highlight

ORDER FLOW
- Intrabar Timeframe: Auto picks 1m data on charts up to 15m, 5m up to 1H, 15m up to 4H, and 60m above that. On 1m charts and below, the chart bars themselves are used. Custom lets you choose, and it falls back to Auto if you pick a timeframe higher than the chart.

SIGNALS
- Signal Band: Inner or Outer
- Require Order-Flow Confirmation: on = delta must agree with the rejection
- Cooldown: minimum bars between signals of the same direction
- Warm-up: bars to ignore after each reset
- Only on Closed Bars: on = no repainting signals

VOLUME PROFILE
- Rows: more rows = finer detail. If labels overlap, lower this (25–30 works well at Large size)
- Offset / Max Width: where the profile sits and how wide it gets
- Max Bars in Profile: caps history on long anchors to keep it fast
- 3D Extrusion + Depth: turn the 3D effect on or off and adjust thickness
- Imbalance Ratio: how lopsided a row must be to count (default 1.5×)
- Min Row Volume: ignores imbalances on thin rows (% of POC volume)
- Value Area %: default 70%
- Extend POC: draws the POC line back across the period

LABELS & DASHBOARD
- Label Size: Small / Normal / Large / Huge
- Dashboard position and text size
- Every neon color can be customized

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
ALERTS
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Create an alert, select this indicator, and choose "Any alert() function call." Alerts fire once per bar close for:
- Bearish upper band rejection
- Bullish lower band rejection
- Close above the upper outer band
- Close below the lower outer band
- VWAP reclaimed
- VWAP lost

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
BEST PRACTICES
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- Built for liquid futures (NQ, ES, MNQ, MES) and liquid stocks/ETFs on 1m–15m charts with the Session anchor
- Use Week or Month anchors on 1H–4H charts for swing context
- Requires volume data. Symbols without volume will show an error
- Treat signals as areas of interest, not automatic entries. Always combine them with your own structure, risk management and plan

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
IMPORTANT NOTES & DISCLAIMER
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
- Buy and sell volume are ESTIMATED from intrabar price action (where each lower-timeframe bar closes within its range). This is not true bid/ask or footprint data, and results can differ from exchange order-flow tools.
- With "Only on Closed Bars" turned off, signals and the live profile can change until the bar closes.
- This indicator is provided free for educational and informational purposes only. It is NOT financial advice, investment advice, or a recommendation to buy or sell any security, futures contract, or other instrument.
- Trading futures, stocks, options and other financial instruments involves substantial risk of loss and is not suitable for every investor. You can lose more than your initial investment when trading leveraged products.
- Past performance, backtests, and historical signals do not guarantee future results.
- You are solely responsible for your own trading decisions. Always do your own research and consider consulting a licensed financial professional.

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.