OPEN-SOURCE SCRIPT
VWAP Gate (1m aligned ORB5)

VWAP Gate v2.3 is a 1-minute aligned, session-aware VWAP regime filter (“gate”) designed to keep VWAP trades out of flat/choppy conditions and focus only on periods where VWAP is moving with structure. It plots a Session Anchored VWAP (RTH) with an ε touch zone, optionally plots an Overnight Anchored VWAP, and can mark VWAP retest entry signals only when the gate is active and price action confirms.
This is an overlay tool for discretionary execution and rule-based filtering. It does not manage exits, risk, or position sizing.
Core idea (what it does)
VWAP works best when the market has directional order flow and fails in mean-reverting chop. This indicator attempts to separate those regimes by requiring:
VWAP has actually moved (slope/magnitude filter)
Price is not constantly flipping around VWAP (chop filter)
Price is holding on one side of VWAP by a realistic buffer (hold/acceptance filter)
Only when these conditions persist does the Gate turn ON, enabling a “tradeable VWAP” environment.
All calculations are done on 1-minute data using request.security(..., "1", ...) so the behavior stays consistent across chart timeframes.
What is plotted
1) Session AVWAP (RTH Anchored VWAP)
A manually computed VWAP that resets at the start of the RTH session (default 09:30–16:00 New York).
It is plotted as “Session AVWAP” and changes color based on gate state and directional readiness (see “Colors” below).
2) VWAP ε Touch Zone (retest band)
Two lines around Session VWAP:
VWAP ε Upper = VWAP + ε
VWAP ε Lower = VWAP − ε
The band between them is filled. This creates a practical “touch zone” for retests and rejection closes.
ε (epsilon) is adaptive to instrument microstructure:
ε = max(minTicksEps × tickSizePts, spreadPts × epsSpreadMult)
This prevents treating tiny touches (often just spread/noise) as meaningful VWAP interactions.
3) Overnight AVWAP (optional)
If enabled, plots an Overnight anchored VWAP computed over the defined overnight session (default 00:00–09:30 New York).
Useful for mapping overnight fair value into the open.
4) ORB(5) High/Low (optional)
Plots the Opening Range Breakout (5 minutes) high/low (default 09:30–09:35 New York).
Optionally draws an ε band around ORB levels (ORB ± ε) to account for noise/spread around key levels.
5) VWAP Retest Entry Markers (optional)
When the gate is active, the tool can print:
“L” for a long retest entry
“S” for a short retest entry
These are filters + triggers, not guaranteed trades.
Gate logic (when trading is allowed)
A) VWAP Move / Slope filter
The indicator measures VWAP displacement over lookbackMin minutes:
VWAP_move = |VWAP_now − VWAP_lookback|
It must exceed thresholds tied to:
Recent price range: thrRange = kRange × (highestHigh − lowestLow over lookback)
Spread: thrSpr = kSpread × spreadPts
Threshold mode
Strict AND: VWAP_move must beat both thresholds
Loose: VWAP_move must beat max(thrRange, thrSpr)
Purpose: block low-energy sessions where VWAP drift is too small vs noise.
B) Chop filter (VWAP flips)
The indicator counts how often price flips sides of VWAP during the lookback window (with a small buffer to reduce micro-noise flips).
If flips exceed maxCrossesN, the environment is classified as chop and the gate cannot activate.
Purpose: avoid mean-reverting “ping-pong” around VWAP.
C) Gate confirmation (anti-flicker / hysteresis)
The gate requires persistence:
Gate turns ON after onConfirmBars consecutive passes
Gate turns OFF after offConfirmBars consecutive fails
Purpose: prevent rapid ON/OFF switching in borderline conditions.
Directional “Hold” readiness (LONG vs SHORT bias)
Even when the gate is ON, the indicator requires acceptance away from VWAP:
Define δ (delta buffer):
δ = max(2 ticks, spreadPts × holdDeltaMult)
Then:
HoldLong = price has stayed > (VWAP + δ) for holdBars 1-minute closes
HoldShort = price has stayed < (VWAP − δ) for holdBars 1-minute closes
Additionally, direction must agree with VWAP slope:
Long requires VWAP slope > 0
Short requires VWAP slope < 0
Purpose: avoid “false bias” when price temporarily deviates but VWAP is drifting the other way.
VWAP Retest Entry signals (L / S)
Entry markers trigger only when all are true:
Gate is active
Inside your Trade Window (default 09:40–11:00 New York)
HoldLongOk / HoldShortOk is true
Price touches the ε zone: low ≤ VWAP+ε AND high ≥ VWAP−ε
Then closes away from VWAP (“rejection close”) by a fraction of ε:
Long rejection:
close > VWAP + (ε × rejCloseFrac)
Short rejection:
close < VWAP − (ε × rejCloseFrac)
Optional: Require pullback can require the previous close to already be on the trend side (to avoid first-touch chaos).
Colors (quick regime read)
The Session VWAP line and ε zone communicate state:
Gray: gate inactive / no-trade regime
Yellow: gate active but no clean long/short hold yet (standby)
Lime: gate active + long hold confirmed (long bias)
Red: gate active + short hold confirmed (short bias)
Optional background tint can reinforce gate state, and optional shading can gray out bars outside the trade window.
Important notes / limitations
Set spreadPts and tickSizePts correctly for your instrument. ε and δ depend on them; wrong values distort the entire filter.
The indicator uses 1-minute computations across all chart timeframes for consistent behavior.
This tool is a regime filter + entry trigger, not a complete trading system (no exits, no sizing, no expectancy validation included).
If volume is missing/invalid, the script substitutes a minimal volume value for VWAP calculations.
Suggested use
Use Prop VWAP Gate to:
Avoid VWAP trading in flat/choppy opens
Focus attention when VWAP is moving and price is holding with structure
Execute VWAP retest setups inside a controlled time window
Combine with ORB(5) and overnight VWAP for key reference levels
This is an overlay tool for discretionary execution and rule-based filtering. It does not manage exits, risk, or position sizing.
Core idea (what it does)
VWAP works best when the market has directional order flow and fails in mean-reverting chop. This indicator attempts to separate those regimes by requiring:
VWAP has actually moved (slope/magnitude filter)
Price is not constantly flipping around VWAP (chop filter)
Price is holding on one side of VWAP by a realistic buffer (hold/acceptance filter)
Only when these conditions persist does the Gate turn ON, enabling a “tradeable VWAP” environment.
All calculations are done on 1-minute data using request.security(..., "1", ...) so the behavior stays consistent across chart timeframes.
What is plotted
1) Session AVWAP (RTH Anchored VWAP)
A manually computed VWAP that resets at the start of the RTH session (default 09:30–16:00 New York).
It is plotted as “Session AVWAP” and changes color based on gate state and directional readiness (see “Colors” below).
2) VWAP ε Touch Zone (retest band)
Two lines around Session VWAP:
VWAP ε Upper = VWAP + ε
VWAP ε Lower = VWAP − ε
The band between them is filled. This creates a practical “touch zone” for retests and rejection closes.
ε (epsilon) is adaptive to instrument microstructure:
ε = max(minTicksEps × tickSizePts, spreadPts × epsSpreadMult)
This prevents treating tiny touches (often just spread/noise) as meaningful VWAP interactions.
3) Overnight AVWAP (optional)
If enabled, plots an Overnight anchored VWAP computed over the defined overnight session (default 00:00–09:30 New York).
Useful for mapping overnight fair value into the open.
4) ORB(5) High/Low (optional)
Plots the Opening Range Breakout (5 minutes) high/low (default 09:30–09:35 New York).
Optionally draws an ε band around ORB levels (ORB ± ε) to account for noise/spread around key levels.
5) VWAP Retest Entry Markers (optional)
When the gate is active, the tool can print:
“L” for a long retest entry
“S” for a short retest entry
These are filters + triggers, not guaranteed trades.
Gate logic (when trading is allowed)
A) VWAP Move / Slope filter
The indicator measures VWAP displacement over lookbackMin minutes:
VWAP_move = |VWAP_now − VWAP_lookback|
It must exceed thresholds tied to:
Recent price range: thrRange = kRange × (highestHigh − lowestLow over lookback)
Spread: thrSpr = kSpread × spreadPts
Threshold mode
Strict AND: VWAP_move must beat both thresholds
Loose: VWAP_move must beat max(thrRange, thrSpr)
Purpose: block low-energy sessions where VWAP drift is too small vs noise.
B) Chop filter (VWAP flips)
The indicator counts how often price flips sides of VWAP during the lookback window (with a small buffer to reduce micro-noise flips).
If flips exceed maxCrossesN, the environment is classified as chop and the gate cannot activate.
Purpose: avoid mean-reverting “ping-pong” around VWAP.
C) Gate confirmation (anti-flicker / hysteresis)
The gate requires persistence:
Gate turns ON after onConfirmBars consecutive passes
Gate turns OFF after offConfirmBars consecutive fails
Purpose: prevent rapid ON/OFF switching in borderline conditions.
Directional “Hold” readiness (LONG vs SHORT bias)
Even when the gate is ON, the indicator requires acceptance away from VWAP:
Define δ (delta buffer):
δ = max(2 ticks, spreadPts × holdDeltaMult)
Then:
HoldLong = price has stayed > (VWAP + δ) for holdBars 1-minute closes
HoldShort = price has stayed < (VWAP − δ) for holdBars 1-minute closes
Additionally, direction must agree with VWAP slope:
Long requires VWAP slope > 0
Short requires VWAP slope < 0
Purpose: avoid “false bias” when price temporarily deviates but VWAP is drifting the other way.
VWAP Retest Entry signals (L / S)
Entry markers trigger only when all are true:
Gate is active
Inside your Trade Window (default 09:40–11:00 New York)
HoldLongOk / HoldShortOk is true
Price touches the ε zone: low ≤ VWAP+ε AND high ≥ VWAP−ε
Then closes away from VWAP (“rejection close”) by a fraction of ε:
Long rejection:
close > VWAP + (ε × rejCloseFrac)
Short rejection:
close < VWAP − (ε × rejCloseFrac)
Optional: Require pullback can require the previous close to already be on the trend side (to avoid first-touch chaos).
Colors (quick regime read)
The Session VWAP line and ε zone communicate state:
Gray: gate inactive / no-trade regime
Yellow: gate active but no clean long/short hold yet (standby)
Lime: gate active + long hold confirmed (long bias)
Red: gate active + short hold confirmed (short bias)
Optional background tint can reinforce gate state, and optional shading can gray out bars outside the trade window.
Important notes / limitations
Set spreadPts and tickSizePts correctly for your instrument. ε and δ depend on them; wrong values distort the entire filter.
The indicator uses 1-minute computations across all chart timeframes for consistent behavior.
This tool is a regime filter + entry trigger, not a complete trading system (no exits, no sizing, no expectancy validation included).
If volume is missing/invalid, the script substitutes a minimal volume value for VWAP calculations.
Suggested use
Use Prop VWAP Gate to:
Avoid VWAP trading in flat/choppy opens
Focus attention when VWAP is moving and price is holding with structure
Execute VWAP retest setups inside a controlled time window
Combine with ORB(5) and overnight VWAP for key reference levels
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。