Indicator · Pine Script v6 · On the chart

Equity Trading Strategy

by AmjadSaidam· code credited to Amjad_S

This indicator draws a daily-anchored volume-weighted average price on the price chart and marks the first long or short reclaim of that level.

View on GitHub

Repaints

GitHub stars2on the repository
Pine versionv6current
Lines of code121
Settings3inputs
LicenceMIT
Last update4 weeks ago24 Sep 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 indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

121 lines of Pine Script v6 from pine/vwap_breakout_pine.txt, published under MIT. Keep the author's credit and licence lines when you reuse it.

vwap_breakout_pine.txt
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Amjad_S

//@version=6
//+------------------------------------------------------------------+
//                                                         INDICATOR |
//<<+----------------------------------------------------------------+{
indicator("EQUITY TRADING STRATEGY", 
     overlay = true, 
     behind_chart = false)

//>>+----------------------------------------------------------------+}
//                                                            INPUTS |
//<<+----------------------------------------------------------------+{
int volume_window = input(1, title = 'Volume Window')

// sl and tp 
atr = ta.atr(14)
float atr_mult = input(3.0, title = 'ATR SL MULTIPLIER')
float rr = input(1.0, title = 'RISK REWARD')

//>>+----------------------------------------------------------------+}
//                                                        INDICATORS |
//<<+----------------------------------------------------------------+{
// vwap --------------------------------------------------------------
vwap_anchor = timeframe.change('D')
vwap = ta.vwap(ohlc4, anchor = vwap_anchor) 

//>>+----------------------------------------------------------------+}
//                                                        CONFLUENCE |
//<<+----------------------------------------------------------------+{
// outlier volume 
avg_volume = ta.sma(volume, volume_window)
outlier_volume = volume_window > 1 ? volume > avg_volume : true

// first bars 
var bars = 0 
var time_elapsed = false

if vwap_anchor
    bars := 0
    time_elapsed := false
else 
    bars += 1 

if bars > 12 // 5 * 12 = 1hour 
    time_elapsed := true 

bgcolor(time_elapsed and not time_elapsed[1] ? color.new(color.white, 90) : na)

//>>+----------------------------------------------------------------+}
//                                                           SIGNALS |
//<<+----------------------------------------------------------------+{
long_signal = (close < vwap) and (high >= vwap)
long_signal_conf = (close > vwap) and long_signal[1]
long_valid = long_signal_conf[1] and (outlier_volume[1] and time_elapsed)

short_signal = (close > vwap) and (low <= vwap)
short_signal_conf = (close < vwap) and short_signal[1]
short_valid = short_signal_conf[1] and (outlier_volume[1] and time_elapsed)

//>>+----------------------------------------------------------------+}
//                                                           SL & TP |
//<<+----------------------------------------------------------------+{
rd(val) =>
    math.round(val, 5)

sl_tp(order) =>
    side = order == 'long' ? 1 : order == 'short' ? -1 : na 
    sl_dist = atr * atr_mult 
    sl = rd(open - sl_dist * side)
    tp = rd(open + sl_dist * side * rr)
    [sl, tp]

//>>+----------------------------------------------------------------+}
//                                                  VALIDATE SIGNALS |
//<<+----------------------------------------------------------------+{
long_trigger = long_valid and not long_valid[1]
short_trigger = short_valid and not short_valid[1] 

var FirstTrade = bool(na) 

if vwap_anchor
    FirstTrade := false 
else
    if long_trigger or short_trigger
        FirstTrade := true

FirstTradeValid = FirstTrade and not FirstTrade[1]

//>>+----------------------------------------------------------------+}
//                                                      SIGNAL PLOTS |
//<<+----------------------------------------------------------------+{
if long_trigger
    [sl, tp] = sl_tp('long')

    label.new(x = bar_index, y = low, 
        text = 'long' + '\n' + 'sl: @' + str.tostring(sl) + '\n' + 'tp: @' + str.tostring(tp), 
        color = FirstTradeValid ? color.green : color.gray,
        style = label.style_label_up)

    if FirstTradeValid
        alert(message = "LONG " + syminfo.ticker + " " + timeframe.period + " ent: @" + str.tostring(close, format.mintick) + 'sl: @' + str.tostring(sl) + 'tp: @' + str.tostring(tp),
             freq = alert.freq_once_per_bar)

if short_trigger
    [sl, tp] = sl_tp('short')

    label.new(x = bar_index, y = high, 
        text = 'short' + '\n' + 'sl: @' + str.tostring(sl) + '\n' + 'tp: @' + str.tostring(tp), 
        color = FirstTradeValid ? color.red : color.gray,
        style = label.style_label_down)

    if FirstTradeValid
        alert(message = "SHORT " + syminfo.ticker + " " + timeframe.period + " ent: @" + str.tostring(close, format.mintick) + 'sl: @' + str.tostring(sl) + 'tp: @' + str.tostring(tp),
             freq = alert.freq_once_per_bar)

//>>+----------------------------------------------------------------+}
//                                                   INDICATOR PLOTS |
//<<+----------------------------------------------------------------+{
plot(vwap, title = 'VWAP', color = color.purple)

Overview

A long needs a bar below the average whose high reaches it, a later close above it, and confirmation after at least twelve bars from the daily reset. Shorts reverse those conditions. If the volume window is above one, volume must exceed its moving average. ATR and the risk-reward input set calculated stop and target distances. The script is an indicator, so it does not enter or exit trades, and conditions can change on the forming bar.

Details

Published by

AmjadSaidam on GitHub

Code credit

Amjad_S, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Volume, Support & resistance, Breakout, Volatility & bands

Markets

Stocks

Timeframes

M1-M5

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

Topics

cryptocurrencyforexmetatrader5stockstrading-bot

Settings

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

SettingTypeDefaultVariable
Volume Windowint1volume_window
ATR SL MULTIPLIERfloat3.0atr_mult
RISK REWARDfloat1.0rr
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

This indicator identifies and plots price compression zones directly on the price chart using multi-module scoring. It measures ATR compression, ADX chop levels, boundary touches, volume dry-up, and historical pivot levels to identify consolidation areas and s

Indicator v6 BreakoutSupport & resistance
Updated yesterday · MIT GitHub repository of CoilForge Zones [WavesUnchained]

Snag - VWAP

by dearvn
257 stars

This indicator plots a custom Anchored Volume-Weighted Average Price (VWAP) directly on the price chart along with optional standard deviation bands. Users can anchor the VWAP to standard time periods like sessions, weeks, or months, or to corporate events suc

Indicator v5 Moving averagesVolatility & bands Repaints
Updated 6 weeks ago · None stated GitHub repository of Snag - VWAP

VWAP - Basic

by TradersPost
218 stars

VWAP - Basic plots an anchored Volume Weighted Average Price directly on the main price chart alongside two standard deviation bands. It calculates typical price weighted by volume, resetting the cumulative calculations at user-selected session, weekly, or mon

Indicator v6 VolumeSupport & resistance
Updated 3 months ago · None stated GitHub repository of VWAP - Basic

Donchian Channels (DC)

by mihakralj
99 stars

This indicator calculates and plots Donchian Channels directly on the price chart. It determines the highest high and lowest low over a user-selected lookback period using an optimized monotonic deque algorithm, as well as a middle basis line computed as their

Indicator v6 Volatility & bandsSupport & resistance
Updated 4 weeks ago · Apache-2.0 GitHub repository of Donchian Channels (DC)

D/W/M VWAPs

by cryptorife
75 stars

This indicator plots daily, weekly, and monthly volume-weighted average prices on the price chart, using a selectable source that defaults to hlc3. For each enabled period it also draws two standard-deviation bands around the VWAP, with multipliers defaulting

Indicator v4 VolumeVolatility & bands
Updated 3 years ago · GPL-3.0 GitHub repository of D/W/M VWAPs
47 stars

The Donchian Channels indicator plots the middle basis line as the average of the high and low over the user-defined period. It also draws the upper band as the highest high and the lower band as the lowest low across the same period on the price chart. The ma

Indicator v6 Volatility & bandsSupport & resistance
Updated 8 months ago · MIT GitHub repository of Donchian Channels (DCHANNEL)

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers