2-day VWAP indicator

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #229566 quote
    Bogren
    Participant
    New

    Hi,

    I´m looking for a indicator that show 2-day VWAP on the chart. I know you can use booth the original VWAP and the anchored one and change settings to 2-days but that´s not how i think about it. The original one should show 2- days at the time, and the anchored you have to manually anchor at every day.

    What I’m looking for is a model that starts a VWAP from today’s open just as the original one but doesn’t close the calculation before tomorrow´s close.

    On a historical chart, you would then see the VWAP starting from each day’s opening but not closing until the next day’s close. In other words, it overlaps each other all the time. Then you can perhaps also color day 1 in one color and day 2 in another to easily separate them visually.

    I´ve tried to code it myself but failed. My beginner skills is limited at the moment!

    #229650 quote
    Iván González
    Moderator
    Master

    Hi
    Try this

    if opendate <> opendate[1] and newday=0 then
    newday = 1
    startbar1 = 1
    elsif opendate <> opendate[1] and newday=1 then
    newday = 0
    startbar2 = 1
    else
    newday = newday
    startbar1 = startbar1+1
    startbar2 = startbar2+1
    endif
    ///VWAP 1
    d1 = max(1, startbar1)
    VWAP1 = SUMMATION[d1](volume*typicalprice)/SUMMATION[d1](volume)
    
    ///VWAP 2
    d2 = max(1, startbar2)
    VWAP2 = SUMMATION[d2](volume*typicalprice)/SUMMATION[d2](volume)
    
    RETURN VWAP2 as "Vwap2" coloured("red"), vwap1 as "Vwap1"coloured("blue")
    Bogren thanked this post
    #229840 quote
    Bogren
    Participant
    New

    Excellent @Iván !

    Now i should try to use this indicator in a strategy with some other tools.

    In a strategy for example, if i only want to to use the second day of both this vwap´s as an entry oportunity when a crossover arises (Because it´s acctuly then a 2- day VWAP arises).

    How should that snippet looks like? I know the acctuly CROSSES OVER code.

    Thanks in advance!

    #229857 quote
    Iván González
    Moderator
    Master

    If you want for example check the cross between both vwap you could try this:

    if vwap2 crosses over vwap1 then
    buy 1 contract at market
    endif
    #229869 quote
    Bogren
    Participant
    New

    Thanks, but I’m aware of that.

    The part of the code I’m looking for is to be able to specify so it only includes the second day. If price crosses the vwap on the first day, it is not a 2-day vwap cross but a regular one, thats not intresting. It is the second day of the 2-day vwap that is the interesting thing here.

    Otherwise, you could have used the standard indicator for vwap and then that price or whatever you want crosses over with the code you attached last.

    Thus, a code string that only includes crosses on the second day. That is the part of the code that is difficult for me.

    Hope this make it clearer. If not, i could attach a pic to make it easier to understand.

    #230090 quote
    Bogren
    Participant
    New

    Hi @Iván

    Attached is a picture that shows what i mean.

    Hope that helps.

    Thank you

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

2-day VWAP indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Bogren @bogren Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by Bogren
1 year, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/11/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...