How can I create my own VWAP using Pine Script?

Asked by Radhesh Joshi · SOLVED
1 reply 240 views Jump to solution Reply
Radhesh Joshi Original Post
Strategy Builder

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?

Posted Aug 24
Reply

    1 Reply

    Tech Support AlgoDelta
    Tech Support AlgoDelta Automation Expert ·

    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.

    Verified Solution
      Markdown supported · ```json for code blocks · paste or drop screenshots

      Be specific and kind. Never share API keys, passwords or personal account details.

      Welcome to the community

      Log in or create your account in under a minute.

      1. 1Mobile
      2. 2E-mail
      3. 3Password
      +91

      Have a password?

      By continuing you agree to the community guidelines. We’ll send a one-time code by SMS.