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 |

Count the number of Intraday Highs Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Winnie
Posted : Wednesday, June 30, 2010 12:11:40 PM
Registered User
Joined: 10/7/2004
Posts: 1,006

How is the best way to write a RealCode Condition, to count the number of new intraday Highs in a 1 Minute Time Frame Chart?  

 

Then, how can these values be  added as a WatchList column?

 

Right click on the Condition; which option to choose?

Create WatchList Column

: Scan Column

: Last Date True

: % True in Period

: Bars Since True

: # True in a Row

 

Thanks

Winnie

StockGuy
Posted : Wednesday, June 30, 2010 12:14:26 PM

Administration

Joined: 9/30/2004
Posts: 9,187
New highs for what period of time?  Since the open of the current day?
Bruce_L
Posted : Wednesday, June 30, 2010 12:24:42 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Winnie,
Please try saving the following RealCode Indicator. You should then be able to Load it as WatchList Column and then Edit that WatchList Column to change the Bar Interval to 1-Minute.

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:New Intraday Highs
'|******************************************************************
Static Count As Single
Static DayHigh As Single
If isFirstBar Then
    Count = Single.NaN
    DayHigh = Single.NaN
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
    Count = 1
    DayHigh = Price.High
End If
If Price.High > DayHigh Then
    Count += 1
    DayHigh = Price.High
End If
Plot = Count

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Winnie
Posted : Wednesday, June 30, 2010 12:59:38 PM
Registered User
Joined: 10/7/2004
Posts: 1,006

Bruce, it works, something like going fishing, the line wiggles, there’s movement and maybe if your’e patient you will catch something.  Will be interesting to see the action tomorrow morning, going to the same fishing spot.

Enjoy.

 

Thanks Bruce,

Winnie

Winnie
Posted : Friday, July 29, 2011 10:31:58 AM
Registered User
Joined: 10/7/2004
Posts: 1,006
Is it possible to modify your RealCode Intraday Indicator New Intraday Highs to a New Intraday Highs Condition to include a UserInput for a minimum number of Highs to pass?
Userinput: Min Number Highs: 10

Thanks
Winnie
Bruce_L
Posted : Friday, July 29, 2011 10:39:12 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.1 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:New Intraday Highs
'|******************************************************************
'# MinNumberHighs = UserInput.Integer = 10
Static Count As Single
Static DayHigh As Single
If isFirstBar Then
    Count = Single.NaN
    DayHigh = Single.NaN
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
    Count = 1
    DayHigh = Price.High
End If
If Price.High > DayHigh Then
    Count += 1
    DayHigh = Price.High
End If
If Single.IsNaN(Count) = False Then
    If Count >= MinNumberHighs Then
        Pass
    End If
Else
    SetIndexInvalid
End If

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Winnie
Posted : Friday, July 29, 2011 10:55:42 AM
Registered User
Joined: 10/7/2004
Posts: 1,006
Bruce, as usual, you are absolutely the best Worden Trainer.
Thanks
Winnie 
FaDirt
Posted : Tuesday, December 11, 2012 2:23:36 PM
Registered User
Joined: 10/7/2004
Posts: 28

Bruce, 

When I tried to use the code you posted above I get the following error.

 

Name 'Pass' is not declared.

 

Don Foster

Bruce_L
Posted : Tuesday, December 11, 2012 2:25:55 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

It reads as if you are attempting to use code for a RealCode Condition as a RealCode Indicator. The Pass syntax is only valid as part of a RealCode Condition. Make sure you are creating a RealCode Condition when attempting to create the Condition.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
FaDirt
Posted : Tuesday, December 11, 2012 2:30:14 PM
Registered User
Joined: 10/7/2004
Posts: 28

QUOTE (Bruce_L)

It reads as if you are attempting to use code for a RealCode Condition as a RealCode Indicator. The Pass syntax is only valid as part of a RealCode Condition. Make sure you are creating a RealCode Condition when attempting to create the Condition.

 

Thanks Bruce. That was the problem.

FaDirt
Posted : Wednesday, December 12, 2012 2:27:18 PM
Registered User
Joined: 10/7/2004
Posts: 28

Bruce,

This New Intraday Highs indicator works great. I'm trying to figure out how to do something similiar by counting the number of closes above an 8 exponential moving average. Any thoughts on how to do this? 

Bruce_L
Posted : Wednesday, December 12, 2012 2:32:47 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

During the current day? Over some past specified number of bars? Something else?



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
FaDirt
Posted : Wednesday, December 12, 2012 2:47:38 PM
Registered User
Joined: 10/7/2004
Posts: 28

QUOTE (Bruce_L)

During the current day? Over some past specified number of bars? Something else?

 

I was trying to count the number of bars during the current day. Similiar to how your new intraday high condition counts. That way it can be used across different intraday timeframes.

Bruce_L
Posted : Wednesday, December 12, 2012 2:58:21 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

Please try the following RealCode Indicator:

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:New Intraday Highs
'|******************************************************************
'# Cumulative
Static Count As Single
If isFirstBar Then
	Count = Single.NaN
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
	Count = 0
End If
If Price.Last > Price.XAVGC(8) Then
	Count += 1
End If
Plot = Count


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
FaDirt
Posted : Thursday, December 13, 2012 8:33:35 AM
Registered User
Joined: 10/7/2004
Posts: 28

Bruce,

Your code worked perfect. Much appreciated!

FaDirt
Posted : Wednesday, March 20, 2013 11:41:03 AM
Registered User
Joined: 10/7/2004
Posts: 28

Hi Bruce,

Can this type of logic be done in TC2000 too or is it strictly limited to Stockfinder?

Bruce_L
Posted : Wednesday, March 20, 2013 11:49:53 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

It is not possible to create something similar to this in TC2000 as there is no way to determine the start of the day in an intraday Time Frame using the Personal Criteria Formula Language.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
FaDirt
Posted : Thursday, May 2, 2013 1:41:36 PM
Registered User
Joined: 10/7/2004
Posts: 28

Hi Bruce,

This code your wrote works great. Is there a way to count new highs ONLY after the first 60 minutes of trading? So new highs after 10:30 am? I'm not sure how to go about programming this. Any assistance would be greatly appreciated. Thanks.

|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:New Intraday Highs
'|******************************************************************
Static Count As Single
Static DayHigh As Single
If isFirstBar Then
    Count = Single.NaN
    DayHigh = Single.NaN
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
    Count = 1
    DayHigh = Price.High
End If
If Price.High > DayHigh Then
    Count += 1
    DayHigh = Price.High
End If
Plot = Count


 

 

Bruce_L
Posted : Thursday, May 2, 2013 1:56:06 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

Maybe something similar to the following?

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:New Intraday Highs
'|******************************************************************
Static Count As Single
Static DayHigh As Single
If isFirstBar Then
	Count = Single.NaN
	DayHigh = Single.NaN
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
	Count = 0
	DayHigh = Price.High
End If
If Price.High > DayHigh Then
	DayHigh = Price.High
	If Price.DateValue.TimeOfDay.Hours > 10.5 Then	
		Count += 1
	End If
End If
Plot = Count


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
FaDirt
Posted : Thursday, May 2, 2013 5:44:28 PM
Registered User
Joined: 10/7/2004
Posts: 28

Hi Bruce,

When I use this code I cannot validate the results. For example, today using a 5 min bar interval I get a count of 4 for MAN. The 11 am , 11:05am, and 11:10am are being counted but they shouldn't be since they are not new highs.  

Another example is PNC. Between 11 am and 11:40 am new highs are being counted but new highs are not being made.

Any thoughts on what is wrong?

Bruce_L
Posted : Friday, May 3, 2013 7:46:12 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

I have made some changes to the RealCode given in my Thursday, May 02, 2013 1:56:06 PM ET post. You may want to compare it to your existing RealCode instead of just copying and pasting it, so you can see what I did wrong the first time.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
FaDirt
Posted : Friday, May 3, 2013 11:22:41 AM
Registered User
Joined: 10/7/2004
Posts: 28

Sorry Bruce. I don't quite follow...I see the differences between the code but I don't see what you did wrong the first time. The code I currently use that you did the first time doesn't seem wrong since it accurately provides the results I'm looking for. The latest code with the TimeOfDay.Hours > 10.5  is the one that isn't providing the results I'm looking for. Sorry for any confusion. I'm trying to have two data columns in my watchlist. One that shows the number of new intraday highs for the entire day . And the other that shows the number of intraday highs strictly after 10:30 am. Again, I appreciate all your help! I'm an amateur with regard to programming the RealCode.

 

Don

 

Bruce_L
Posted : Friday, May 3, 2013 11:29:01 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

I made changes to the code in my Thursday, May 02, 2013 1:56:06 PM ET post. I meant for you to compare the code that you originally copied from the post to the code that is currently in that same post and hopefully see the differences and why what was there didn't work and what is there should work.

Keep in mind that these posts and the code provided are meant to be instructional and are for educational purposes only (which is why I'm hoping you can see and understand the change I made). We don't actually provide a programming service.

That said, understanding the change isn't a requirement of using the RealCode in the post. You should be able to just copy and paste it into StockFinder to try out the changes.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
FaDirt
Posted : Friday, May 3, 2013 1:33:04 PM
Registered User
Joined: 10/7/2004
Posts: 28

I was able to get my results using the following code:

 

 

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:New Intraday Highs AFTER 10:30 am
'|******************************************************************
Static Count As Single
Static DayHigh As Single
If isFirstBar Then
Count = Single.NaN
DayHigh = Single.NaN
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
Count = 0
DayHigh = Price.High
End If
If Price.High > DayHigh Then
DayHigh = Price.High
If Price.DateValue.TimeOfDay > Date.Parse("10:30").TimeOfDay Then
Count += 1
End If
End If
Plot = Count
 
Not sure why the Date.Parse code worked better for me but I'll take it. Thanks for assisting me Bruce.
 
Bruce_L
Posted : Friday, May 3, 2013 1:36:05 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

I am happy to read you were able to figure out something that met your needs.



-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.