Scripting and Anchored VWAPs

by Apr 24, 2020All Articles, Technical Analysis, Education

The Anchored Volume-Weighted Average Price tool is a great way to determine potential support and resistance levels for any stock. Brian Shannon, CMT believes that it is because of “anchoring bias” – the human tendency to rely heavily on the first piece of information encountered when making decisions and then use that initial piece of information to make future decisions.

For more background and information on Anchored VWAPs click here to watch Brian’s video from the recent online Chart Summit, but without going into too much detail, when the tool is placed on a chart it will calculate the average price paid since that date based on the volume traded each day.

Significant highs and lows are suitable starting points from which to calculate the average price paid, so in this example of Boeing $BA, the tool has been placed on the February high (in green) and the March low (in blue). What it’s telling us is that the average price paid for Boeing since the high is $157.45, but only $139.14 since the low, and the price is currently trading between these levels, and has formed a wedge:

It would be extremely useful to know when either of these average price levels are taken out, which is where the AVWAP() function in Optuma’s scripting language comes in handy.

It’s possible to scan for when a stock has crossed it’s AVWAP from a fixed date (eg the market high on February 19th) using the following to show when the closing price crosses either above or below the AVWAP:

You could also use a rolling month, which might be useful to run at the end of a month:

This is great for anchoring to a specific date, but of course not all stocks have highs and lows on the same date. This is a bit trickier, but it can be done! The first part of the following formula identifies the respective 3 month high date for each stock, and uses that in the AVWAP function:

This watchlist column shows those where the closing price has crossed above the VWAP anchored from the 3 month high, such as for Philip Morris $PM:

Automatically applying AVWAPs

By modifying the scan formula used above we can use a Show Plot tool to automatically apply the tool to an important high or low, instead of manually drawing it on the chart. The following will apply the tool to the 3 month low (the blue line in the PM chart above).

Tip: in the Script Editor window save the script formula as an indicator to the same view to add it to your toolbox.

Calculate Percentage from AVWAP

The last example is the formula to calculate the percentage from the AVWAP, which can be used in a watchlist column or Show View. The following calculates the percentage from the AVWAP from the 3 month low:

This shows GE and SPG are 7% below their 3 month low AVWAPs – which are anchored to different low dates – and is definitely not a sign of strength!

If you are interested in learning more about the concept of Anchored VWAPs be sure to watch Brian’s video mentioned above, and you can follow him on Twitter here.


Download Workbooks

Optuma clients can save and open the workbooks by clicking the buttons below. They include the scripts in watchlist columns and tools which can be adapted as required.

Share Link
Darren Hawkins, MSTA

Darren Hawkins, MSTA

Senior Software Specialist at Optuma

Darren is the senior Software Specialist at Optuma. He joined the company in 2009 after attending an introductory technical analysis course. Darren now instructs users all over the world, from experienced Wall Street traders and professional money managers to individual traders drawing their first trendlines.

Darren grew up in the UK and attended college in the USA where he earned a BA in Economics from St Mary's College of Maryland. He went on to spend a few years working at the Nasdaq Stock Market in Washington DC. Going on to live and work in Australia, the US and currently the UK, Darren has a broad understanding of the individual needs of traders, portfolio managers and investors utilising a wide range of methodologies.

In 2014 Darren passed the UK-based Society of Technical Analysts diploma course, and when not looking at charts he keeps a keen eye on England's cricket team - especially if they are playing against Australia. He lives in the Essex countryside in England, with wife Wendy and their labrador, Gabba.


  1. mandeep

    Hi Darren great article.

    Just a quick one is there a way to backtest or signal test the AVWAP. My initial attempts don’t look right.



    • Darren Hawkins, MSTA

      Hi Mandeep,
      What are you trying to test? Because of the complexities of calculating AVWAPs and starting points it may not be possible, but post your query on the Scripting Forum with as much detail as possible.

  2. May Leung

    Thank you very much for the post, Darren!

    I find that if the Start Date falls on a non-trading day, Optuma is unable to locate a Start Date because of no data, there will be no AVWAP plot. Is that Optuma has no function to do calculation on number of bars in order to solve this? I have looked into the Barcount function but it is not for this purpose.
    3M Hi AVWAP line deviates a lot for some US tickers e.g. DHR, MO, SO, UPS …
    whereas the contrary happens on GILD.
    Any reason for that? Thanks.

    • Darren Hawkins, MSTA

      Ah – thanks for pointing that out May! I’ll see if we can find a way around that, but in the meantime you can change the lookback period in the start variable to eg 81*1 instead of 12*7.
      As for GILD vs DHR etc I’m not sure what you mean by deviates more… the AVWAP is a function of daily volume and price since the high occurred.

      • Darren Hawkins, MSTA

        Hi May the script formulas and workbooks have been updated for when the start date is on a non-trading day.

Submit a Comment

Your email address will not be published. Required fields are marked *

Blog Signup

Pin It on Pinterest

Share This