PureBytes Links
Trading Reference Links
|
On Dec 16, 2:06pm, Ian MacAuslan wrote:
> Subject: Calculating Volume-Weighted Avg Price
> I am trading stocks intraday.
>
> But as part of a setup criteria to go long, I'd like my system to
> reference not just daily Closes -- but to take into account the
> *volume-weighted average price* for the day, as compared with the
> volume-weighted average price over the last, say, 5 days.
> My thinking is this is maybe a better measure of market sentiment about
> a stock's value than simply the Close (or even some combination of
> Open-High-Low-Close). I have heard, in fact, large institutional
> traders are often evaluated this way by their large institutional
> customers on how a good average price they got for them.
>
> I'm having some difficulty conceptualizing how I might write this in
> EasyLanguage. Can someone on the list help?
Well, I tried a custom 1-line indicator, specifying the following
as "input1":
Average(volume*Close, 5)/Summation(Volume, 5)
But for some reason that didn't work. I think it has something
to do with the difference between numericseries and numericsimple
funcations. I was able to write the equivalent code to the
above (rolling my own addition of the terms in the numerator
and denominator, and not calling average or summation), and
it worked as expected. Something along these lines:
{ indicator: volumeweightedave }
inputs: Price(Close), Length(5);
vars: sx(0), sy(0), ave(0), j(0);
if length >= 1 then
sx = 0;
sy = 0;
for j = 0 to (Length-1) begin
sx = sx + Price[j]*Volume[j];
sy = sy + Volume[j];
end;
if sy > 0 then begin
ave = sx / sy;
end else begin
{ if volume is zero, just return simple average }
ave = sx / length;
end;
plot1(ave, "VWA");
end;
note: since reversal days are often marked by higher volume,
it seems to me that giving more weight to a high volume day,
in a trend following system may be the wrong thing.
|