Volume with time frame


Category:
0
0

Hello

can you please help me with the script for watchlist. actually i am looking to scan the stock if the time in between 0930 to 1130 volume should me more than 1 million and after the time 1130 to 1600 volume should be more than 5 million.

Thanks

 

Marked as spam
Posted by (Questions: 12, Answers: 5)
Asked on March 19, 2021 3:56 pm
207 views
0
Private answer

The bulk of your request has already been provided previously in the form of a chart study:

https://www.hahn-tech.com/ans/volume-for-specific-time-frame/

We can take the code from that previous post and make two minor changes to make it work as a scan:

input volumeLimit = 1000000;
input startTime = 930;
input endTime = 1129;
def startCounter = SecondsFromTime(startTime);
def endCounter = SecondsTillTime(endTime);
def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else
if targetPeriod then volumeTotal[1] + volume else volumeTotal[1];
plot scan = volumeTotal > volumeLimit;

The endTime input is currently set for a 1 min time frame. If you apply this to another time frame you will need to adjust the endTime input so that is matches the time stamped on the last bar of the chart you want to include in the volume. Failing to make this adjustment will cause the code to fail.

This is all I have time to complete. In order to cover both time frames you will add a second Study Filter your scan, paste this very same code, and adjust the volumeLimit, startTime and endTime accordingly.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on March 19, 2021 7:27 pm
0
it come with error that exactly one plot expected
( at March 20, 2021 9:40 am)
0
Simple to fix that. I have corrected the code provided in my answer. You can copy/paste that again and it will work.
( at March 20, 2021 9:51 am)