Anchored VWAP Indicator for ThinkorSwim

Thank you BenTen for the Anchored VWAP, loving the setup and signals generated. I'm not a coder, is it difficult to have an alert with sound and text? That would be just awesome! Thanks again...
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

One of my favorite indicators but unfortunately, over the past couple of weeks of testing, I could not get it to work without consistently delayed signals. I played with it on a 5 and 10 minute chart on the ES and CL, played with the variables, but with no luck. It was good to confirm my other signals in hindsight,, but as a trading signal, too delayed to be useful.
 
Hello, I refresh the TOS chart, and draw the AVWAP. Also on my phone, as I open each futures symbol it shows properly. If you don't refresh, then it's delayed...
 
@Alan Sigudo Try this code:

Code:
input anchorDate = 20190701;
input anchorTime = 0930;

def postAnchorDate = if GetYYYYMMDD() >= anchorDate then 1 else 0;
def postAnchorTime = if SecondsFromTime(anchorTime) >= 0 then 1 else 0;

plot anchoredVWAP = TotalSum(if postAnchorDate and postAnchorTime then ((high+low+close)/3)*(volume) else 0)/TotalSum(if postAnchorDate and postAnchorTime then volume else 0);

anchoredVWAP.setStyle(Curve.Firm);
anchoredVWAP.SetLineWeight(3);
anchoredVWAP.SetDefaultColor(Color.Cyan);
 
Ben, thanks, this was the code I was looking at before I posted to this forum. I'm looking for a way to drag the start point around using the gui, in the same way that a trendline start point can be dragged around on the chart visually.

Thanks!
 
@BenTen Will these signals re position or adjust based on the prices/time (The reason I am asking is for Trendsignal Script it repaints)
 
Yeah, I saw both of those. Sounds like you don't know how to create indicators with endpoints that can be defined using the UI, by dragging it to different bars on the chart. That's ok --I'm sure it's not simple.
 
Greetings, new member here and not much of a coder, just TOS user. Thanks a lot for the AVWAP script, great study. I am trying to generate study alerts based on it, however, after selecting the criteria "Up" signals, I get this error on the thinkScript editor:
Error processing referenced script AnchoredVWAP: No such function: barNumber at 1:38
Expected double
How can this error be fixed?
Thanks a lot.
Rfrankco.
 
Hello. Is there a way to add sound alerts to the indicator? I am using the original version of the script. Thank you.
 
Is there a way to add the 2 & 4 Standard Deviation Bands to this anchored VWAP? That would make it like the Maximum Permissible Deviation (MPD) Study for TOS that I saw somewhere else! I see similar code that others posted but you cannot change the anchor date and time for those. Thanks in advance and keep up the awesome work!
 
Hi - I am looking for help in coding VWAP that is anchored to the 52 week High. Is there a way to set the reference date in the YYYYMMDD format? See below for script that I am looking for help with. Ideally can get the date referenced in the first line of the code correctly as what I have in there is not correct. Thanks!

Code:
def anchorDATE = lookuphighest(barNumber(),high,252);
def postAnchorDate = if GetYYYYMMDD()  >= anchorDATE then 1 else 0;

def anchoredVWAP = TotalSum(if postAnchorDate then ((high + low + close) / 3) * (volume) else 0) / TotalSum(if postAnchorDate then volume else 0);

plot AVWAP = anchoredVWAP;
 
There are lots of VWAP indicators but I cannot find one that plots accurately the start time of 7:00 AM.
Can anyone help? I do have one that start at regular trading hours start. and I have other anchored VWAP's,
but they start plotting from the close of yesterday and then adds cumulative volume from that close yestarday.
For example, I want one that starts at 7:00 am and the first minute vwap "only starts there."
any help is greatly appreciated. :)
 
I have an Anchored VWAP set to 6:00 pm EST the previous evening. I want to add Standard Deviation Bands on either side as shown below:

+/- Daily Range / 2
+/- Daily Range / 4

Any help would be appreciated!
 
Haven't tested, but try this

Code:
#yakBro intraday anchoredVWAP excluding extended hours volume 2019
#barbaros stddev channels 05.12.2020

declare hide_on_daily;

def anchorTime = 0930;
def anchorEnd = 1600;

input ShowTodayOnly = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;
def postAnchorTime = if SecondsFromTime(anchorTime) >= 0 then 1 else 0;
def endAchorTime = if SecondsTillTime(anchorEnd) >= 0 then 1 else 0;

#plot anchorVWAP for intraday
def count = compoundValue(1, if postAnchorTime and endAchorTime then 1 else 0, 1);
def volumeSum = compoundValue(1, if postAnchorTime and endAchorTime then volumeSum[1] + volume else 0, volume);
def volumeVwapSum = compoundValue(1, if postAnchorTime and endAchorTime then volumeVwapSum[1] + volume * vwap else 0, volume * vwap);

plot anchorVWAP = if ShowTodayOnly and !Today then Double.NaN else if anchorTime then volumeVwapSum / volumeSum else Double.NaN;
anchorVWAP.setStyle(Curve.Firm);
anchorVWAP.setDefaultColor(Color.light_ORANGE);
anchorVWAP.setlineWeight(2);

def aVWAP = Average(anchorVWAP);
def sVWAP = fold n = 0 to count with s do Sqr(GetValue(anchorVWAP,n) - aVWAP);
def stdVWAP = Sqrt(sVWAP/count);
AddLabel(yes, stdVWAP, Color.GRAY);

input deviations = 2.0;
plot UpperLine = anchorVWAP + deviations * stdVWAP;
plot LowerLine = anchorVWAP - deviations * stdVWAP;
UpperLine.SetDefaultColor(GetColor(8));
LowerLine.SetDefaultColor(GetColor(8));
 
@barbaros Thank you but that did not work. The anchor must be 6 pm EST the previous evening. The lines are stuck to each other.

If there is a specific anchored VWAP you like, you can add the last few lines to that to get the std dev channels.

Code:
def aVWAP = Average(anchorVWAP);
def sVWAP = fold n = 0 to count with s do Sqr(GetValue(anchorVWAP,n) - aVWAP);
def stdVWAP = Sqrt(sVWAP/count);
AddLabel(yes, stdVWAP, Color.GRAY);

input deviations = 2.0;
plot UpperLine = anchorVWAP + deviations * stdVWAP;
plot LowerLine = anchorVWAP - deviations * stdVWAP;
UpperLine.SetDefaultColor(GetColor(8));
LowerLine.SetDefaultColor(GetColor(8));

As far as I understand, as the anchored vwap movements are very small, std dev is going to be very short. Unless, you want the price std dev around the vwap line.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
321 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top