OPEN-SOURCE SCRIPT

VWAP

80
//version=5
indicator(title="VWAP", shorttitle="VWAP", overlay=true)

// Calculate VWAP
price = (high + low + close) / 3
pv = price * volume
cumulativePV = ta.cum(pv)
cumulativeVolume = ta.cum(volume)
vwap = cumulativePV / cumulativeVolume

// Plot VWAP
plot(vwap, color=color.blue, linewidth=2, title="VWAP")

// Example: Display bullish/bearish signals (basic)
isBullish = close > vwap
isBearish = close < vwap

plotshape(isBullish, style=shape.triangleup, color=color.green, size=size.tiny, location=location.bottom, title="Bullish Signal")
plotshape(isBearish, style=shape.triangledown, color=color.red, size=size.tiny, location=location.top, title="Bearish Signal")

//Alerts
alertcondition(ta.crossover(close,vwap),"Price crossing above VWAP","Price crossing above VWAP")
alertcondition(ta.crossunder(close,vwap),"Price crossing below VWAP","Price crossing below VWAP")

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.