Calculate the session vwap

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #222467 quote
    ioannispapadakisioannispapadakis
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    ioannispapadakisioannispapadakis
    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
    KumoNoJuzzaKumoNoJuzza
    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.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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 KumoNoJuzzaKumoNoJuzza
2 years, 11 months ago.

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