Anchored VWAP

This is the anchored VWAP which can be used on any timeframe, including intraday.

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


Hello @jamiespips, can you give me instructions on how to use this indicator? I add it but don't know how to anchor it to a certain bar.
+125 Reply
@jamiespips Thanks for sharing. Somehow I find the indicator can't be anchored to the first two intra-day bars for newly listed IPO stocks, for example the stock BYND. Does the indicator requires at least two bars' data to calculate? thanks,
+12 Reply
It seems unable to go back further than like 4.5 months
+3 Reply
jamiespips TheTechnique
Hi @TheTechnique,

This is a fault of tradingview - it only lets you calculate so much data. I have found if you use it at non-peak times it works... but most of the time if you're calculating a lot of data it wont work. Use TC2000 if AVWAP is central to your trading.

+1 Reply
rosstopher jamiespips
@jamiespips, Any knowledge on an AVWAP tool code for ToS platform? Any way to make this script work with a click and touch on a candle (rather than having to go into settings every time to manually change anchor date/time?
+5 Reply
trendfirst jamiespips
Hello @jamiespips, and thank you for this indicator, I use it every day. I have also run into issues when using it more than a few months back, and contacted Tradingview about data. Here's what they said:

"For upgraded plans, the length of historical data for any intraday time interval is 10,000 bars/candles + additionally several bars/candles back to the beginning of the week, month or year (depending on the resolution). Unfortunately, this limit cannot be extended. We may at some point consider extending this feature, but no decision has been made and there is no ETA for said extension.
With that being said, if you change the chart interval to daily or daily-based, you will see a longer date range. We display all available data for daily-based intervals."

So they are claiming that it is not a data problem. However, having worked with this group at Multicharts for many years, it is my observation that their first reaction to a problem is "It's not us, it's something else, our work is just fine thank you." So as far as I'm concerned they do have a credibility problem.

I like to have the following baseline AVWAPs on my charts: Year to date, Month to date, Week to date, Latest high, Latest low. YTD is pretty much out of the question an this point, as we are over 4 months into the year. MTD, WTD, H, L usually work pretty good. Intraday a few days back always works.

So far I am using it with a premium plan and their free data. Has anyone tried it with a data subscription from the exchanges? I already pay for data at IB, so I don't pay for it on Tradingview. As a side note, I wonder if the paid subscription volume data would be different, yielding a different AVWAP curve. Can anyone comment on this?

bluedesk trendfirst
Thanks for describing the data issue, so that others can modify this script.
trendfirst bluedesk
@bluedesk, You are welcome. But the built-in AVWAP works quite well, so I don't bother with this script any more.
trendfirst jamiespips
Hello @jamiespips,

I have been messing around with this script, partly to learn more about Pine, and partly to test some ideas that I had.

First, I converted it from v2 to v4.
Second, I started looking at the functions and trying to figure out why it was so stubborn about plotting when the anchor point was several months in the past. I think I have made some progress here. I started looking at the "security" function, and noticed the time interval was 1 minute in the script. If the script is calculating every minute, and you try to go back 3 months, that is 390 minutes/session x 66 trading days (approx), which is almost 25k calculations. My guess is this is where it is choking. So I changed the time interval from "1" to "D", and I was able to plot it back several years. Can probably go further, but I haven't tested beyond 2 years.

I am going to set up 6 separate scripts, named YTD AVWAP, MTD, WTD, HI, LO, INTRADAY. I'll set the security time interval to "D" for YTD, MTD, WTD, and probably "1", or some multiple, for the others, depending.

At any rate, I think this will fix the issue with not being able to use distant anchor points.
ElAnalista TheTechnique
@TheTechnique, This is very bad, specially in correction/bearish times