Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

New High Count from user defined date Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
BobM
Posted : Monday, July 25, 2011 7:54:15 PM
Registered User
Joined: 2/28/2005
Posts: 36

I would like some help creating an indicator that will count the number of new highs in a watch list between the most recent (current) date and a user specificed date in the past.   In other words, if the user defined date was January 1, the indicator would show the number of stocks in a list which now trade above their January 1, price.  Obviously, this would not work on any time frames less than daily.

Thanks,
Bob

Bruce_L
Posted : Tuesday, July 26, 2011 8:34:39 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I would not have guessed the second sentence from reading the first sentence, but am going to assume the second sentence is an accurate representation of your intent.

You could create the following RealCode Condition (note that I used 12/31/2010 instead of 1/1/2011 because 1/1/2011 is not a trading day):

Writing Conditions in RealCode

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Price above Date High
'|******************************************************************
'# HighDate = UserInput.Date = "12/31/2010"
'# Cumulative
Static Basis As Single
If isFirstBar Then
    Basis = Price.Bar.HighValue(Price.IndexForDate(HighDate))
End If
If Price.Last > Basis Then
    Pass
End If

And then right-click on it and select Create Market Indicator | (choose WatchList) | Next | Count Passing | Next | (adjust as desired) | Finish.

Market Indicators from Conditions
Custom Market Indicators

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
BobM
Posted : Tuesday, July 26, 2011 4:35:06 PM
Registered User
Joined: 2/28/2005
Posts: 36
Thanks!
Works like a charm.

Bob
Bruce_L
Posted : Tuesday, July 26, 2011 4:36:32 PM


Worden Trainer

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

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
BobM
Posted : Tuesday, July 26, 2011 6:31:02 PM
Registered User
Joined: 2/28/2005
Posts: 36

Bruce:  Fiddling with this indicator I changed "high" to "low" (see below) attempting to get and indicator that will show the count below its price as of a specified date.

*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Price below Date High
'|******************************************************************
'# HighDate = UserInput.Date = "12/31/2010"
'# Cumulative
Static Basis As Single
If isFirstBar Then
 Basis = Price.Bar.lowValue(Price.IndexForDate(HighDate))
End If
If Price.Last > Basis Then
 Pass
End If


It seems to work OK, (I think) but the high and low indicator don't add up to 100%.  I assume this is because it is looking at the high of one bar and the low of the other bar, on the two indicators.  I then tried to replace "high" with "close" to no avail: lots of error messages.

If I'm correct in my assumption, and if using the closing price would allow two indicators, one showing items above its close on a certain date and the other showing items below, to display two separate values equaling 100%, (for instance 22% above and 78% below - on the same date) would you please make that change to the formula.  I've looked at the RealCode reference book and am stumbling.

Thanks,
Bob

jas0501
Posted : Tuesday, July 26, 2011 8:46:24 PM
Registered User
Joined: 12/31/2005
Posts: 2,499
QUOTE (rmoosmann)

Bruce:  Fiddling with this indicator I changed "high" to "low" (see below) attempting to get and indicator that will show the count below its price as of a specified date.

*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Price below Date High
'|******************************************************************
'# HighDate = UserInput.Date = "12/31/2010"
'# Cumulative
Static Basis As Single
If isFirstBar Then
 Basis = Price.Bar.lowValue(Price.IndexForDate(HighDate))
End If
If Price.Last > Basis Then
 Pass
End If


It seems to work OK, (I think) but the high and low indicator don't add up to 100%.  I assume this is because it is looking at the high of one bar and the low of the other bar, on the two indicators.  I then tried to replace "high" with "close" to no avail: lots of error messages.

If I'm correct in my assumption, and if using the closing price would allow two indicators, one showing items above its close on a certain date and the other showing items below, to display two separate values equaling 100%, (for instance 22% above and 78% below - on the same date) would you please make that change to the formula.  I've looked at the RealCode reference book and am stumbling.

Thanks,
Bob


 I think you want 

If Price.last < Basis then

Note: you are getting pass values both before and after the date. You might want to include logic to see that the current bar date is greater than HighDate
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.