// VWAP equation VWAP = sum of(volume x price)/ cumulative Volume
// Basic operation - The VWAP for each bar is calculated. Some values are accumulated for on going calculations.
// - If the chosen time period setting (close of 1st bar in required period )is met, lines are drawn .
// - variables holding cumulation values are reset ready for start of new period.
//-----------------------Calculate VWAP------------------------------
price=(high+low+close)/3 // calulation the average price/bar better h,l,c
VP=volume*price // VP is the volume multiplied by the price current bar
cumVP=cumVP+VP // variable to hold cumulative VP's. VP for current bar
cumVolume=cumVolume+volume // variable to hold cumulative volume's. volume is volume per bar.
VWAP=cumVP/cumVolume // calculate VWAP
//---------------------At specified time draw lines-------------------------------
if currenthour =0 and currentminute = 30 and currentsecond = 0 then // hrs 0-23, mins 0-59, secs 0-59
DRAWHLINE(VWAP) coloured(0,150,150,100) // Draw horizontal lines @VWAP value at chosen time
DRAWVLINE(barindex) coloured(0,150,150,50) // Draw vertical lines at beginning of period
// coloured (R,G,B,opacity)
cumPrice=0 // reset variable for new day/period
cumVolume=0 // "
cumVP=0 // "
endif
return VWAP as "VWAP Lines"