Anyone know how to calculate SD of VWAP?

Discussion in 'Technical Analysis' started by IronFist, Jul 23, 2008.

  1. B.I.N.G.O.

    rather than plot VWAP +/- stdev(VWAP)

    create a variable called diff
    Let diff = VWAP - P

    The variable gets updated at each step as
    VWAP and Price get updated.

    then calculate stdev(diff)

    add +/- 3 of these stdev pts to each VWAP pt. in your data series.
    Overlay that with the price series.

    This also gets updated at each step.

    Buy me a beer one of these days.
    Cheers.

    :D
     
    #41     Jul 25, 2008
  2. i'll do that in a bit. i'm away now (posting from my blackjack)
     
    #42     Jul 25, 2008
  3. Xuanxue

    Xuanxue

    Since I'm the odd man out here and I'm showing interest, if albeit an unlearned interest, in learning how to excel program VWAP, will someone tell me how to upload the calculations, and which charting software allows it? I know it's a pain in the arse dealing with a total coding noob but saving me a decade spinning the bottle on books while I'm seeing it on another's chart is, I'll admit, akin to leading by a carrot. Despite hating carrots myself, remember you were once a coding noob, too.

    Also, while I often evoke distain in the best, and worst, of people for various irrational reasons, other total noobs too afraid to claim being so are peering, laying in wait in anticipation for some direction.

    It certainly wouldn't go unappreciated.

    Thank you, good night and God bless.
     
    #43     Jul 25, 2008
  4. Let me make sure I have this right.

    The range of values which I'm using to calculate the SD is going to be every candle so far since the new VWAP began, right? So I can't just use a fixed value n for this calculation.

    Assuming that's the case I'm only going to be able to do this for fixed time bars because I'm not good enough to code it such that it could use range/tick/volume bars where there might be a different amount each day.
     
    #44     Jul 25, 2008
  5. Here it is on 15 min charts.

    Note that the trading day is the small area between the dotted yellow line (8:30am CST) and the dotted blue line (3pm CST).

    Not sure if this is correct tho. I think it might not be...
     
    #45     Jul 25, 2008
  6. Here's a closer look at yesterday and today.
     
    #46     Jul 25, 2008
  7. Ok, chart is looking much better.

    Few issues problems to iron out.

    1) Is that 7/25 marker at the bottom of the 2 period window the end of the 1st 24 hour window?
    I'll assume it is for the moment.

    Couple of funny things, which may be related to your question...

    2) That large red candle at about 9:30 seems to be swinging pretty wildly outside of the 3std band. Doesn't really seem right... HOWEVER, I think it is because you are calculating STD relative to the average of the price bar (is this what you mean by varying ranges?). You could recode it so that instead of using average price, you use the differnece value of the greatest price swing during the OHLC bar during that bar minus VWAP. I.e.
    diff = max(VWAP - P(OHLC)) for each point.

    Or more explicitly, diff is equal to the maximum of
    (VWAP-Po, VWAP-PH, VWAP-PL, VWAP-PC) for each bar.

    That would solve the narrow boundary issue.

    3) secondly, if your 24 hour window period ends at the 7/25 marker, the old values of VWAP, stdev, etc.. need to be reset and started at the next point.
    You only get to define 1 and only 1 window of time to reapply the function to each time. I.e. start VWAP and STDEV at midnight end at midnight.
    Clear variables. Repeat.
    Start next VWAP/stdev at next point after midnight (looks correct on VWAP, but stdev did not seem to reset on 7/25 open), why?


    I can't see why you would change the interval between time bars on any given day (24 hr) window. In any typical program I'm aware of, the time intervals are always fixed (1 bar/min/day, 1bar/sec/day, 1bar/10min/day, etc.. is fixed over window).
    Not sure why there would be a different amount each day. Maybe you can clarify.

    If you did want to start calculating VWAP at the 1st instant of each trading day (as you mentioned), they would have to change that in the program or give you the flexibility to do so.
    It looks like they fix the VWAP window at 24hrs. I can see why that alternative might be more meaningful.
     
    #47     Jul 25, 2008
  8. Yeah that's the beginning of 7/25.

    I was just using the close price of each bar.



    That wouldn't be too hard to add.

    That's what I'm not entirely sure how to do. I'm using SierraChart's worksheet functionality because I don't know C++ so I'm not able to write actual code per se. I should probably learn.

    Ok, so time bars always have the same amount per day. If you're using hour bars, there will be 24 of them. If you're using 15 min bars, there will be 96 of them, etc. If you're using range, tick, or constant volume bars, there will be a varying number of bars per day depending on the range/volume and number of trades that day. In my limited worksheet functionality, I don't think it's possible to be computing the current bar number like this and having it reset each day. At least with constant time bars I know how many there will be and can use that many in my SD range. Hopefully that made sense.

    See previous paragraph.
     
    #48     Jul 25, 2008
  9. Yeah that's the beginning of 7/25.

    That wouldn't be too hard to add.


    good. Plot a revised chart when your done. Actually, I thought about it a bit more. You should try to plot it both as VWAP minus avg price and then VWAP minus max price. The max may be a bit extreme. Didn't realize you were using closing price.



    That's what I'm not entirely sure how to do. I'm using SierraChart's worksheet functionality because I don't know C++ so I'm not able to write actual code per se. I should probably learn.


    Can't help you there. You're limited by Sierra Chart's and your programming capability (can ask for help on the boards... good luck).


    Ok, so time bars always have the same amount per day. If you're using hour bars, there will be 24 of them. If you're using 15 min bars, there will be 96 of them, etc. If you're using range, tick, or constant volume bars, there will be a varying number of bars per day depending on the range/volume and number of trades that day. In my limited worksheet functionality, I don't think it's possible to be computing the current bar number like this and having it reset each day. At least with constant time bars I know how many there will be and can use that many in my SD range. Hopefully that made sense.


    I'd have to see it a little more clearly. But even if the intervals were not constant as you say, you could still update each VWAP/STDEV at every point, and I believe it would still be proper. Again, though, as you say, you could be limited from doing so due to your programming/platform capability. Don't know if I can help there.
     
    #49     Jul 25, 2008
  10. dcriese

    dcriese

    The discussion on the use of VWAP and SD bands on http://www.traderslaboratory.com/forums/f6/trading-with-market-statistics-iv-standard-2101.html has the formula for computing these bands (see attached graphic).

    There are plenty of charting programs that can plot these bands for you pretty easily, either using their built-in indicators or simple programming. Ensignsoftware and MarketDelta/InvestorRT have it built in. Genesis Trade Navigator can be easily programmed with the following programming:

    For the VWAP (intraday only) I choose to use the AvgOHLC of each bar as the “price.” So the VWAP at each bar is recalculated as :

    MovingSum ((AvgOHLC * Volume) , BarOfDay , 0) / MovingSum (Volume , BarOfDay , 0)

    Where BarOfDay is the nth bar from the open.
    (the 0 in the function above is not relevant, by the way)

    Then using the Standard Deviation equation above, the programming for the 1st SD above the VWAP:

    vwap + SqrRoot (MovingSum (((Volume / MovingSum (Volume , BarOfDay , 0)) * Square (AvgOHLC - vwap)) , BarOfDay , 0))

    then use similar equations to make bands for the 1,2,3 SD bands below and above the VWAP. So if you can’t do it with Sierra Chart, then you might consider just getting another charting program.
     
    #50     Jul 26, 2008