I read through your request a few times and still end up with two different ways to interpret your request. I believe you asking for one of these two:
- For each trading session, display the number of bars since the first 1 minute bar recorded volume greater than 1,000
- For each trading session, display the exact bar number at which the first 1 minute bar recorded volume greater than 1,000
Let me know which one it is. Or if you actually need something entirely different.
Since you are requesting a custom watchlist column and not a scan I have moved this out of the "Stock Scanners" topic and into the "Watch List" topic.
Edit: I can provide a solution now that we have clarification on this request in the comments section below.
The code will need to be run on a custom column that does NOT included extended trading hours. However it will also work if you included extended hours but it will begin the bar count after midnight Eastern.
input volumeThreshold = 1000;
def newDay = GetDay() <> GetDay()[1];
rec trackHighestVolume = if newDay then volume else if trackHighestVolume[1] < volumeThreshold and volume > trackHighestVolume[1] then volume else trackHighestVolume[1];
rec countBars = if newDay then 1 else if trackHighestVolume < volumeThreshold then countBars[1] + 1 else countBars[1];
plot data = if trackHighestVolume > volumeThreshold then countBars else 0;
data.AssignValueColor(if data <> 0 then Color.BLACK else Color.CURRENT);
AssignBackgroundColor(if data > 0 then Color.GRAY else Color.CURRENT);