Scan for specified volume twice within 10 bars


Category:
0
0

Hey Pete,

I’m trying to figure out the code that would pull a stock when X volume occurs twice within 10 bars. So for example, stock ABC is pulled when its volume spikes above 10,000 on two separate bars but within 10 bars of each other. I appreciate any help you can give on this!

Sincerely,

CW

Marked as spam
Posted by (Questions: 2, Answers: 2)
Asked on August 16, 2020 5:51 pm
68 views
0
Private answer

Very important to consider that a fixed value for the volume threshold is going to have an extremely narrow focus and zero flexibility. Much better to apply it as a percent threshold above an average volume. Why? Stocks with very high volume are going to exceed your fixed value for the volume threshold every single bar during the trading session. Whereas extremely low volume stocks will never exceed your fixed value for volume threshold at all.

When constructing scans it's always best to design the specifications so the resulting solution has the widest possible utility and flexibility. Which ends up being the most robust solution. Since you did not do this, the solution below is configured to match your extremely fragile and very narrow specifications.

The following code includes three user inputs so you can adjust the various metrics without modifying the code.

input volumeThreshold = 10000;
input numberOfBars = 10;
input numberOfInstances = 2;
def volumeCondition = volume > volumeThreshold;
plot scan = Sum(volumeCondition, numberOfBars) >= numberOfInstances;

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on August 16, 2020 6:11 pm