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.
//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)
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?
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!
Syd
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).
//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) > 1
Only 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.