Yes sir, you can definitely create your own VWAP using Pine Script’s built-in functions.
Pine Script already provides the ta.vwap() function, so you don’t need to manually calculate the VWAP from price and volume.
You can create it using:
//@version=6
indicator("Custom VWAP", overlay=true)
vwapValue = ta.vwap(close)
plot(vwapValue, "VWAP", color=color.blue)
-> ta.vwap() calculates the VWAP using the selected source.
-> Here, close is used as the source for the VWAP calculation.
-> The result can then be plotted directly on the chart.
You can also make the source configurable:
source = input.source(close, "Source")
vwapValue = ta.vwap(source)
plot(vwapValue, "VWAP", color=color.blue)
=> This approach is useful when you understand the indicator’s logic but want to use Pine Script’s built-in functions instead of manually recreating the entire calculation.
So that’s how you can create your own VWAP using Pine Script’s built-in function.