vwap previous close line

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #179739 quote
    keks
    Participant
    Average

    Hi, I would like to draw a horizontal line on the intraday chart that represents last observed daily vwap level of previous session of trading. So in essense:

    line1 = dclose(1)
    return line1 coloured(255,255,255)

    Except I do not want dclose, instead want to see where daily vwap was at close previous session. Would anyone PLEASE let me know how I can create this?

     

    THANKS!!

    #179740 quote
    robertogozzi
    Moderator
    Master

    There you go:

    Timeframe(Daily,UpdateOnClose)
    if volume > 0 then
       VWAP = (volume * typicalprice)
    endif
    Timeframe(default)
    return VWAP AS "Daily VWAP"
    keks thanked this post
    #179743 quote
    keks
    Participant
    Average

    THANKS!!!!

    I modified code slightly:

    Timeframe(Daily,UpdateOnClose)
    if volume > 0 then
    d = max(1, intradaybarindex)
    VWAP = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
    endif
    Timeframe(default)
    return VWAP AS “Daily VWAP”

    #179744 quote
    keks
    Participant
    Average

    Hmm.. it seem to work for a bit then get calculation error and the indicator drops off the chart. Not sure what is wrong with code

    #179746 quote
    keks
    Participant
    Average

    in the attached pic the green is daily vwap, red is the code above… ideally i would like the red line to extend from where green on ends on previous day. strategy under development will build signals based on whether price remains above previous day vwap….

    vwap.png vwap.png
    #179748 quote
    robertogozzi
    Moderator
    Master

    I am not getting any error with both of them.

    Anyhow, you are NOT calculating VWAP, your code simply returns TypicalPrice.

    keks thanked this post
    #179751 quote
    robertogozzi
    Moderator
    Master

    I also got the error message now. I think it’s due to the high number involved summing up they daily volume*typicalprice for the intradaybarindex.

    #179752 quote
    keks
    Participant
    Average

    would it be easier/less calc to use last observed vwap level of previous session instead of calculating? In other words previous session daily vwap close… seem to be an lighter way to accomplish this however I am not sure how to code this

    #179754 quote
    robertogozzi
    Moderator
    Master

    I did in my first reply.

    keks thanked this post
    #179838 quote
    keks
    Participant
    Average

    thanks again.

    would you be chance be willing to help me specify time interval of previous day session for the vwap calculation line to be based off?

    For example, let us assume I want to use index futures previous day vwap level during ordinary trading session only as an indicator on the following day trading session…

    #179841 quote
    robertogozzi
    Moderator
    Master

    To make it work in a time interval the daily timeframe can’t be used.

    The code you wrote is almost correct, provided the TIMEFRAME keyword is removed. Then a time interval must be added:

    ONCE d = 0
    if volume > 0 then
       IF intradaybarindex = 0 THEN
          d = 0
       ENDIF
       IF Time >= 080000 AND Time <= 180000 THEN
          d    = d + 1
          VWAP = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
       ENDIF
    endif
    return VWAP AS “Daily VWAP”
    keks thanked this post
    #179871 quote
    keks
    Participant
    Average

    thanks so much for taking the time to update this code. Still this does not seem to give me a horizontal line marking previous end of session vwap level….

    the reason I like having this drawn is many of the securities I follow seem to trade differently based on whether they are above or below previous session vwap…

    I will try to figure out how to get an accurate line drawn using clues from your code, but so far still not where I would like to be!

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

vwap previous close line


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
keks @keks Participant
Summary

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

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