Average cumulative volume

#1
hi

I am trying to code a intraday indicator for 1 min data , which plots
1) Total cumulative volume of the day.
2) Moving average of the same cumulative volume of last N days.

The first part plots correctly by the following :

Bar_today = 1 + BarsSince( Day() != Ref(Day(), -1));
TodayVolume = Sum(V,Bar_today);
Plot (TodayVolume ,"totalVol",colorRed, styleThick);

But the second part is proving to be tricky.
Basically how to plot n day average total volume traded till a particular point of time.
Any clues.

regards
 

extremist

Well-Known Member
#2
hi

I am trying to code a intraday indicator for 1 min data , which plots
1) Total cumulative volume of the day.
2) Moving average of the same cumulative volume of last N days.

The first part plots correctly by the following :

Code:
Bar_today = 1 + BarsSince( Day() != Ref(Day(), -1));
TodayVolume = Sum(V,Bar_today);
Plot (TodayVolume ,"totalVol",colorRed, styleThick);
But the second part is proving to be tricky.
Basically how to plot n day average total volume traded till a particular point of time.
Any clues.

regards
u made successful attempt to get part one done.
but the problem in getting part 2 done is tht each day your Cum V will start from V of first bar of day and start accumulating volume bar by bar.

so if u run n day moving avg on it; it wont be correct coz of the data u r creating. At the end of day yesterday Cum V will produce very hi value and at start of today it will be V of first bar of day(comparatively very low). so u may feel tht wht ever Avg u are setting is not correct but actually it is.

SO THIS MIGHT BE ANSWER TO BOTH OF YOUR PARTS

Code:
pr= Param("Avg Period",20,1,200,1);
cv=Cum(V);
Plot(cv,"CumV",colorBlack);
Plot(MA(cv,pr),"AvgCV",colorbrightgreen);
This will serve u better. But for better results of this code u will have to keep at least 3-4 days Graph on screen Coz CUM function starts accumulating data from the first bar visible on screen.
So achieve better accuracy keep 3-4 days graph on screen.

IF DON'T LIKE ABV SOLUTION THEN U MAY TRY THIS

Code:
pr= Param("Avg Period",20,1,200,1);
Bar_today = 1 + BarsSince( Day() != Ref(Day(), -1));
TodayVolume = Sum(V,Bar_today);
Plot (TodayVolume ,"totalVol",colorRed, styleline);
Plot (MA(TodayVolume,pr) ,"AVG",colorbrightgreen, styleline);
But i wont prefer the second option.

So now Choice is yours.
 

Similar threads