Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Help with Creating Multiple Filters Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
vpi63
Posted : Friday, April 16, 2010 11:22:06 AM
Registered User
Joined: 3/15/2005
Posts: 33

I am trying to put together a scan of a universe of securities that consists of all stocks less ETFs that filters by the following criteria:

 

  1. 1)      Stock price must be less or equal to $X

  1. 2)      Stock price must have risen at least Y% over the last Z trading days

  1. 3)      I want to be able to plot the raw output of this filter over time

  1. 4)      I want to be able to normalize the raw output of this filter by dividing the raw output number by the number of stocks in the universe, which consist of my original scan (universe of securities that consists of all stocks less ETFs), and plot this as a  % over time.

 

Any help with putting this procedure and/or code together will be most appreciated.

 

Thanks and take care,

 

VPI63

Bruce_L
Posted : Friday, April 16, 2010 11:47:20 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Create the following RealCode Condition or Rule and then right-click on it to create a Percent Passing Market Indicator or Custom Index for the US Common Stocks WatchList.

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Multiple Filters
'|******************************************************************
'# MaxPrice = UserInput.Single = 100
'# MinPercRise = UserInput.Single = 10
'# Period = UserInput.Integer = 90
If Price.Last <= MaxPrice AndAlso _
    Price.Last / Price.Last(Period) >= 1 + MinPercRise / 100 Then Pass

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
vpi63
Posted : Friday, April 16, 2010 1:17:45 PM
Registered User
Joined: 3/15/2005
Posts: 33
Bruce,

Thanks for your prompt response.

I'm not at my PC, so I'll have to  wait until I get home to try this out.

In the meantime, please let me know if I have the interpretation of your code correct.

For this piece:

Price.Last / Price.Last(Period) >= 1 ?

It looks like that this code divides the last price by the price 90 days ago and sets it to GTE to 1.

So this ensures that the price is higher than 90 days ago.

So if ture, then:

MinPercRise / 100

sets the other criteria to ensure that the price is 10% or higher than 90 days ago, and both act as a logical AND?

{It looks like the code is evaluating "1(or greater)+10%" to me. Should "# MinPercRise = UserInput.Single = 10 " be "# MinPercRise = UserInput.Single >= 10" instead?}.

If both are true, then the code satisfies this condition:

2)      Stock price must have risen at least Y% over the last Z trading days

and the code counts the number that pass all criteria for a given day.

Is this correct?

If so, how do I get it to plot this raw # over time? Does it do so just by creating the indicator?

Finally, I'm not sure how I create the all stocks minus the ETFs universe of securies using the

"Custom Index for the US Common Stocks WatchList".

One last question, I see that this was created with version 5.0, and I have the latest version of 4.0, so is this code good to go with my version?

I'm sure if I was at my PC, I probably could answer most of this myself, but I won't be home to much later tonight, and with the weekend upon us, I'm not sure that I could get an aswer so quickly.

Again I thank you for time. 

Take care,

VPI63
Bruce_L
Posted : Friday, April 16, 2010 2:14:09 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (vpi63)
For this piece:

Price.Last / Price.Last(Period) >= 1 ?

It looks like that this code divides the last price by the price 90 days ago and sets it to GTE to 1.

So this ensures that the price is higher than 90 days ago.

So if ture, then:

MinPercRise / 100

sets the other criteria to ensure that the price is 10% or higher than 90 days ago, and both act as a logical AND?

Kind of, but no. It's just a single Boolean (True or False) expression where both sides of the >= get evaluated and then the comparison is made to see if it is True or not.

So Price.Last / Price.Last(Period) gets evaluated and 1 + MinPercRise / 100 gets evaluated. In the case where MinPercRise = 10, then 1 + MinPercRise / 100 = 1.1 and Price.Last / Price.Last(Period) needs to be greater than or equal to 1.1 for the expression to be True.

QUOTE (vpi63)
If both are true, then the code satisfies this condition:

2)      Stock price must have risen at least Y% over the last Z trading days

and the code counts the number that pass all criteria for a given day.

Is this correct?

The RealCode is just for Condition for a single stock. There isn't any counting built into the RealCode. It is just True or False.

QUOTE (vpi63)
If so, how do I get it to plot this raw # over time? Does it do so just by creating the indicator?

Finally, I'm not sure how I create the all stocks minus the ETFs universe of securies using the

"Custom Index for the US Common Stocks WatchList".

Yes, it is creating the Market Indicator or Custom Index that creates the count (or in this case, percentage).

When you right-click on the RealCode Rule or Condition after it is created, one of the options will be to Create Market Indicator or Create Custom Index.

The first page the comes up will allow you to choose the WatchList to use and the basis of the Market Indicator or Custom Index. The US Common Stocks WatchList is a built in System WatchList that already excludes ETFs, so you will choose this as the WatchList on this page.

The next page will let you choose what type of Custom Index or Market Indicator to create. You are going to choose Percent Passing.

QUOTE (vpi63)
One last question, I see that this was created with version 5.0, and I have the latest version of 4.0, so is this code good to go with my version?

The RealCode Condiiton was created in StockFinder 5, but it does not contain any SF5 specific syntax and should work as is in StockFinder 4.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
vpi63
Posted : Friday, April 16, 2010 3:48:03 PM
Registered User
Joined: 3/15/2005
Posts: 33
Bruce,

Thanks once again for a prompt response.

The following explanation of your code is confusing to me :

"In the case where MinPercRise = 10, then 1 + MinPercRise / 100 = 1.1 and Price.Last / Price.Last(Period) needs to be greater than or equal to 1.1 for the expression to be True."

If  "Price.Last / Price.Last(Period) >= 1" were tue, that is evauates to 1.1 or higher, why
would you need the 2nd expression :

"1 + MinPercRise / 100 " to satisfy the criteria:

2)      Stock price must have risen at least Y% over the last Z trading days

It seems to me like that:

"Price.Last / Price.Last(Period) >= 1"

says that,  if true, (1.1 or greater) the price today is 10% or greater than 90 days ago, which is what (2) above requires.


What is the value added of the 2nd piece of code:

"1 + MinPercRise / 100 "  ?

Obviously, I am missing something.

Thanks again for your help,

Take care,

VPI63
Bruce_L
Posted : Friday, April 16, 2010 3:59:15 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
QUOTE (vpi63)
If  "Price.Last / Price.Last(Period) >= 1" were tue, that is evauates to 1.1 or higher, why
would you need the 2nd expression :

"1 + MinPercRise / 100 " to satisfy the criteria:

There is no:

Price.Last / Price.Last(Period) >= 1

There is only:

Price.Last / Price.Last(Period) >= 1 + MinPercRise / 100

If you input 10 for MinPercentRise, then 1 + MinPercRise / 100 = 1.1. If 1 + MinPercRise / 100 = 1.1 then Price.Last / Price.Last(Period) must be at least 1.1 for the Rule to Pass. Price must have increased at least 10% for Price.Last / Price.Last(Period) to be at least 1.1.

If you input 20 for MinPercentRise, then 1 + MinPercRise / 100 = 1.2. If 1 + MinPercRise / 100 = 1.2 then Price.Last / Price.Last(Period) must be at least 1.2 for the Rule to Pass. Price must have increased at least 20% for Price.Last / Price.Last(Period) to be at least 1.2.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
vpi63
Posted : Friday, April 16, 2010 4:10:52 PM
Registered User
Joined: 3/15/2005
Posts: 33
Bruce,

Thanks one again for your prompt response and your patience.

I guess Friday is one of my dense days.

If I may reiterate my last question.

Why wouldn't :

"Price.Last / Price.Last(Period) >= 1" satisfy the criteria:

2)      Stock price must have risen at least Y% over the last Z trading days

if the % increase is 10%?

Thanks again for your help.

Take care,

VPI63


Bruce_L
Posted : Friday, April 16, 2010 4:13:40 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Because Price.Last / Price.Last(Period) = 1 when the Price Percent Change over the Period is 0%. Price.Last / Price.Last(Period) = 1.1 when the Price Percent Change over the Period is 10%.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
vpi63
Posted : Friday, April 16, 2010 4:35:44 PM
Registered User
Joined: 3/15/2005
Posts: 33
Bruce,

Thanks once again for your prompt response.

So I think I am on track, sorta of. :)

How is this 2nd expression:

" Price.Last / Price.Last(Period) >= 1 + MinPercRise / 100"

picking up stocks that have risen greater than 10%?

Thanks once again for your patience.

Take care,

VPI63
Bruce_L
Posted : Friday, April 16, 2010 5:00:17 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The computer evaluates both sides of the Boolean expression.

Price.Last / Price.Last(Period) gets evaluated based on the current Close and Close from Period Bars Ago.

1 + MinPercRise / 100 gets evaluated based on the UserInput for MinPercRise. If MinPercRise is 10, then 1 + MinPercRise / 100 = 1.1.

So if MinPercRise = 10, then what gets evaluated is:

Price.Last / Price.Last(Period) >= 1.1

If the UserInput for MinPercRise is changed to 20, then what gets evaluated is:

Price.Last / Price.Last(Period) >= 1.2

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
vpi63
Posted : Friday, April 16, 2010 5:12:47 PM
Registered User
Joined: 3/15/2005
Posts: 33
Bruce,

I think I have it.

Thanks so much for yoiur help.

Take care,

VPI63

Bruce_L
Posted : Friday, April 16, 2010 6:30:01 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
vpi63
Posted : Friday, April 16, 2010 11:46:48 PM
Registered User
Joined: 3/15/2005
Posts: 33
Bruce,

I tried your code by copying and pasting it in a real code rule and right clicked as directed.

I my stock universe was US Stocks.

Unfortunately I did not get a graph of either the raw data or the %>than X.

For my purposes, I used a 10% gain or higher, a look back of 10 days and a price <=10.

Although, I don't have the same universe in TC2000 (I have a universe of US stocks + ETFs), the number that I get for this scan in TC2000 for Friday, April 16, 2010, is 78.

So something is not right. I am not getting anything from this code.

Are you sure that the code is not filtering all stocks that do not meet a 10% gain exactly?  That might explain why I am not getting a number or a graph over time.

Thanks in advance for any help.

Take care,

VPI63

vpi63
Posted : Saturday, April 17, 2010 12:35:44 AM
Registered User
Joined: 3/15/2005
Posts: 33
Bruce,

Nevermind, I got it!

You are the man!!

Thanks and and take care,

VPI63
Bruce_L
Posted : Saturday, April 17, 2010 8:45:46 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I'm happy to read you were able to figure it out on your own.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.