VWAP Weekly Monthly & Yearly

Category: Indicators By: Nicolas Created: September 28, 2017, 9:35 AM
September 28, 2017, 9:35 AM
Indicators
8 Comments

The VWAP is a ratio that measures daily the total volume of trade in a security, as well as its average price. The volume-weighted average price can also be calculated over a given period.

This indicator calculate and plot the VWAP for the Weekly, Monthly and Yearly periods. It needs, of course, that the instrument has Volumes.

//PRC_VWAP weekly,monthly,yearly
//28.09.2016
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

//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)

RETURN VWAPweekly as "VWAP Weekly", VWAPmonthly style(line,2) as "VWAP Monthly", VWAPyearly style(line,3) as "VWAP Yearly"

Download
Filename: vwap-prorealtime-weekly-monthly-and-yearly.png
Downloads: 121
Download
Filename: PRC_VWAP-weekly-monthly-yearly.itf
Downloads: 508
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...