vwap Weekly

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #84323 quote
    Gabriele Battista
    Participant
    Senior

    Is it possible to have the code of vwap that starts its value at the begin of the week (for any time frame), in alternative starts in a fixed day. thanks

    #84326 quote
    robertogozzi
    Moderator
    Master
    #84339 quote
    Gabriele Battista
    Participant
    Senior

    Non mi funziona se prendo solo la parte del codice che riguarda la settimana non ho il valore corretto e se provo a costruire le bande a più dev.std (altro obiettivo) non da risultati corretti.

    It does not work if I take only the part of the code that concerns the week I do not have the correct value and if I try to build the bands with several dev.std’s (other objective) it does not return correct results.

    #84343 quote
    Vonasi
    Moderator
    Master

    Gabriele Battista – English only in the English speaking forum please. Please post in the Italian speaking forum if you want to communicate in Italian.

    #84371 quote
    Gabriele Battista
    Participant
    Senior

    sorry

    #84394 quote
    robertogozzi
    Moderator
    Master

    You can simply make the two unnecessary lines INVISIBLE using the properties of the indicator, once installed on the chart, without changing the code workings. Just replace the RETURN line to get rid of STYLE:

    RETURN VWAPweekly as "VWAP Weekly", VWAPmonthly as "VWAP Monthly", VWAPyearly as "VWAP Yearly"

    As for bands, you did not tell about your error, But there’s no reason not to be able to draw as many bands as you want (Band2UP/Band2DN, …), this is the same code modified (without removing any original calculation), with just 1 band and the RETURN line reflecting that addition:

    //PRC_VWAP weekly,monthly,yearly
    //28.09.2016
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    defparam calculateonlastbars=10000
    //calculation periods
    if DayOfWeek=0 or (dayofweek[1]=5 and dayofweek<>5) then
       weekbar=barindex
    endif
    if month<>month[1] then
       monthbar=barindex
    endif
    if year<>year[1] then
       yearbar=barindex
    endif
    
    once dWeekly  = 1
    once dMonthly = 1
    once dYearly  = 1
    dWeekly  = max(dWeekly, barindex-weekbar)
    dMonthly = max(dMonthly, barindex-monthbar)
    dYearly  = max(dYearly, barindex-yearbar)
    
    VWAPweekly  = SUMMATION[dWeekly](volume*typicalprice)/SUMMATION[dWeekly](volume)
    VWAPmonthly = SUMMATION[dMonthly](volume*typicalprice)/SUMMATION[dMonthly](volume)
    VWAPyearly  = SUMMATION[dYearly](volume*typicalprice)/SUMMATION[dYearly](volume)
    Band1UP     = VWAPweekly + ((std[20](VWAPweekly)) * 2.0)    //UPPER band
    Band1DN     = VWAPweekly - ((std[20](VWAPweekly)) * 2.0)    //UPPER band
    RETURN VWAPweekly as "VWAP Weekly", VWAPmonthly as "VWAP Monthly", VWAPyearly as "VWAP Yearly",Band1UP,Band1DN
    x-2.jpg x-2.jpg y.jpg y.jpg
    #84398 quote
    Nicolas
    Keymaster
    Master

    Standard deviation bands calculation of VWAP can be found in this indicator: VWAP intraday

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

vwap Weekly


ProBuilder: Indicators & Custom Tools

New Reply
Summary

This topic contains 6 replies,
has 4 voices, and was last updated by Nicolas
7 years, 4 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/07/2018
Status: Active
Attachments: 2 files
Logo Logo
Loading...