Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

dbntina

VWAP Indicator with 1SD and 2SD bands

Recommended Posts

Hi there,

 

See your PM's. Am travelling at the moment but the current work is complete however I now want to incorporate multi day stuff and a histogram. The stuff that DBNTina is absolutely fine btw it ust cane be a little sluggish loading up...results are pretty much the same. That should do as a stopgap.

 

Cheers,

Nick

Share this post


Link to post
Share on other sites
Does anyone know whether the VWAP indicator downloadable from this thread is almost 100% accurate? Or does it need further adjustments?

 

Thanks.

 

Its 100% accurate on tick charts. To be honest on 2 minute charts its fine too. Its actually the PvP that can change characteristics on 2 minute bars. Dbntina posted an indicator that gets round that by using ADE to take data from a tick chart and push it to an X minute chart.

 

Cheers.

Share this post


Link to post
Share on other sites
add a 3rd SD, as this is the way Jerry teaches it? Bryan

 

Please find below in the code box the complete code listing for Jay who asked for it in August and for Bryan, just add the last three lines of this listing to the bottom of your indicator code:

 

input : trdSD (3);

Plot6(VolWAPValue + (trdSD*VolWAPSD), "VWAP3SDUp");

Plot7(VolWAPValue - (trdSD*VolWAPSD), "VWAP3SDDown");

 

The third SD is now an input, allowing you to use different numbers. There is nothing magical about '3'; it all depends on how many are following it and how strong the trend. Sometimes 2.5 works better.

attachment.php?attachmentid=4591&stc=1&d=1198255005


{***********************************************************************************************

Coded by dbntina/boxmeister 8/2/2007

Used the VWAP_H code provided by Tradestation on 02/07/2003 Topic ID = 6735 Thanks Guys!

Added the computation for variance and the Standard Deviation to combine into one indicator
plot and this indicator plots the VWAP, SD1 bands and SD2 bands

***********************************************************************************************}



[LegacyColorValue = true];

vars:
	PriceW(0),
	ShareW(0),
	Count(0),
	VolWAPValue(0),
	VolWAPVariance(0),
	VolWAPSD(0);


if date > date[1] then begin
	PriceW = 0;
	ShareW = 0;
	Count = -1;
	Value1 = 0;
	Value2 = 0;
	VolWAPValue = 0;
end;

PriceW = PriceW + (AvgPrice * (UpTicks+DownTicks));
ShareW = ShareW + (UpTicks+DownTicks);
Count = Count + 1;
Value3 = 0;

if ShareW > 0 then VolWAPValue = PriceW / ShareW;

{Calculate the individual variance terms for each intraday bar starting with the current
bar and looping back through each bar to the start bar.  The terms are each normalized
according to the Variance formula for each level of volume at each price bar			}

	For Value1 = 0 To Count Begin
	Value2 = ((UpTicks[Value1]+DownTicks[Value1])/ShareW) * (Square(AvgPrice[Value1]-VolWAPValue));
	Value3 = Value3 + Value2;
End;

VolWAPVariance = Value3;
VolWAPSD = SquareRoot(VolWAPVariance);


Plot1(VolWAPValue, "VWAP");
Plot2(VolWAPValue + VolWAPSD, "VWAP1SDUp");
   Plot3(VolWAPValue - VolWAPSD, "VWAP1SDDown");
Plot4(VolWAPValue + (2*VolWAPSD), "VWAP2SDUp");
   Plot5(VolWAPValue - (2*VolWAPSD), "VWAP2SDDown");
// added by request http://www.traderslaboratory.com/forums/f46/vwap-indicator-with-1sd-and-2sd-2175.html#post27273
input : trdSD (3);
   Plot6(VolWAPValue + (trdSD*VolWAPSD), "VWAP3SDUp");
   Plot7(VolWAPValue - (trdSD*VolWAPSD), "VWAP3SDDown");


5aa70e2e9ab98_vwapsd2.52007-12-21_113611.png.baeff4533d6cc6078c25fe28a779dae8.png

Share this post


Link to post
Share on other sites

I am using the 3 SD version updated by thrunner. There is one problem. When I add a Horizontal line like in the included picture, the price as listed on the horizontal line is incorrect. This problem only occurs on charts with the VWAP indicator. Notice that the HL is listed at 1508.91 while it is actually at the 1510.00 level.

 

Any thoughts on this?

 

ScreenShot001.thumb.png.3df23059753c590f29a1e3f3ae9464bc.png

Share this post


Link to post
Share on other sites
problem only occurs on charts with the VWAP indicator. Notice that the HL is listed at 1508.91 while it is actually at the 1510.00 level
Does this horizontal line problem persist after you move it up and down the vertical axis and/or right click format it? I do not see this problem in TS 8.2.3896. Which TS version are your using? There are some reports of inaccurate HL and alerts in prior versions of TS, but not recently. You may have to save a minimal chart and workspace with the problem and report it to TS support.

5aa70e2f7f761_dbvwaphorizontallineTS8.22007-12-27_085836.png.7ecff833c5d6c1d7abedff573f906639.png

Share this post


Link to post
Share on other sites

Thanks for the great indicator!

 

I tried it with the daily charts it it looks very weird and does not appear to work.

 

Can someone try it and see if they get this problem as well?

 

Also, it looks a bit different from the Ensign data that I got for today's trading (JAN 4 - 08)

 

Namely, Ensign hung around VWAP -std2, but with TS it hung around -std1 and it never touched std2.

Share this post


Link to post
Share on other sites

Thanks for the VWAP indicator for TS guys. I've been looking for this for a while and stumbled on this great thread. I have some issues though....

 

I have used the TS VWAP indicator posted here and I have seem some descrepencies between it and the VWAP indicator for Ensign (build in 03-Jan-08 version).

 

Namely, they don't seem to match. See the attached images for trading TODAY (Jan-04). Ensign has most of todays trading at -2std, while TS has it at -1std.

 

Also, the TS indicator does not seem to work for intervals other intraday. I tried to recreate someone else's chart for daily's on and it seemed to fail.

5aa70e3030b94_ensign-jan04vwap.thumb.PNG.9840278763623263040c3cabf4636e40.PNG

ts-vwap-jan04.thumb.PNG.0694590f38b2787c766e9ed908107499.PNG

ts-vwap-daily.thumb.PNG.23bbf5b904c60ed76be32f3902f25edc.PNG

Edited by lj2500
add more info...

Share this post


Link to post
Share on other sites
some descrepencies..... and it seemed to fail.
Welcome to the forum. As you have noticed, VWAP is a moving average and it's calculation can differ greatly depending on when (exact time) you started counting the VWAP, which defined as:
VWAP (Volume Weighted Average Price) is a measure of the price at which the majority of a given day's trading in a given security took place. It is calculated by adding the dollars traded for the average price of the bar throughout the day ("avgprice" x "number of shares traded" per bar) and dividing the total shares traded for the day.

There is not a great deal of meaning for VWAP that spans multiple days and it is not a great trend predictor as you can see in the attached picture; I am not sure if many traders follow it other than that there is a correlation between daily VWAP and Market Profile's idea of POC (Point of control). The previous ELD attached in this thread will not do VWAP across different trading days. There is some code below from the TS forum that will, posted below.

{ plot a five-day VWAP to use on my charts } 

{ Format -> Symbol... -> Settings tab -> For volume, use: Trade Vol } 

{ Need more than 5 days of data not including bars to satisfy MaxBarsBack } 

inputs: 
Price( AvgPrice ), 
Color( Red ); 

variables: 
Trade_Vol( 0 ), 
VWAP_5Day( 0 ), 
TLID( -1 ), 
x( 0 ); 

arrays:	 
VPSum[5]( 0 ), 
VSum[5]( 0 ); 

if Date <> Date[1] then { detect day changes } 
begin 
{ Build the arrays of Summed Price and Volume } 
for x = 5 downto 1 
	begin 
	VPSum[x] = VPSum[x-1] ; 
	VSum[x] = VSum[x-1] ; 
	end ; 
if VSum[5] > 0 then 
	begin 
	{ Calculate the 5-day VWAP once values for the 5th day are obtained } 
	VWAP_5Day = SummationArray( VPSum, 5 ) / SummationArray( VSum, 5 ) ; 
	{ Plot the end of each day starting with the 5th day } 
	Plot1( VWAP_5Day, "VWAP_5Day", Color ) ; 
	{ Project last calculated VWAP_5Day forward with a Trendline } 
	if TLID = -1 then 
		begin 
		TLID = TL_New( Date[1], Time[1], VWAP_5Day, Date, Time, VWAP_5Day ) ; 
		TL_SetExtRight( TLID, true ) ; 
		TL_SetColor( TLID, Color ) ; 
		end 
	else 
		begin 
		TL_SetEnd( TLID, Date, Time, VWAP_5Day ) ; 
		TL_SetBegin( TLID, Date[1], Time[1], VWAP_5Day ) ; 
		end ; 
	end ; 
end ; 

if BarType >= 2 then { ie, not tick/minute data } 
Trade_Vol = Volume 
else { if tick/minute data } 
Trade_Vol = Ticks ; 

{ Sum Price and Volume data } 
VPSum[0] = VPSum[0] + Trade_Vol * Price ; 
VSum[0] = VSum[0] + Trade_Vol ; 

5aa70e303ddac_Calculatethe5-dayVWAPoncevaluesforthe5thdayareobtained2008-01-05_111820.png.228fe5bf65f7373b8bb7d2e65c565ce9.png

Share this post


Link to post
Share on other sites

I thought it would make a difference depending on the start point...so the BIG question is, what is the best start point? 12am? 8am?

 

Since I am a newbie trader, any one want to suggest what they are using?

 

Thanks TRunner for the other version of vwap...i'll take a look at it over multiple days...from your post, it doesn't look like it means much...at least for the past few weeks.

Share this post


Link to post
Share on other sites

I don't know, there is something very wrong with both Ensign and the TS vwap/bands in those charts.

I wonder if Jerry could post a chart from that day? I've noticed with alot of the versions people have wrote up, something is totally off with the variance calculations for the bands. With that big drop at the open the dev band away from price should be expanding. Alot of the versions people have made the bands just look like channels while in Jerry's videos they look more like "claws".

Investors r/t seems to be the closest to what Jerry did in his videos. Here is a chart from marketdelta/investors RT with DTN iq feed. The variance setting for investors r/t seems to get like what Jerry does, then the proprietary is different as price never seems to get beyond the 2nd standard dev band on any chart i've pulled up.

vwapbands.jpg.582b4fc43139554d2d21962b812fab4e.jpg

Share this post


Link to post
Share on other sites
I don't know, there is something very wrong with both Ensign and the TS vwap/bands in those charts.
Please see the attached PNG. The TS VWAP SD appears to match what you displayed if TS code is set to 0930 regular trading hours (EST). By default, both the Ensign and TS appeared to use the start of next day as basis for calculation.

5aa70e3176f41_TSVWAPSD2008-01-04_180248.png.51eb7bf195db8bdb9dbfdfa3d94dd4cb.png

Share this post


Link to post
Share on other sites
I don't know, there is something very wrong with both Ensign and the TS vwap/bands in those charts.

I wonder if Jerry could post a chart from that day? I've noticed with alot of the versions people have wrote up, something is totally off with the variance calculations for the bands. With that big drop at the open the dev band away from price should be expanding. Alot of the versions people have made the bands just look like channels while in Jerry's videos they look more like "claws".

Investors r/t seems to be the closest to what Jerry did in his videos. Here is a chart from marketdelta/investors RT with DTN iq feed. The variance setting for investors r/t seems to get like what Jerry does, then the proprietary is different as price never seems to get beyond the 2nd standard dev band on any chart i've pulled up.

 

Hi Darth, firstly I am no maths expert though I did do a degree in a math heavy subject ... that was in the stoneage! I did do a bit of research (actually a lot) when Jerry first published this excellent series.

 

There are a few algorithms out there for variance but they can be prone to accuracy errors due to overflow and underflow. More likely an issue is when using anything but individual ticks you need to decide what price level to assign the volume of that bar to. Ensign I think uses a uniform distribution at each level from bar high to low. I guess some might use mid points or other methods. Sounds like this might not be the issue you have got. By definition price will get to the 3rd standar deviation X% of the time (can't remember what X is but its pretty small) from memory 2SD's is something like 2% of the sample. anyway no real answers but some food for thought.

 

Cheers.

Share this post


Link to post
Share on other sites

Thank you for your comments Blowfish. As a long time user of Multicharts, could you please comment on the following chart where the VWAP-SD indicator plots dramatically moved up and down vs the underlying bars as one scrolls along the x axis. Is this a bug in MC? Is there an easy fix? The same code in TS and MC also do not show the same results. Thanks.

5aa70e31ed514_MCcomboTSVWAPSD2008-01-08_202607.thumb.png.120f0660aebd7315e250bd77bbe3fabd.png

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.