Scan for specified consecutive closes above or below VWAP


Category:
0
0

Hi Pete,

Is there a way to write a scan to see how many times a close X above/below the VWAP over X period? I would like custom inputs on both the aggregation and time frame. Ideally, I’d like to see the stats for 5 and 15 minutes.

Thank you!

Marked as spam
Posted by (Questions: 20, Answers: 27)
Asked on July 10, 2020 1:43 pm
125 views
0
Private answer

No, a scan cannot display values. A scan is only able to return a list of stocks meeting a specified criteria. So perhaps you left something out in your description. Because we already provided a solution for you that displays the number of bars above or below the VWAP.

https://www.hahn-tech.com/ans/column-to-show-number-of-bars-above-or-below-vwap/

If you wanted to scan for all stocks that had a count above or below a specified number. Well then that would be a scan. You can use that code from the previous solution and simply remove the last two lines and build your scan based on the data variable:

plot scan = data > 10;

If this is what you are requesting then let me know so I can fix the title of your question. A properly worded title to this question may have helped me understand your request more clearly.

Marked as spam
Posted by (Questions: 37, Answers: 4086)
Answered on July 10, 2020 3:16 pm
0
My bad Pete, I forgot that a scan can't do a value. I'm doing something wrong. I took out the last two lines and added plot scan = data > 10; but I received "Exactly one plot expected".
( at July 10, 2020 10:21 pm)
0
Sorry about that, plot data = if countBarsAbove > -countBarsBelow then countBarsAbove else countBarsBelow; needs to be changed to def data = if countBarsAbove > -countBarsBelow then countBarsAbove else countBarsBelow; then you can do those changes I described.
( at July 11, 2020 8:29 am)
0
Thanks again Pete! I also made a voluntary contribution for all your free help to not only myself but to everyone else.
( at July 11, 2020 11:16 am)
0
Thank you! Very much appreciated and very glad to know we got this working. I will update the title of the question so that folks searching for this will find it easy to locate.
( at July 11, 2020 1:45 pm)