Optuma Forums › Optuma Scripting › Anchored VWAP scripts
Tagged: Anchored VWAP, pivots
- This topic has 6 replies, 3 voices, and was last updated 6 days ago by
Darren.
-
AuthorPosts
-
March 7, 2020 at 2:32 am #57277
Darren
- Topics: 74
- Replies: 967
- Posts: 1,041
To calculate the distance from the anchored VWAP line for IPOs – and therefore be alerted when the level is crossed – use the following scripts.
[Click here and here for other IPO posts.]
Distance from A-VWAP as a Show View tool or watchlist column:
12345678//Get IPO Date$IPO=FIRST(BARDATE());//Calculate VWAP from IPO DateR1=AVWAP(BACKTYPE=Fixed, DATE=$IPO);//Calculate % difference((CLOSE()/R1)-1)The following can be added to a watchlist for A-VWAP crosses:
123456789101112//Get IPO Date$IPO=FIRST(BARDATE());//Calc VWAP from IPO Date;V1=AVWAP(BACKTYPE=Fixed, DATE=$IPO);//Does Close cross VWAP?Above = CLOSE() CrossesAbove V1;Below = CLOSE() CrossesBelow V1;//For formatting column in a watchlist//Cross above will display as 1, cross below as 0.5;IF(Above==1,1,(IF(Below==1,0.5),0))This shows PTON crossing below, and WORK above:
To format the A-VWAP Cross column right-click on the header and change the Custom Labels to match the values in the script (ie ==1 is Above, etc):
May 19, 2023 at 3:22 pm #70951Darren
- Topics: 74
- Replies: 967
- Posts: 1,041
Here’s a script for breakouts above the AVWAP from the previous high. Based on Brian Shannon’s Tweet.
The high has been defined using a 22 bar Pivot Label, ie there has to be 22 bars (1 month on a daily chart) of lower highs before and after the high. Change the value of $PL (line 3 below) to change the significance of the high.
1234567891011//Define high based on pivots labels, eg a value of 22 requires at least 22 bars before the high and 22 bars after;$PL=22;P1=PIVOT(TYPE=High, MIN=$PL, IGNOREUNCONFIRMED=True, DIR=Both);//Get the date of the high from which the AVWAP will be calculated;$DATE = BarDate(NonZero(P1));//Calculate the VWAP from Pivot High date;R1=AVWAP(BACKTYPE=Fixed, DATE=$DATE);//Did the close cross above AVWAP and make a new month high?;CLOSE() CrossesAbove R1 and HIGH() > HIGHESTHIGH(BARS=22)May 21, 2023 at 11:00 pm #70959Paul
- Topics: 0
- Replies: 3
- Posts: 3
I am pretty new to this kind of scripting. I did not succeed in getting this script plot anything with ShowPlot on a chart. Can anyone share a workbook with this example please?
May 22, 2023 at 11:50 am #70977Darren
- Topics: 74
- Replies: 967
- Posts: 1,041
Hi Paul,
The above is a script for a scan, so it won’t plot anything. To automatically plot the AVWAP from a pivot high try this in a Show Plot:
12345678//Set Pivot Label value and get pivot date;$PL=22;P1=PIVOT(TYPE=High, MIN=$PL, IGNOREUNCONFIRMED=True, DIR=Both);$DATE = BarDate(NonZero(P1));//Calculate VWAP from Pivot Low Date;AVWAP(BACKTYPE=Fixed, DATE=$DATE)Workbook attached, with the scan formula in the watchlist column and the AVWAP plotted in blue from the 22 bar pivot high.
May 22, 2023 at 5:05 pm #70987Paul
- Topics: 0
- Replies: 3
- Posts: 3
Thank you Darren!
May 31, 2023 at 10:48 pm #71033Julia
- Topics: 1
- Replies: 1
- Posts: 2
Hi,
I tried to use the above script with the 22 day pivot, but changed the last line to Close() > R1 instead of Plot1= R1 in an attempt to scan for all stocks that are closing today above the AVWAP, but it doesn’t work, even though if I used the same script in the WL, it calculates the AVWAP correctly.
Any reason why it doesn’t work on the scanner? I’d like to scan for all stocks that are trading above a 3 month AVWAP for example.
Thanks!
SydJune 1, 2023 at 2:51 pm #71035Darren
- Topics: 74
- Replies: 967
- Posts: 1,041
I’m not sure what formula you are using but this will get you those trading above the VWAP from their 3 month high (as long as the high occurred at least 2 days ago to avoid those making new highs).
123456789101112//Get 3 month high ie over last 63 trading days;Start = BARINDEX()==LAST(BARINDEX())-63;//Find where date matches the Highest High value in the lookback period;Sig = HIGH() == HIGHESTSINCE(Start);//Remove Non Zero results to show most recent result as latest value;$DATE = BarDate(NonZero(Sig));//Calculate VWAP from High Date;R1=AVWAP(BACKTYPE=Fixed, DATE=$DATE);//Is close above VWAP and the high more that a day ago?;CLOSE()>R1 and TIMESINCESIGNAL(Sig) > 1Only 60 of the $SPX members are currently above their 3 month A-VWAP high, with $TSLA 15% above. Duplicate the scan formula above and change the last line to DIFFPCT(CLOSE(),R1) to display the percentage above in a watchlist or Show View.
-
This reply was modified 6 days ago by
Darren.
-
AuthorPosts
- You must be logged in to reply to this topic.