############# UPDATE ###################
This post seems to show up as one of the top popular posts – but there is a follow up post which should used to get the latest VWAP code
Here is the link: http://www.vtrender-2.com/2010/10/vwap-modified-code-to-remove-annoying.html
#######################################
Since I am engineer and have reasonably good skills in programming and reverse engineering – I was able to modify the VWAP code from web to make it work for day, week and month.
This post seems to show up as one of the top popular posts – but there is a follow up post which should used to get the latest VWAP code
Here is the link: http://www.vtrender-2.com/2010/10/vwap-modified-code-to-remove-annoying.html
#######################################
Since I am engineer and have reasonably good skills in programming and reverse engineering – I was able to modify the VWAP code from web to make it work for day, week and month.
The weekly is showing some glitch as it goes down abruptly at end of week 🙁
BTW, I have no knowledge of AFLs — may be I should learn. I have heard that it can be used for real time scanning for stocks and back testing of trading systems.
Please add it to your AFL at the end and enjoy 🙂 And most importantly – for this show up on your chart the parameter “Show VA Fill” has to be set to “No”
Here are illustrations for Nifty and Banknifty
_SECTION_BEGIN(“VWAP”);
/*
The VWAP for a stock is calculated by adding the dollars traded for every
transaction in that stock (“price” x “number of
shares traded”) and dividing the total shares traded. A VWAP is computed
from the Open of the market to the market Close, AND is
calculated by Volume weighting all transactions during this time period
*/
if(Period==”Daily” ){//OR Interval()==3600
Bars_so_far_today = 1 + BarsSince( Day() != Ref(Day(), -1));
StartBar = ValueWhen(TimeNum() == 090000, BarIndex());
TodayVolume = Sum(V,Bars_so_far_today);
IIf (BarIndex() >= StartBar, VWAP = Sum (C * V, Bars_so_far_today ) /
TodayVolume,0);
}
if(Period==”Weekly” OR Interval()==24 * 3600 ){
Bars_so_far_today = BarsSince(DayOfWeek() <>
StartBar = ValueWhen(TimeNum() == 090000, BarIndex());
Vol = TimeFrameGetPrice(“V”, inWeekly, 0);
TodayVolume = Sum(Vol,Bars_so_far_today);
IIf (BarIndex() >= StartBar, VWAP = Sum (C * Vol, Bars_so_far_today ) / TodayVolume,0);
}
if(Period==”Monthly” ){
Bars_so_far_today = BarsSince(Month() != Ref(Month(), -1));
Vol = TimeFrameGetPrice(“V”, inMonthly, 0);
StartBar = ValueWhen(TimeNum() == 090000, BarIndex());
TodayVolume = Sum(Vol,Bars_so_far_today);
IIf (BarIndex() >= StartBar, VWAP = Sum (C * Vol, Bars_so_far_today ) / TodayVolume,0);
}
Plot (VWAP,”VWAP”,colorOrange);
_SECTION_END();