|
|
|
|
|||||||
| Trading Indicators Post your custom trading indicators. If you download, remember to click INSTALL. |
![]() |
| Bookmarks | |||||||
del.icio.us
|
StumbleUpon
|
Google
|
Digg
|
Facebook
|
Furl
|
Reddit
|
Netscape
|
|
|
LinkBack (5) | Release Tools | Display Modes | Language |
|
VWAP Indicator with 1SD and 2SD bands
Developer Last Online: May 2008
Guys I am not a TS coding guru by any means...still new at it but wanted to share this code if anyone else was interested. Just wrote this code for myself to keep up with JPERL's threads on Market Statistics. It plots the VWAP, and 1st and 2nd Standard Deviation bands. It lines up with his numbers within a tick or two so I think it is working correctly.
Any other TS coders out there please take a look because it can probably be improved upon. This is my first post of a file so if I screwed something up...be gentle! Hope this helps, dbntina boxmeister ![]() |
||||||||||||
|
Show Your Support
|
||||||||||||
|
|
||||||||||||
|
By
bh_trade
on
08-03-2007, 11:56 AM
|
|
Re: VWAP Indicator with 1SD and 2SD bands
dbntina:
Thank you for posting this. I had always wanted an indicator that provided statistical representation of what was happening today. Nice job! |
|
By
JayRemy
on
08-03-2007, 12:40 PM
|
|
Re: VWAP Indicator with 1SD and 2SD bands
Good post mate. I've been wanting to do this since reading Jpearls threads. I am however using ninja trader, so (if you dont mind) Im going to try and convert your code to ninja script.
I dont think there are too many ninja users out there - everybody seems to use esignal or tradestation! Cheers, Jay. |
|
By
nickm001
on
08-03-2007, 12:51 PM
|
|
Re: VWAP Indicator with 1SD and 2SD bands
Hi DbnTina,
I am not sure if the calculation for vi is correct. In your EL you have used variance_i = ((UpTicks[Value1]+DownTicks[Value1])/ShareW) * (Square(AvgPrice[i]-VolWAPValue)); where (UpTicks[i]+DownTicks[i]) represents volume of the bar [i]... I think in a probability calculation one should use total volume at price i, not just volume of the bar i. Lets ask Jerry for clarification. |
|
By
dbntina
on
08-03-2007, 06:22 PM
|
|
Re: VWAP Indicator with 1SD and 2SD bands
Hi DbnTina,
I am not sure if the calculation for vi is correct. In your EL you have used variance_i = ((UpTicks[Value1]+DownTicks[Value1])/ShareW) * (Square(AvgPrice[i]-VolWAPValue)); where (UpTicks[i]+DownTicks[i]) represents volume of the bar [i]... I think in a probability calculation one should use total volume at price i, not just volume of the bar i. Lets ask Jerry for clarification. NickM001, You are correct. In the code, ShareW is always the total share volume up to the current time from your start. You divide the volume of the current bar by the total volume and use this "normalized volume" to multiply with according to Jerry. This should be correct if I am understanding the formula correctly. It also seems to line up with Jerry's bands so I think it is correct. Let me know...I can correct if I am not suppossed to normalize this way... Thanks for taking a look at the code if it is incorrect we want to find out now. dbntina ![]() |
|
By
Soultrader
on
08-03-2007, 07:30 PM
|
|
Re: VWAP Indicator with 1SD and 2SD bands
Hi dbntina,
Thank you for your contribution. If you happen to need any updating on the code, threads here can be edited at anytime so please feel free to do so. Also, would it be possible to add a screenshot of the indicator in action? It would help traders give a visual clue on what the indicator is all about. Thanks. |
|
By
nickm001
on
08-03-2007, 11:46 PM
|
|
Re: VWAP Indicator with 1SD and 2SD bands
OK let me try to explain again my understanding of the formula. Let quote what Jerry wrote in his explanation:
QUOTE#################### ################### While we won't address all these questions in one thread their answers can be obtained by analysis of the volume distribution function. To do so requires that we introduce a third property of the volume distribution function called the Standard Deviation of the VWAP, SD for short. SD is computed from the following equations: NOTE : Formula did not copy ... see http://www.traderslaboratory.com/for...dard-2101.html where the summation subscript i, runs over all prices in the volume distribution pi = ith price in the volume distribution Pi = vi/V is the probability of occurrence of price pi vi = the volume traded at price pi from the volume distribution V = total volume for the entire distribution ######################### ######## Note that factor vi is volume traded at price pi. If I understand your code, you have used volume of the bar[i], or volume at time [i], not as described in the formula. To get proper value for vi, you would have to keep track of all the volume distribution at EACH price level of the range in the array and use the value of volume array element [i] that corresponds to price pi. It can be done, but it would take more then few lines of code, unfortunately. For some odd reason, it does not seem to make much difference even if you set vi/V = 1, for the few sample charts I looked at. So for all practical purposes, SD value is usable... |
|
By
BlowFish
on
08-04-2007, 04:34 AM
|
|
Re: VWAP Indicator with 1SD and 2SD bands
I think it's considered an 'acceptable' trade of computational complexity/speed against accuracy.
You can control the accuracy by putting a second series of lower timeframe bars and applying the indicator to that perhaps? (hide the second series). A 1 tick series should be completely accurate? Just a thought. Oh and thanks Dbntina! |
|
By
dbntina
on
08-04-2007, 10:19 AM
|
|
Re: VWAP Indicator with 1SD and 2SD bands
Nick,
You are exactly correct...I know what you are getting at for sure. Blowfish is exactly right...the code I wrote on a 10M bar will do what you are getting at but only at 10M increments. A 5M bar will be more accurate...then a 3M bar will be even more accurate...then a 2M bar will be even more accurate...etc. Jerry is content using a 2M bar. Technically you would have to run it how you are describing to get it exact but I am not sure that it is necessary according Jerry he thinks running it on a 2M bar is close enough. I understand though what you are saying because if I remember my match classes correctly it is a continuous function not a discrete function? I am approximating (so is Jerry I believe) using calculations at every 2 minutes (discrete) when the true value would be evaluated constantly like a continuous function. We will get more and more accurate as will decrease our bar interval. But knowing that the bands are truly at .38 on the S&P as oppossed to having our numbers 1 to 2 ticks off (I don't know if this is the case but I am just giving an example) I think it is close enough on a 2M according to Jerry. Let me know if I am misunderstanding what you are getting at...the important thing is that the code is doing the same thing as Jerry's code on a 2 minute chart...that was all I was trying to accomplish so I could follow Jerry's logic and trade management. dbntina ![]() |
![]() |
LinkBacks (?)
LinkBack to this Thread: http://www.traderslaboratory.com/forums/f46/vwap-indicator-with-1sd-and-2sd-2175.html
|
|||
| Posted By | For | Type | Date |
| Incredible Charts: Trading - Systems: VWAP Part Two. | This thread | Refback | 01-31-2008 06:28 PM |
| Forums - Multicharts float display error? | This thread | Refback | 01-09-2008 11:22 AM |
| Forums - Multicharts float display error? | This thread | Refback | 01-08-2008 09:17 PM |
| Traders Laboratory - forumdisplay | This thread | Refback | 08-05-2007 06:26 PM |
| Traders Laboratory | This thread | Refback | 08-03-2007 02:03 PM |
| Currently Active Users Viewing This Release: 1 (0 members and 1 guests) | |
| Release Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Release | Release Starter | Category | Comments | Last Post |
| Is the RSI indicator any good? | Lisa | Technical Analysis | 14 | 04-27-2008 12:41 PM |
| Trading With Market Statistics.II The Volume Weighted Average Price (VWAP). | jperl | Market ProfileŽ | 54 | 02-05-2008 04:56 PM |
| Trading with Market Statistics III. Basics of VWAP Trading | jperl | Market ProfileŽ | 45 | 01-17-2008 02:07 PM |
| Question regarding Bollinger Bands | Robert | Technical Analysis | 17 | 04-29-2007 11:58 AM |