Time limit premarket scanner


Category:
0
0

Hi Pete!

I’m a beginner with scripts and I’ve been following what you guys are doing here for a while. It’s amazing, really awesome ideas.

I’m trying to create a very basic scanner for premarket which includes a study and alerts when the condition is met, but I get some errors.

I want to scan for stocks between 1 and 7 making 20k or more volume in the 1-min bars. I want to catch volume spikes of that kind. All the volume alerts I see are related to percentage.

I’m getting hundreds of alerts all day long. It’s driving me crazy! I need the alerts to stop at 9:30, market open time.

So, I want to set:

  • A time limit for the alert.
  • A volume value equal or higher than 20K adding that as a stock filter study for that scan.
  • Later I will select “Alert me when results change” to get the alerts.

So, this is what I have tried:

——————-

def afterStart = SecondsFromTime(700) > 0;
def beforeEnd = SecondsTillTime(930) > 0;
def conditionTrue = volume >= 23000
plot alert = afterStart and beforeEnd and conditionTrue;
UNUSUALVOLUME() is greater than or equal to 23000

——————

Also trying, but apparently I’m not using the Unusual Volume condition in the right way because I get an error of invalid statement.

I also tried, with similar results:

—————-

input ORBegin = 700;
input OREnd = 930;
Def ORActive = if secondstilltime(OREnd)>0 AND secondstillTime(ORBegin)<=0 then 1 else 0;

——————

Thanks so much!

 

 

 

Attachments:
Marked as spam
Posted by (Questions: 6, Answers: 21)
Asked on February 10, 2020 12:01 pm
280 views
0
Private answer

Well there is no such study named UNUSUALVOLUME(). So that will not work at all. If this is a custom study you have created and saved, you cannot reference that in a Study Filter. You will need to use the actual code used in that custom study.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on February 10, 2020 3:51 pm
0
Private answer

Great, Pete! I am seeing the study now, here's the code:

 

# UNUSUALVOLUME

# DREWGRIFFITH15 (C) 2014

 

input price = volume;

input choice = {default increased, decreased};

input percent = 10;

input length = 50;

def avg = average(price, length)[1];

def chg = 100 * (price/avg -1);

plot scan;

 

switch (choice) {

case increased:

    scan = chg >= percent;

case decreased:

    scan = chg <= -percent;

}

 

But I see that this study is also using percentage. What should I do?

 

Thanks!

Marked as spam
Posted by (Questions: 6, Answers: 21)
Answered on February 10, 2020 4:14 pm
0
Hi Pete, This is an old question that I have been investigating. The unusual volume part is not that important to me. What I want to solve is the end time for a couple of scans I'm using. None of these formulas seems to work: 1) input startTime = 600; input endTime = 929; def startOfScan = SecondsFromTime(startTime) > 0; def endOfScan = SecondsTillTime(endTime) > 0; plot scanPeriod = startOfScan or endOfScan; 2) def finalization=929; def close1= if secondsfromTime(1200)>0 and secondsFromTime(1600)=close1*1.08 and close1>0; plot scan =condition1 and secondsFromTime(finalization) 0; def beforeEnd = SecondsTillTime(929) > 0; plot alert = afterStart and beforeEnd Any suggestion on what to do to scan from 6 am to 9:29 am (premarket time)? Thanks!
( at April 29, 2020 8:20 am)
0
I won't take the time to try and troubleshoot your code. Instead I will give you a link to a post that provides code you can run in a completely separate study filter. Placing the code from the solution I provided in the following post in a separate study filter will cause the entire scan to only run during the time you specify: https://www.hahn-tech.com/ans/scan-within-a-specific-hour-time-range/
( at April 29, 2020 9:51 am)
0
Thanks so much for your answer, Pete! I always search for possible solutions here before asking a question. Thing is I used that same code from that link and it is not working for me. It is the first example I posted above. So, this is what I used as a separate filter for my scan, and it didn't work. I keep receiving alerts all day long instead of only until 9:29 am. input startTime = 600; input endTime = 929; def startOfScan = SecondsFromTime(startTime) > 0; def endOfScan = SecondsTillTime(endTime) > 0; plot scanPeriod = startOfScan or endOfScan; Anything I'm doing wrong?
( at April 29, 2020 11:12 am)
0
Ok, I figured out what is going on and I have posted an update to my answer on that post. You need to modify the last line of code as follows: plot scanPeriod = startOfScan and endOfScan;
( at April 29, 2020 12:32 pm)
0
Amazing, Pete! That was a very fortunate "error", because I also wanted to use a similar scan for the after hours to premarket time. Thanks again!
( at April 29, 2020 12:59 pm)
0
So... Unfortunately this is not working either, Pete. I keep receiving the alerts all day long. Right now still getting them.
( at April 29, 2020 1:27 pm)