[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Volume Weighted Average Price (VWAP)



PureBytes Links

Trading Reference Links

It's a bit messy... I never really developed it further... but I was
playing around with channels around a VWAP... I was trading futures so
I put in an option to change the point from which I started calcing a
VWAP... i.e. RTH session or change of day (i.e. midnight).

VWAP = Null;
Plot_Toggle = False;
Bol_or_Kelt = ParamToggle( "Bollinger/Keltner", "Bollinger|Keltner",
True );
NYSE_Reset = ParamToggle( "NYSE Reset", "No|Yes", True );
LengthX = Param( "Length", 15, 1, 100, 1, 1 );
WidthX = Param( "ATR/StdDev", 3, 0.5, 4, 0.1, 0.1 );
StartBar = ValueWhen( TimeNum() <= 093000, BarIndex() );
EndBar =  ValueWhen( TimeNum()  >= 161400, BarIndex() );
Plot_Toggle = IIf( NYSE_Reset == False, True, False );
Plot_Toggle = IIf( NYSE_Reset == True AND ( BarIndex() > StartBar AND
BarIndex() > EndBar ), True, Plot_Toggle );
Bars_so_far_today = IIf( NYSE_Reset == False AND Plot_Toggle == True,
1 + BarsSince( Day() != Ref( Day(), -1 ) ), Null );
Bars_so_far_today = IIf( NYSE_Reset == True AND Plot_Toggle == True, 1
+ BarsSince( Plot_Toggle != Ref( Plot_Toggle, -1 ) ), Bars_so_far_today );
TodayVolume = Sum( V, Bars_so_far_today );
VWAP = Sum ( ( ( H + L ) / 2 ) * V, Bars_so_far_today  ) / TodayVolume;
Bol_Top = IIf( Bol_or_Kelt == False, VWAP + WidthX * StDev( C, LengthX
), 0 );
Bol_Bot = IIf( Bol_or_Kelt == False, VWAP - WidthX * StDev( C, LengthX
), 0 );
KTop = IIf( Bol_or_Kelt == True, VWAP + WidthX * ATR( LengthX ), 0 );
KBot = IIf( Bol_or_Kelt == True, VWAP - WidthX * ATR( LengthX ), 0 );

Plot ( VWAP, "VWAP", colorOrange, styleNoRescale );
Plot ( Bol_Top, "BBTop", colorSeaGreen, styleNoRescale );
Plot ( Bol_Bot, "BBBot", colorSeaGreen, styleNoRescale );
Plot ( KTop, "KTop", colorRed, styleNoRescale );
Plot ( KBot, "KBot", colorRed, styleNoRescale );



--- In amibroker@xxxxxxxxxxxxxxx, dingo <waledingo@xxx> wrote:
>
> I guess Mo (makes me wonder about larry, curly and schemp).
> 
> I'd like to see yours as well if you have a complete version - I didn't
> think you did since you were providing snippets.
> 
> d
> 
> On Sun, Jan 25, 2009 at 3:40 PM, sidhartha70 <sidhartha70@xxx> wrote:
> 
> > You mean me Dingo or the other poster...?
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, dingo <waledingo@> wrote:
> > >
> > > How about posting your complete code?
> > >
> > > d
> > >
> >  > On Sun, Jan 25, 2009 at 2:41 PM, mo_means_go <mo_means_go@> wrote:
> > >
> > > > Thanks!  It's working perfectly!  The flow logic totally
escaped me.
> > > > I over complicated it.  Have a great day/evening.
> > > >
> > > >
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "sidhartha70" <sidhartha70@>
wrote:
> > > > >
> > > > > Try this... no need to covert to  daily time frame...
> > > > >
> > > > > TodayVolume = Sum( V, Bars_so_far_today );
> > > > > VWAP = Sum ( ( ( H + L ) / 2 ) * V, Bars_so_far_today  ) /
> > TodayVolume;
> > > > >
> > > > >
> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "mo_means_go" <mo_means_go@>
> > wrote:
> > > > > >
> > > > > > Thanks sidharta70.  I thought I had it but I was looking at a
> > daily
> > > > > > time frame.  Once switched to intraday my formula wasn't
right:
> > > > > >
> > > > > > AP = (O+H+L+C)/4; //Average Period Price
> > > > > > Bars = 1 + BarsSince( Day() != Ref( Day(), -1 ));
> > > > > > VAP = Sum(V*AP,Bars); // Volume x Price
> > > > > > TimeFrameSet(inDaily);
> > > > > > DV = V; //Daily Volume
> > > > > > TimeFrameRestore();
> > > > > > VWAP = VAP/DV;
> > > > > > Plot(VWAP, "VWAP", colorBlack, styleDashed);
> > > > > >
> > > > > > I guess I need to think about this some more.
> > > > > >
> > > > > > Thanks.
> > > > > >
> > > > > >
> > > > > >
> > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "sidhartha70" <sidhartha70@>
> > wrote:
> > > > > > >
> > > > > > > I did some stuff on VWAP... clearly you have to define a
start
> > > > > > > point... that's easier for stocks than some of futures
contracts
> > > > I was
> > > > > > > looking at... but you'll need something like this to get the
> > > > number of
> > > > > > > bars in a day...
> > > > > > >
> > > > > > > Bars_so_far_today = 1 + BarsSince( Day() != Ref( Day(),
-1 );
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "mo_means_go"
<mo_means_go@>
> > > > wrote:
> > > > > > > >
> > > > > > > > Has anybody ever developed this for use on intraday
charts?
> > > > > > > >
> > > > > > > > Without tick information it is a brute force
calculation, but
> > > > would
> > > > > > > > seem to be fairly accurate on one minute charts.
> > > > > > > >
> > > > > > > > The definition is "sum of the shares bought X share
price" /
> > > > "total
> > > > > > > > shares traded for the day"
> > > > > > > >
> > > > > > > > In this case the sum function is over the one minute time
> > > > frame.  My
> > > > > > > > assumption is that the daily volume is acquired by:
> > > > > > > >
> > > > > > > > TimeFrameSet(inDaily);
> > > > > > > > DV = V;
> > > > > > > > TimeFrameRestore();
> > > > > > > >
> > > > > > > > However, I'm lost as to how to get the sum of the intraday
> > > > volume x
> > > > > > > price:
> > > > > > > >
> > > > > > > > VAP = Sum(V*AP; RANGE); //AP = average bar price
> > > > > > > >
> > > > > > > > Does anybody know how I arrive at the RANGE?  It has
to be the
> > > > bars
> > > > > > > > since yesterdays close using one minute bars, but how do I
> > arrive
> > > > > > > > at the number?
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > ------------------------------------
> > > >
> > > > **** IMPORTANT ****
> > > > This group is for the discussion between users only.
> > > > This is *NOT* technical support channel.
> > > >
> > > > *********************
> > > > TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail
> > directly to
> > > > SUPPORT {at} amibroker.com
> > > > *********************
> > > >
> > > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > > > http://www.amibroker.com/devlog/
> > > >
> > > > For other support material please check also:
> > > > http://www.amibroker.com/support.html
> > > >
> > > > *********************************
> > > > Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
> >
> > ------------------------------------
> >
> > **** IMPORTANT ****
> > This group is for the discussion between users only.
> > This is *NOT* technical support channel.
> >
> > *********************
> > TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail
directly to
> > SUPPORT {at} amibroker.com
> > *********************
> >
> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> >
> > For other support material please check also:
> > http://www.amibroker.com/support.html
> >
> > *********************************
> > Yahoo! Groups Links
> >
> >
> >
> >
>



------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/