Calculate the session vwap

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #222467 quote
    ioannispapadakis
    Participant
    New

    Hey everyone,

    I am trying to calculate the US session vwap. I want the calculation to start when the US session starts, i.e. 16:30 in Greece. I am using this code but I am not geting the right result:

    if OpenTime=163000 then
    OpenBarIndex=intradaybarindex
    SumVol=0
    SumVol2=0
    for i=OpenBarIndex to intradaybarindex do
    SumVol=volume+SumVol
    SumVol2=volume*typicalprice+SumVol2
    next
    VWAP2 = SumVol2/SumVol
    endif
    
    return vwap2

    Can you help me fix this code please?

     

    John

    #222473 quote
    robertogozzi
    Moderator
    Master

    Try this version:

    if OpenTime=163000 then
       SumVol=0
       SumVol2=0
    Endig
    SumVol=volume+SumVol
    SumVol2=volume*typicalprice+SumVol2
    VWAP2 = SumVol2/SumVol
    return vwap2
    ioannispapadakis thanked this post
    #222481 quote
    ioannispapadakis
    Participant
    New

    Thank you once again! I just realized that the code updates each time a new M15 bar starts. That’s why I don’t need that for loop.

    John

    robertogozzi thanked this post
    #222556 quote
    KumoNoJuzza
    Participant
    New

    Hi,

    Just for information, Nicolas proposed the indicator there: https://www.prorealcode.com/topic/time-anchored-vwap/

    ioannispapadakis and robertogozzi thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Calculate the session vwap


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 3 replies,
has 3 voices, and was last updated by KumoNoJuzza
2 years, 3 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/15/2023
Status: Active
Attachments: No files
Logo Logo
Loading...