VWAP Bands - Can't figure this one out...

 

*edit: I figured out how to do it, it's basically a weighed standard deviation formula instead of a regular standard deviation. And it uses N rather than N-1 (unlike Bollinger Bands). More details in my last reply.

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

Original post:

I've been spending a lot of time lately trying to figure out the way to manually calculate VWAP Bands and I can't seem to get it right...

I know how to calculate the VWAP and I know how to calculate the standard deviation of a data set either with N or N-1 (I figure N would be better for a VWAP band but I could be wrong) so that's not the issue. The issue is I have a ready made indicator already giving me values for the VWAP and its bands and I'm trying to manually calculate the bands and compare them with what the indicator is producing and I can never get them to match.

So I must be doing something wrong.

The indicator values are as follows:

Typical price from bar 0 to bar 2: (where bar 0 is the first bar of the session)

23429,3967

23421,9967

23401,0433


Volume for those bars:

959

420

821


And VWAP:

23429,3967

23427,1429

23417,4030


And the STD DEV according to the indicator:

0

3,41

12,91

(approximate values because the indicator is rounded to 2 digits)


Like I said, I can't replicate these values no matter what I try even though I know how to calculate the standard deviation of a data set.

I think I'm confused because the period keeps changing for a VWAP. Does anyone know how to figure this out or have a link to a useful article? Thanks in advance...

Standard Deviation - Trend Indicators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
Standard Deviation — value of the market volatility measurement. This indicator describes the range of price fluctuations relative to Moving...
 
Jeepack:

I've been spending a lot of time lately trying to figure out the way to manually calculate VWAP Bands and I can't seem to get it right...

I know how to calculate the VWAP and I know how to calculate the standard deviation of a data set either with N or N-1 (I figure N would be better for a VWAP band but I could be wrong) so that's not the issue. The issue is I have a ready made indicator already giving me values for the VWAP and its bands and I'm trying to manually calculate the bands and compare them with what the indicator is producing and I can never get them to match.

So I must be doing something wrong.

The indicator values are as follows:

Typical price from bar 0 to bar 2: (where bar 0 is the first bar of the session)

23429,3967

23421,9967

23401,0433


Volume for those bars:

959

420

821


And VWAP:

23429,3967

23427,1429

23417,4030


And the STD DEV according to the indicator:

0

3,41

12,91

(approximate values because the indicator is rounded to 2 digits)


Like I said, I can't replicate these values no matter what I try even though I know how to calculate the standard deviation of a data set.

I think I'm confused because the period keeps changing for a VWAP. Does anyone know how to figure this out or have a link to a useful article? Thanks in advance...

// avg contains average for n bars
// value is the input array
    double sumOfSquareDeviations = 0.0;
    for (int i = 0 ;i<n;i++)
        sumOfSquareDeviations = sumOfSquareDeviations + MathPow(value[i]-avg,2);
    double stdev = MathSqrt(sumOfSquareDeviations /n);
    

This is how I calculate standard deviation for array: value with n indices inside it.

 
Yashar Seyyedin #:

This is how I calculate standard deviation for array: value with n indices inside it.

remember standard deviation for each index depends on n previous bars.

 
Yashar Seyyedin #:

remember standard deviation for each index depends on n previous bars.

I think figured out my mistake. I'll try again but will make sure to use a volume weighed price value when calculating the differences for the variance.

I was calculating VWAP value - Typical price to get the deviation values, now I see that makes no sense, probably have to do something like VWAP - Typical price * (Vol / (Cumulative volume / N))

 

Three words: WEIGHED STANDARD DEVIATION

*edit:

Four words: POPULATION WEIGHED STANDARD DEVIATION, or "SquareRoot((SumOfProductsOf(SquaredDifferencesOfTypicalPricesAndVWAPs)andCorrespondingVolumeValues)/CumulativeVolume)"

A well kept secret it seems... I've known how to calculate regular standard deviations for a long time but this one was completely new to me and I had to guess to even figure out it was a thing. Then I ran some tests with a built-in VWAP bands indicator to check if N was used instead of N-1. Turns out it's the population weighed standard deviation so N (unlike bollinger bands that use N-1), which is why at the end of the formula you don't substract 1 from the cumulative volume.

How to Calculate Weighted Standard Deviation in Excel
How to Calculate Weighted Standard Deviation in Excel
  • 2021.02.15
  • Zach
  • www.statology.org
This tutorial explains how to calculate a weighted standard deviation in Excel, including an example.
Reason: