StockFetcher Forums · Filter Exchange · A-VWAP [ Anchored VWAP ] - Only for the last bar; with important limitations<< >>Post Follow-up
lorypanna
32 posts
msg #161707
Ignore lorypanna
3/16/2025 7:57:23 PM

Hi

I'm interested in Brian Shannon's teaching about A-VWAP - Anchored Volume-Weighted Average-Price.

I wanted to build a filter which allowed me to screen for stocks with a closing price near some 'important' A-VWAPs. Saying 'important' I mean: 1. A-VWAPs kept into consideration by many traders/investors (based on what Brian Shannon says); 2. A-VWAPs valid (in general) for all stocks, that is independent from anchor-dates specific for each stock (earnings date, highest-high date, lowest-low date, ...); example: quarters' first trading date.

Using the sum(indicator,length) function it's possible to obtain the A-VWAP value on the last bar and to apply filters on it for identifying 'interesting stocks'.

First of all, all the important limitations of the filter I was able to identify:
1. Due to sum(indicator,length) function's limitations, the anchor date cannot be more than 252 bars in past (the SF manual about the function says period limit = 100, but my tests showed that it works till 252)
2. SF data is not adjusted based on dividends and other 'similar events'. Keep this in mind when comparing with other platforms or analyzing downloaded data. As an example, compare the A-VWAPs obtained for LMT with adjusted data on other platforms
3. In case of splits (or reverse splits) SF data is adjusted for price (OHLC) but not for volume. As an example, compare the price/volume data for SMCI before/after 2024-10-01 with other pltaforms' data
4. Filter must be manually updated every day, changing the sum()'s length
5. If the stock's IPO date is more recent than the anchor date, in general the obtained values cannot be 'trusted' bacause sometimes price and volume data exists before IPO date (example: SFD: based on Finviz / TradingView, it IPOed on 2025-01-30, but in SF data exists back in 2024. Maybe this can be explained and it's not wrong, just my ignorance, so consider it FWIW)

As of today, the script uses the following 'important' anchor dates (they can be easily changed):
1. First trading date of 2024-Q2 - On 2025-03-14, 240 trading days have passed since the beginning of 2024Q2 (2024-04-01)
2. First trading date of 2024-Q3 - On 2025-03-14, 177 trading days have passed since the beginning of 2024Q3 (2024-07-01)
3. First trading date of 2024-Q4 - On 2025-03-14, 113 trading days have passed since the beginning of 2024Q4 (2024-10-01)
4. First trading date of 2025-Q1 - On 2025-03-14, 49 trading days have passed since the beginning of 2025Q1 (2024-10-01)

Using the values above cited, four 'Moving VWAPs' can be calculated, whose value on the last available bar (2025-03-14) is the same as the value of the 'corresponding Anchored VWAPs'.

Main sections of the filter are those named OHLC4 and Moving-VWAP NN .... NOTE: I used OHLC4 for the typical price, but that can be easily changed as wanted.

Just for clarity: I'm just a beginner / learner, not trading at present. So carefully check the code and be aware of the limitations above described and maybe others that I was not able to identify. I checked the results of the filter on TradingView charts and, when data allows, it works, but ...

Thanks in advance for any observations and suggestions on how to improve the filter, on how to chose other 'important' anchoring dates, ...

Cheers from Italy. LP

Fetcher[
/* FOR EDUCATIONAL PURPOSES ONLY */

symlist(SMCI,LMT,SPY,QQQ,IWM,SMH,XBI,DIA,XLF,TLT,XLE,XLK)

/* Filter based on volume - BEGIN */
/* Filter 1 - By TheRumpledOne*/
/*
set {VolFilt, count(volume is below 1000000, 100)}
VolFilt below 1
*/
/* Filter 2 */
/*
set {VolFilt, count(cma(volume, 100) is above 1000000, 1)}
VolFilt equals 1
*/
/* Filter based on volume - END */


offset is 0 days

chart-type is Candlestick
chart-time is 14 months


/* Exchange / ETF are identified - BEGIN */
set {IsNSDQ, count(market is NASDAQ, 1)}
set {IsNYSE, count(market is NYSE, 1)}
set {IsAMEX, count(market is AMEX, 1)}
set {tEOI, IsNSDQ + IsNYSE}
set {ExchangeOfInterest, tEOI + IsAMEX}

set {IsETF, count(stock type is ETF, 1)}
/* Exchange / ETF are identified - END */


/* My base filters - BEGIN */
/*
IsETF equals 0
*/

ExchangeOfInterest is above 0

do not draw IsETF
do not draw ExchangeOfInterest

do not draw VolFilt
/* My base filters - END */


add column separator
add column IsETF
add column IsNSDQ
add column IsNYSE
add column IsAMEX
add column separator
add column Sector
add column Industry
add column separator
add column close
add column separator


/* OHLC4 */
set {t001, open plus high}
set {t002, t001 plus low}
set {t003, t002 plus close}
set {OHLC4, t003 divided by 4.0}


/* Moving-VWAP 01 - Begin */
/* Reference date: 2024Q2 - On 20250314, 240 trading days have passed since the beginning of 2024Q2 (20240401) */
set {t101, sum(OHLC4 multiplied by volume, 240)}
set {t102, sum(volume, 240)}
set {AVWAP01, t101 / t102}

/* close vs AVWAP01 */
set {da01, close - AVWAP01}
set {dp01, da01 / AVWAP01}

add column AVWAP01
add column da01 {Diff01}
add column dp01 multiplied by 100.0 {Diff01%}
add column separator
/* Moving-VWAP 01 - End */


/* Moving-VWAP 02 - Begin */
/* Reference date: 2024Q3 - On 20250314, 177 trading days have passed since the beginning of 2024Q3 (20240701) */
set {t201, sum(OHLC4 multiplied by volume, 177)}
set {t202, sum(volume, 177)}
set {AVWAP02, t201 / t202}

/* close vs AVWAP02 */
set {da02, close - AVWAP02}
set {dp02, da02 / AVWAP02}

add column AVWAP02
add column da02 {Diff02}
add column dp02 multiplied by 100.0 {Diff02%}
add column separator
/* Moving-VWAP 02 - End */


/* Moving-VWAP 03 - Begin */
/* Reference date: 2024Q4 - On 20250314, 113 trading days have passed since the beginning of 2024Q4 (20241001) */
set {t301, sum(OHLC4 multiplied by volume, 113)}
set {t302, sum(volume, 113)}
set {AVWAP03, t301 / t302}

/* close vs AVWAP03 */
set {da03, close - AVWAP03}
set {dp03, da03 / AVWAP03}

add column AVWAP03
add column da03 {Diff03}
add column dp03 multiplied by 100.0 {Diff03%}
add column separator
/* Moving-VWAP 03 - End */


/* Moving-VWAP 04 - Begin */
/* Reference date: 2025Q1 - On 20250314, 49 trading days have passed since the beginning of 2025Q1 (20241001) */
set {t401, sum(OHLC4 multiplied by volume, 49)}
set {t402, sum(volume, 49)}
set {AVWAP04, t401 / t402}

/* close vs AVWAP04 */
set {da04, close - AVWAP04}
set {dp04, da04 / AVWAP04}

add column AVWAP04
add column da04 {Diff04}
add column dp04 multiplied by 100.0 {Diff04%}
add column separator
/* Moving-VWAP 04 - End */


/* Drawing the indicator on the price is only to display the indicator value on the last trading day */
/* Previous values are just the values of a Mobile-VWAP based on the 'period' defined by the number of bars used to evaluate the A-VWAP */
draw AVWAP01 on plot price
draw AVWAP02 on plot price
draw AVWAP03 on plot price
draw AVWAP04 on plot price


/* Example of 'Interesting Stocks' */
/* DiffNN% = (close - AVWAPNN)% lesser than a threshold */
/*
abs(dp01) is below 0.02
abs(dp02) is below 0.02
abs(dp03) is below 0.02
abs(dp04) is below 0.02
*/
]



Mactheriverrat
3,166 posts
msg #161709
Ignore Mactheriverrat
3/16/2025 10:49:37 PM

No.

nibor100
1,067 posts
msg #161714
Ignore nibor100
3/17/2025 8:34:30 PM

Apparently SFD was delisted from Nasdaq in 2013 when it was bought by a Chinese company, so it has been in business for years, and perhaps SF got some 2024 data from SFD financial reports. There are other dates in Jan 2025 for the first trading day on other sites.

If you want to save some columns you could add Add column market.

Ed S.

lorypanna
32 posts
msg #161724
Ignore lorypanna
modified
3/21/2025 2:48:22 AM

Hi @nibor100

Thanks for your suggestion.

FWIW, I used that 'logic' because from my tests the filter show stocks where market is not OTCBB (suggested in page SF-Help) doesn't seem to work, at least from my (maybe wrong) expectations. In the results I find a lot of OTCBB/Other items that I haven't found a way to filter out.

Thanks again for your always useful hints. Have a nice day. Cheers from Italy


Fetcher[
show stocks where market is not OTCBB
add column market
sort column 5 descending
]



StockFetcher Forums · Filter Exchange · A-VWAP [ Anchored VWAP ] - Only for the last bar; with important limitations<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.