Home Forums Pine Script How can I create my own VWAP using Pine Script?

How can I create my own VWAP using Pine Script?

  • Author
    Posts
    • I already understand how VWAP works, but I want to create my own VWAP indicator in Pine Script.

      I’m not sure which built-in Pine Script functions I should use to calculate and plot it properly.

      Can anyone help me with the right way to implement a custom VWAP in Pine Script?

    • 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.

Viewing 1 reply thread
×

Start a Discussion

Get help from the AlgoDelta community.

×

Welcome Back!

Enter your email to sign in or create an account. No passwords needed.

⚠️

Delete This?

Are you sure you want to delete this? This action is permanent and cannot be undone.

Scroll to Top