Gap up open and gap down open scan
Author: jen28
Creation Date: 4/6/2010 10:36 AM
profile picture

jen28

#1
Hello,

I am a newbie using wealth-lab script. I want to create a scan that will run at the market open to see if the current price is 0.5% above the prior day's close or 0.5% below the prior day's close. I set the scale to be 1min for the data set and run 20 bars, as I intend to run within 1-2 minutes after the market open at 9:30am. I tested to run the Nasdaq 100 data set ( after change it to be 1min as the data setting), and got the error: "Error (7), thread was been aborted"

Here is my code.

CODE:
Please log in to see this code.


Thanks in advance for your help!!
Jen
profile picture

Cone

#2
In a streaming chart that is initialized (by changing scales, pressing Go, F5, etc.) very close to the end of an interval, this error can be expected to occur by design. The problem is that the script is running when a new bar becomes available. If it happens, just let the script run and it will pick up processing on the next bar.

If we're not talking Streaming, then please specify the conditions.
profile picture

jen28

#3
Thanks!

1. I run this after market open today using Fidelity's streaming data. So does it consider as streaming chart?

2. If that is the case, how to avoid this error and get some scan result? Should I run it against a longer time frame chart, 2min or 5 min?

3. This is my first time doing the wealth-lab coding? Can you tell if my code is ok?

4. Most important, is there any ready made scan that will scan for market gap up or gap down open?

Many thanks!
Jen
profile picture

Cone

#4
QUOTE:
I run this after market open today using Fidelity's streaming data. So does it consider as streaming chart?
You'd know if it were a Streaming Strategy window, because you have to click the Streaming button for that.

So, you're either running this with on-demand static data over the Naz 100 DataSet in a Strategy Window, or you're using the Strategy Monitor tool (the best choice since on-demand updates will occur 10x faster). In either of these cases, I'm not familiar with that error.

As for the script, the p1 assignment isn't robust at all. Instead, you should be using iDay.Close[bar] (the synchronized Daily Bars) to get yesterday's Closing value. (Of course there are many other ways to get that value, but we'll stick with what you've got.) Also, you assigned the same ROC.Series to two different variables, why?

Here's a little cleanup with some shortcuts for your boolean assignments -

CODE:
Please log in to see this code.


profile picture

jen28

#5
Thank you so much! I run this in the Strategy Monitor, so it is on-demand update then. I will test out tomorrow morning at the open.

Many thanks and have a good night!
Jen
profile picture

jen28

#6
I tried this morning with my old program. Still get the same error "Error (7), thread was been aborted", and got SYMC in the alert after running (which is not correct result).

I then tried this morning with your updated program. Still get the same error "Error (7), thread was been aborted", and get no symbol in the alert after running. I ran against Nasdaq100 both with 1 min and 5 min data setting in the strategy monitor window.

I think to scan for gap open, we need to compare today's open with yesterdays' close. Do you know how to get today's open price in the code and can run this program at the market open?

Thanks!
Jen

profile picture

Cone

#7
I didn't really do anything that would have any effect on the outcome of the Strategy - just a little cleanup.

Anyway, I can duplicate this, so let me try to figure out what's going on.
profile picture

Cone

#8
Man, what a bird brain I am today. I named the Strategy "Error(7) Thread Aborted", got distracted doing other things, and when I looked back at the title, I thought I had duplicated the error.

So, I still don't see the problem (yet). Meanwhile, what are the first 10 symbols in your Nasdaq 100 DataSet?
profile picture

Cone

#9
One thing I'm noticing is that there's no way the S. Monitor can keep up with updating 100 symbols every minute. The User Guide has some dialog about this in the last section of the S. Monitor chapter.

QUOTE:
Do you know how to get today's open price in the code and can run this program at the market open?
Strategies only run on complete bars, so it's not really possible to run a strategy just after the open with the opening prices alone (but there's always a way). Also, just think about the NYSE with staggered openings - you often must wait a minute or two after 9:30 for a handful of stocks.

We've requested Fidelity to provide a method to obtain the opening prices in a timely manner to run Strategies, but it's not on the horizon. Without another external method (like grabbing the quote from another source right after 09:30), the best you can do is wait for the end of the 1-minute bar to access the open.

QUOTE:
I think to scan for gap open, we need to compare today's open with yesterdays' close.
Knowing that you have to wait for the end of whatever interval you're using, here's something to play with -

CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).