dear friends
how to calculate average Volume of previous 5 days?
Lets say, we have EOD data upto 26-Feb-2007, then
how to calculate 5 day average volume of previous 5 trading
sessions excluding 26-Feb-2007?
have a nice day
JB
Sorry man, didn't notice your post.
You need to calculate avg. of "last" five days. So you need to refer "backwards". I think the Ref() will help you out.
The AFL is given below. Let us know if you find any problem with it.
_SECTION_BEGIN("Prev5daysAvg");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
field = ParamField("Field");
period = Param("Period", 5, 1);
prev5daysAvg = MA(Ref(field, -1), period);
Plot(prev5daysAvg,"prev5daysAvg", ParamColor("Colour", colorGreen), styleLine);
_SECTION_END();