♥ 0 |
Hi Pete, I am looking for a scanner to produce results where the VWAP is declining and is down by a percentage which is set by a defined input with the value of say 2%. I thought this would work but it’s producing undesired results.
Please know I am using this in a 5 minute aggregation period. Thank you
Marked as spam
|
Private answer
There is a massive difference between the fundamental data type named "vwap" https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Fundamentals/vwap and the built-in chart study named "VWAP" https://toslc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/V-Z/VWAP So if you are building your scan using the fundamental data type of "vwap" while plotting the built-in chart study named "VWAP" on your chart. Well you will never get results from the scan that match what you see on the chart. If that is the case then you need to at least reference the built-in chart study named VWAP in your code. You do this in the following manner:
Marked as spam
|
Please log in to post questions.
def lowerVWAPByPercent = vwap/vwap[length] -1 < 1-percent
This line will compute a 2% value as 0.02 and not as 2.0. So the input named "percent" would then need to be converted the decimal equivalent in order to get this to work the way you expect. The way we do this is to multiply the percent input by 0.01 to move the decimal point two places to the left. So that the input value of 2.0 becomes 0.02. So you would modify that line as follows:
def lowerVWAPByPercent = vwap / vwap[length] -1 < 1 - percent * 0.01;