Welcome to the Traders Laboratory Forums.
Market Profile Are you a market profile trader? Post here.

Reply
Old 08-25-2007, 05:51 PM   #81

Join Date: Jan 2007
Location: san jose
Posts: 90
Ignore this user

Thanks: 0
Thanked 5 Times in 5 Posts

Re: Trading with Market Statistics. IV Standard Deviation

here is the code segment calculationg vwap.. Line 3 sums total volume, not just volume of the bar n
____________________
Volume_i = UpTicks+DownTicks;// volume for a bar "i"
Price_Volume = Price_Volume + (AvgPrice * Volume_i);// SUM ( Price_Volume[i] ) + AvgPrice * Volume_i
Total_Volume = Total_Volume + Volume_i;// sum total volume

if Total_Volume > 0 then
vwap_value = Price_Volume / Total_Volume;
_________________________ ____
nickm001 is offline  
Reply With Quote
Old 08-27-2007, 05:41 AM   #82

BlowFish's Avatar

Join Date: Mar 2007
Location: In Da House
Posts: 3,292
Ignore this user

Thanks: 129
Thanked 1,054 Times in 702 Posts

Re: Trading with Market Statistics. IV Standard Deviation

Hi Nick,

posted a long reply yesterday and then couldn't submit it ! I thought I saved the txt file but can't find it. I think all the tradestation calculations for VWAP may be wrong. TS native, mine, Dbntina, and the code you submitted.

In your code line 3 does not sum total volume it sums volume up to bar N. Whenever a new bar comes in (with added volume) every single preceding bar needs re-calculating with the new total volume for the series. You need to do something like

for n = 1 to totalnumber of bars VolumeTotal= VolumTotal + Volume(n)

then you run the weighting.

for n = 1 to totalnumber of bars VWAP = close * Volume(n) /VolumeTotal

Basically you need to use the volume for the whole series (not just up to bar N) for the weighting. The same issue as with the SD.

I'm not sure if I am explaining myself well do you see what I am getting at?

If you are calculating the variance with total volume for the whole series should you not do the same for the VWAP itself?

Jerry sorry to bug you I wonder if you had any comment on this, a simple yes or no would be cool

Cheers,
Nick.

P.S. Apologies to all, I know I am being pedantic about this but its become a sort of challenge. having said that its not wrong to strive for 'truth' & 'accuracy'.
BlowFish is offline  
Reply With Quote
Old 08-27-2007, 09:09 AM   #83

Join Date: Jan 2007
Location: san jose
Posts: 90
Ignore this user

Thanks: 0
Thanked 5 Times in 5 Posts

Re: Trading with Market Statistics. IV Standard Deviation

HI Blowfish
Quick reply... I will look at the code again after market close. Should be easy to print the volume out for testing...
The way I read the code is:
1. Variable "Total_Volume" is set to zero at the beginning of the period ( standard TS code uses if date[0] <> date[1] then...
2. each bar you add bar volume to "Total_Volume" ( line 3 of the code I posted)
nickm001 is offline  
Reply With Quote
Old 08-27-2007, 04:48 PM   #84

jperl's Avatar

Join Date: Sep 2006
Location: Rochester,NY
Posts: 359
Ignore this user

Thanks: 2
Thanked 362 Times in 74 Posts

Re: Trading with Market Statistics. IV Standard Deviation

Quote:
Originally Posted by BlowFish »

In your code line 3 does not sum total volume it sums volume up to bar N. Whenever a new bar comes in (with added volume) every single preceding bar needs re-calculating with the new total volume for the series. You need to do something like

for n = 1 to totalnumber of bars VolumeTotal= VolumTotal + Volume(n)

then you run the weighting.

for n = 1 to totalnumber of bars VWAP = close * Volume(n) /VolumeTotal

Basically you need to use the volume for the whole series (not just up to bar N) for the weighting. The same issue as with the SD.

If you are calculating the variance with total volume for the whole series should you not do the same for the VWAP itself?
Yes, that is correct Nick. Every time you add a new bar, with new volume, you have to renormalize the VWAP computation to include this new volume. What that means is computing the VWAP terms beginning at the start time each time you add a new bar.
__________________
JERRY

---I'm going to trade til I'm 100, or die trying----
jperl is offline  
Reply With Quote
Old 08-27-2007, 04:50 PM   #85

Join Date: Jan 2007
Location: san jose
Posts: 90
Ignore this user

Thanks: 0
Thanked 5 Times in 5 Posts

Re: Trading with Market Statistics. IV Standard Deviation

I have a pic for you. Left side has 405 min bars with total volume showing at lower right corner in red (850,237). Second chart is 5 min with vwap modified to print Total_volume value at last bar( I used AtCommentrayBar( ) ). You can see it shows the same volume.
re code comments:
precondition at bar number n..
_________________________ _________________________ _____
"Price_Volume" has subtotal of all Price_i * Volume_i, where i is 1 - (n-1)... and
"Total_Volume" has subtotal of all Volume_i, where i is 1 - (n-1)...
_________________________ _________________________ ________
NOW the bar n happens and the code below is executed

Volume_i = UpTicks+DownTicks;// volume for a bar "i"
Price_Volume = Price_Volume + (AvgPrice * Volume_i);// SUM ( Price_Volume[i] ) + AvgPrice * Volume_i
Total_Volume = Total_Volume + Volume_i;// sum total volume

if Total_Volume > 0 then
vwap_value = Price_Volume / Total_Volume;

I think code is correct..
How do u read ( understand)this code segment? I guess I am not sure if I understand your concern.

Note: Just noticed that I used 2 forms of ES on the pic... ESU07.D is the same as @ES.D ( TS symbol for continuous contract)
Attached Thumbnails
Trading with Market Statistics. IV Standard Deviation-vwap-volume1.gif  

Last edited by nickm001; 08-27-2007 at 05:13 PM.
nickm001 is offline  
Reply With Quote
Old 08-28-2007, 05:28 AM   #86

BlowFish's Avatar

Join Date: Mar 2007
Location: In Da House
Posts: 3,292
Ignore this user

Thanks: 129
Thanked 1,054 Times in 702 Posts

Re: Trading with Market Statistics. IV Standard Deviation

Hi Nick,

The concern is that the value used for total volume in all the algorithms is not the total volume for the whole series it is the volume for the series up to the bar you are processing.

As an example

Lets say you are processing bar 100.

Total Volume is now the old Total Volume + Volume(100) you now need to re process bars 1-99 with the new total volume!! As there is more volume in the whole 'universe' Bars 1-99 need re-weighting taking into accounting for this volume.

Lets use the annotation Volume(1 to 100) for the total volume for bars 1 to 100

WeightedPrice(n) = price * volume(n) / volume(1 to 100) NOT

WeightedPrice(n) = price * volume(n) / volume(1 to n)

Put another way the weights on all the previous bars change when the total volume changes (i.e. there is new tick). Of course you don't re-plot old bars but the weighting they contribute changes so you do need to re-calculate the series. (well strictly speaking you do).

Obviously this is computationally intensive and my hunch is most software doesn't bother. TS dosent. Actually I wonder if institutions that lean heavily on VWAP do? Thats a spooky thought... the 'inaccurate' line seems to be heavily leaned upon.

Cheers,
Nick.

P.S. the usual caveats apply - its not the line you trade its how you trade it. Yes its all a bit anal but there is a difference etc. etc.
BlowFish is offline  
Reply With Quote
Old 08-28-2007, 09:16 AM   #87

Join Date: Jan 2007
Location: san jose
Posts: 90
Ignore this user

Thanks: 0
Thanked 5 Times in 5 Posts

Re: Trading with Market Statistics. IV Standard Deviation

.. add to that computational error associated with new calculations and I would say ... nahh... this is good enough..

P.S. finally got your point. I would say that error is well withing the "noise" of the market.
nickm001 is offline  
Reply With Quote
Old 08-28-2007, 11:19 AM   #88

BlowFish's Avatar

Join Date: Mar 2007
Location: In Da House
Posts: 3,292
Ignore this user

Thanks: 129
Thanked 1,054 Times in 702 Posts

Re: Trading with Market Statistics. IV Standard Deviation

OK glad I finally put it clearly! On the plus side this has given me a far deeper knowledge of the tools. Personally I always like to have that. I think is all to do with 'constructing your reality'. Kind of building your beliefs from ground zero. I do wonder if that is why people don't have confidence in there tools - they don't spend enough time getting to really understand what they do and how they do it.

Ironically when you have done all that leg work its probably best forgoten when you actually trade!!

I also wonder if I allowed myself to get sidetracked by the subconscious demons trying to delay the final test (trading with real money). I have spent a good portion of the last week pursuing about half a dozen versions of this indicator.

Actually I think I should post them but still could do with writing a decent histogram module. I can see that taking a while to get right.

Cheers.
BlowFish is offline  
Reply With Quote

Reply

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trading With Market Statistics.II The Volume Weighted Average Price (VWAP). jperl Market Profile 65 02-25-2012 04:02 PM
Trading With Market Statistics I. Volume Histogram jperl Market Profile 36 02-21-2012 06:23 PM
Trading with Market Statistics III. Basics of VWAP Trading jperl Market Profile 73 01-03-2012 08:06 AM
Standard deviations & Odds rayk Market Profile 2 10-07-2006 11:13 AM
Trading in a Dull Market Soultrader Technical Analysis 0 09-06-2006 11:44 AM

All times are GMT -4. The time now is 03:41 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.