Scanning for price near VWAP

ssaeed73

Member
I am having trouble with setting up a scan to find stocks that are within 0.20$ of VWAP. I'm using the scan below with a 1min timeframe yet the stocks it returns have values sometimes more than 2$ from VWAP. Can someone help with this?

Code:
def vw=vwap;
plot diff =absvalue((close -vw)) < 0.20 within 2 bars;
 

ssaeed73

Member
No luck, it still pulls up stocks that are dollars away from VWAP and higher than VWAP even though your code says close should be less than VWAP. I'm using 1min on the scan and have after hours turned off.
 

rad14733

Moderator
Staff member
VIP
I played a bit more and came up with the following... This code insures that close is below VWAP and within 0.20... You should be able to get things the way you need between this code and that posted by @generic...

Ruby:
def vw = reference vwap();
plot diff = vw >= close and close > vw - 0.20 within 2 bars;
 

cabe1332

Active member
@ssaeed73 As an option, what I have is a column on my favorite (like Relative Volume) watchlist that provides me with the vwap value (colored). Very helpful to glance through before clicking a ticker or stock. The simple code below may also help you.

Code:
#Code

# Green vwap value means it is currently above the price.
# Red vwap value means it is currently below the price.

plot vw = reference vwap();
vw.AssignValueColor(if close > vw then Color.green else if close < vw then Color.red else Color.orANGE);

#end code

Good luck!
 

XeoNoX

Well-known member
VIP
Hi, Trying to create a scan that includes the condition that current price is within x% above OR Below VWAP. Any help is appreciated.

Price is within X% max of VWAP

Code:
#Price is within X% max of VWAP
# By XeoNoX via usethinkscript.com
#### Change percentvalue to decirect % in decimal format
###  Example .02 is 2%  and .025 is 2.5%
def percentvalue = .02;
def vw = reference vwap();
def s2 = vw*percentvalue;
plot scan = absvalue(close - vw) is less than or equal to s2;
 

KELTON98

New member
Price is within X% max of VWAP

Code:
#Price is within X% max of VWAP
# By XeoNoX via usethinkscript.com
#### Change percentvalue to decirect % in decimal format
###  Example .02 is 2%  and .025 is 2.5%
def percentvalue = .02;
def vw = reference vwap();
def s2 = vw*percentvalue;
plot scan = absvalue(close - vw) is less than or equal to s2;
for this to work properly what does the aggregation period need to be set to? I want to use this to scan for stocks with last price within x percent of vwap.
Thank you!
 

Similar threads

Top