Strategy · Pine Script v5 · On the chart

VWAP Bounce & Cross

by Basant1Saini· code credited to TradingTools

This strategy trades intraday price interactions with the Volume Weighted Average Price (VWAP).

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code88
Settings11inputs
LicenceNone statedfile: MPL-2.0
Last update7 months ago4 Mar 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

88 lines of Pine Script v5 from 6_VWAP_Bounce/6_VWAP_Bounce.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

6_VWAP_Bounce.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0
// © TradingTools

//@version=5
strategy("VWAP Bounce & Cross", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)

// ─── Inputs ───
showBands       = input.bool(true, "Show VWAP Bands", group="VWAP Settings")
bandMult1       = input.float(1.0, "Band 1 StdDev", step=0.1, group="VWAP Settings")
bandMult2       = input.float(2.0, "Band 2 StdDev", step=0.1, group="VWAP Settings")
entryMode       = input.string("Bounce", "Entry Mode", options=["Bounce", "Cross", "Both"], group="Entry")
bounceBuffer    = input.float(0.1, "Bounce Buffer (%)", step=0.05, group="Entry")
emaFilter       = input.int(20, "Trend Filter EMA", group="Filters")
useTrendFilter  = input.bool(true, "Use EMA Trend Filter", group="Filters")
atrLength       = input.int(14, "ATR Length", group="Risk Management")
atrMult         = input.float(1.5, "ATR Multiplier for SL", step=0.1, group="Risk Management")
rrRatio         = input.float(2.0, "Risk:Reward Ratio", step=0.1, group="Risk Management")
sessionFilter   = input.session("0930-1600", "Trading Session", group="Session")

// ─── VWAP Calculation ───
vwapVal         = ta.vwap(hlc3)
vwapDev         = ta.stdev(close - vwapVal, 20)
upperBand1      = vwapVal + vwapDev * bandMult1
lowerBand1      = vwapVal - vwapDev * bandMult1
upperBand2      = vwapVal + vwapDev * bandMult2
lowerBand2      = vwapVal - vwapDev * bandMult2

// ─── Trend Filter ───
emaVal          = ta.ema(close, emaFilter)
trendBull       = useTrendFilter ? close > emaVal : true
trendBear       = useTrendFilter ? close < emaVal : true

// ─── Session Filter ───
inSession       = not na(time(timeframe.period, sessionFilter))

// ─── ATR ───
atrVal          = ta.atr(atrLength)

// ─── Bounce Logic ───
bufferPct       = bounceBuffer / 100
nearVwapLong    = low <= vwapVal * (1 + bufferPct) and close > vwapVal
nearVwapShort   = high >= vwapVal * (1 - bufferPct) and close < vwapVal

// ─── Cross Logic ───
crossLong       = ta.crossover(close, vwapVal)
crossShort      = ta.crossunder(close, vwapVal)

// ─── Combined Entry ───
bounceLong      = (entryMode == "Bounce" or entryMode == "Both") and nearVwapLong
bounceShort     = (entryMode == "Bounce" or entryMode == "Both") and nearVwapShort
xLong           = (entryMode == "Cross" or entryMode == "Both") and crossLong
xShort          = (entryMode == "Cross" or entryMode == "Both") and crossShort

longCondition   = (bounceLong or xLong) and trendBull and inSession
shortCondition  = (bounceShort or xShort) and trendBear and inSession

// ─── Execute Trades ───
if longCondition and strategy.position_size == 0
    sl = close - atrVal * atrMult
    tp = close + (close - sl) * rrRatio
    strategy.entry("VWAP Long", strategy.long)
    strategy.exit("VWAP Long Exit", "VWAP Long", stop=sl, limit=tp)

if shortCondition and strategy.position_size == 0
    sl = close + atrVal * atrMult
    tp = close - (sl - close) * rrRatio
    strategy.entry("VWAP Short", strategy.short)
    strategy.exit("VWAP Short Exit", "VWAP Short", stop=sl, limit=tp)

// ─── Close at Session End ───
if not inSession and strategy.position_size != 0
    strategy.close_all("Session End")

// ─── Plotting ───
plot(vwapVal, "VWAP", color=color.new(color.yellow, 0), linewidth=3)
p1u = plot(showBands ? upperBand1 : na, "Upper Band 1", color=color.new(color.gray, 50))
p1l = plot(showBands ? lowerBand1 : na, "Lower Band 1", color=color.new(color.gray, 50))
p2u = plot(showBands ? upperBand2 : na, "Upper Band 2", color=color.new(color.gray, 70))
p2l = plot(showBands ? lowerBand2 : na, "Lower Band 2", color=color.new(color.gray, 70))
fill(p1u, p1l, color=color.new(color.yellow, 90), title="Band 1 Fill")
fill(p2u, p2l, color=color.new(color.yellow, 95), title="Band 2 Fill")

plotshape(longCondition, title="Long", location=location.belowbar, style=shape.circle, color=color.green, size=size.tiny)
plotshape(shortCondition, title="Short", location=location.abovebar, style=shape.circle, color=color.red, size=size.tiny)

// ─── Alerts ───
alertcondition(longCondition, title="VWAP Long", message="VWAP: Long entry signal")
alertcondition(shortCondition, title="VWAP Short", message="VWAP: Short entry signal")

Overview

VWAP Bounce & Cross offers bounce and crossover entry modes, filtered by an Exponential Moving Average trend filter and a customizable trading session window. Stop loss levels are calculated dynamically using an Average True Range multiplier, while take profit targets are established via a fixed risk-reward ratio. All open positions are automatically closed at the end of the specified trading session. The strategy displays the main VWAP line alongside standard deviation bands directly on the price chart.

Details

Published by

Basant1Saini on GitHub

Code credit

TradingTools, as written in the script's header

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Trend, Moving averages, Support & resistance, Sessions & time

Markets

Stocks

Timeframes

M1-M5, M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Show VWAP BandsbooltrueshowBands
Band 1 StdDevfloat1.0bandMult1
Band 2 StdDevfloat2.0bandMult2
Entry ModestringBounceentryMode
Bounce Buffer (%)float0.1bounceBuffer
Trend Filter EMAint20emaFilter
Use EMA Trend FilterbooltrueuseTrendFilter
ATR Lengthint14atrLength
ATR Multiplier for SLfloat1.5atrMult
Risk:Reward Ratiofloat2.0rrRatio
Trading Sessionsession0930-1600sessionFilter
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

STT SR TMA Plan

by majohnst
1 stars

This strategy executes trades based on Triangular Moving Average (TMA) crossings, support and resistance structures, and breakout logic. It evaluates multiple confluence conditions including daily pivots, anchored VWAP, and multi-day moving averages alongside

Strategy v6 Moving averagesTrend
Updated 3 months ago · None stated GitHub repository of STT SR TMA Plan

Omar Edited WF

by Alorse
330 stars

Omar Edited WF is a trading strategy overlay built around Williams Fractals and multiple Exponential Moving Averages. It detects high and low fractal pivot points over configurable lookback periods alongside three adjustable EMA trendlines. Long entries are ma

Strategy v5 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of Omar Edited WF
257 stars

This strategy calculates dynamic support and resistance levels using pivot highs and lows alongside a custom smoothed trend filter and a 3-period EMA. It identifies entry opportunities when price breaks out relative to the trend filter and short-term EMA cross

Strategy v5 TrendSupport & resistance Repaints
Updated 6 weeks ago · None stated GitHub repository of 30s - ES 1m Strategy Candle Bar

This strategy overlays the price chart and looks for VWAP pullbacks. It goes long when a short SMA crosses above VWAP after RSI has been oversold within ten bars, and short on the opposite cross after RSI has been overbought. Optional Minervini-style moving-av

Strategy v5 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of Advanced VWAP-Momentum Pullback Trend Qualifier
104 stars

This strategy combines three Exponential Moving Averages with Williams Fractals to execute trend-following or mean-reverting trades. It analyzes price structure using short, medium, and long-term EMAs along with fractal highs and lows. Entries trigger when fra

Strategy v5 TrendMoving averages
Updated 3 years ago · MIT GitHub repository of 3MA and Fractals Strategy

ATOM 1m scalp HK

by dearvn
43 stars

This overlay strategy targets one-minute ATOM scalps. It tracks pivot highs and lows as resistance and support, compares a three-period EMA with a multi-stage smoothed close, and flags long or short when price crosses that curve in the matching direction. Dail

Strategy v5 ScalpingSupport & resistance Repaints
Updated 2 years ago · None stated GitHub repository of ATOM 1m scalp HK

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers