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

Consequtive Higher Closes Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
nimal
Posted : Thursday, January 3, 2013 1:33:21 PM
Registered User
Joined: 2/14/2006
Posts: 117

Can you please provide Real Codes for the following two scenerios.

1. 3 consequtive higher closes within a given number of bars

2. 3 Consequtiver higher closes within a given number of bars accompanied by consequtive higher volumes.

In both cases allow me to vary the Given number of bars (look Back Bars), no of qualifying candles ie 3 or 4 and the time period ie hourly, 30 mnts etc.

Thanks in advance

Bruce_L
Posted : Thursday, January 3, 2013 2:14:05 PM


Worden Trainer

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

The Time Frame is based on the Time Frame of the chart upon which the Condition is placed. You can manually change the Bar Interval of the Condition if it is used as a WatchList Column or Filter Condition that is not linked to the chart. A RealCode Condition that checks for 3 consecutive higher bars in a row ending 0 bars ago could be written as:

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Higher Closes
'|******************************************************************
'# Consecutive = UserInput.Integer = 3
'# Lookback = UserInput.Integer = 0
Static Since As Single
Static Count As Integer
Static Valid As Integer
If isFirstBar Then
	Since = Lookback
	Count = 0
	Valid = Consecutive + Lookback - 1
Else If Price.Last > Price.Last(1) Then
	Count += 1
Else
	Count = 0
End If
Since += 1
If Count >= Consecutive Then
	Since = 0
End If
If CurrentIndex >= Valid Then
	If Since <= Lookback Then
		Pass
	End If
Else
	SetIndexInvalid
End If

You just have to add a Volume.Value > Volume.Value(1) to the RealCode to test for increasing volume as well:

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Higher Closes and Volumes
'|******************************************************************
'# Consecutive = UserInput.Integer = 3
'# Lookback = UserInput.Integer = 0
Static Since As Single
Static Count As Integer
Static Valid As Integer
If isFirstBar Then
	Since = Lookback
	Count = 0
	Valid = Consecutive + Lookback - 1
Else If Price.Last > Price.Last(1) AndAlso _
	Volume.Value > Volume.Value(1) Then
	Count += 1
Else
	Count = 0
End If
Since += 1
If Count >= Consecutive Then
	Since = 0
End If
If CurrentIndex >= Valid Then
	If Since <= Lookback Then
		Pass
	End If
Else
	SetIndexInvalid
End If


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
nimal
Posted : Thursday, January 3, 2013 8:27:51 PM
Registered User
Joined: 2/14/2006
Posts: 117

Bruce,

Thanks for the code. My observation is that the 3 higher closes are always the last 3 bars of the day. I need to find 3 higher closes using 7 previous bars including the current bar on hourly chart and using 13 previous bars including the current bar on 30 Mnt chart. The 3 higher consequtive closes can be anywhere within the 7 bars or 13 bars.

Secondly, should I input lookback Integer depending on which chart the code is placed ie 7 if it is on hourly and 13 if it is on 30 mnt.

Thanks.

 

Bruce_L
Posted : Friday, January 4, 2013 8:22:05 AM


Worden Trainer

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

Your observation is only true if you leave lookback at zero as the lookback represents how recently the last of the consecutive bars must have happened. If you increase it to 1 for example, then those three bars could have ended on the current bar or the previous bar. If you increase the lookback to 7, those three bars could have ended on any of the most recent 8 bars.

The lookback is in bars, you can adjust however you want. If you want different lookbacks for differ bar intervals (time frames), then you would need to change the lookback depending on the bar interval of the chart.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
nimal
Posted : Friday, January 4, 2013 1:12:39 PM
Registered User
Joined: 2/14/2006
Posts: 117

Please take a look at symbol G. It has 3 higher closes, 2nd, 3rd and 4th candes on a 15 mnt chart. I have the real code on a 15 mnt chart and the look back set at 20. But the scan does not return symbol "G".

Thanks

 

Bruce_L
Posted : Friday, January 4, 2013 1:23:26 PM


Worden Trainer

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

With the Time Frame set to 15-Minutes, Consecutive set to 3 and Lookback set to 20, G has returned true continuously since 10:15 this morning when using the first RealCode Condition given in my Thursday, January 03, 2013 2:14:05 PM ET post. The second RealCode Condition from the same post has returned true continuously since 12:30 this afternoon in a 15-Minute Time Frame.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
nimal
Posted : Saturday, January 5, 2013 9:35:10 PM
Registered User
Joined: 2/14/2006
Posts: 117

Thanks Bruce, I figured it out and it is OK now. 

Bruce_L
Posted : Monday, January 7, 2013 8:05:05 AM


Worden Trainer

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

You're welcome. I am happy to read you were able to figure it out.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
nimal
Posted : Thursday, February 21, 2013 9:18:38 PM
Registered User
Joined: 2/14/2006
Posts: 117

Hi Bruce,

Old problem is back again. Take a look at HRB. It has 3 higher closes accompanied by higher volumes on hourly on 21st Feb 2013.

I have the code dated "January 3, 2013 2:14:05 PM" on an hourly chart but HRB is not returned.  I have a look back of zero and  consequtive 3 on my settings. What could be the reason.

Thanks

 

Bruce_L
Posted : Thursday, February 21, 2013 11:46:39 PM


Worden Trainer

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

The 2/21/2013 4:00 PM bar had a net change in price of $0.08 and a net change in volume of 243800 shares. That's one.

The 2/21/2013 3:00 PM bar had a net change in price of $0.15 and a net change in volume of 357300 shares. That's two.

The 2/21/2013 2:00 PM bar had a net change in price of $0.16 but the net change in volume was -100900 shares. So we only have two bars, not three.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
nimal
Posted : Sunday, March 10, 2013 2:05:03 PM
Registered User
Joined: 2/14/2006
Posts: 117

Hi Bruce,

Appreciate if you would modify the above code to reflect the following.

1. No lookback period but the consequtive # to stay.

2. Consequtive # to begin from the start of the trading and last till the end of the day's session.

3. Volume Surge/s also to be higher simultaneously with the higher close/s.

Thanks in advance.

 

Bruce_L
Posted : Monday, March 11, 2013 9:38:20 AM


Worden Trainer

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

If this is supposed to somehow be different than the current Higher Closes and Volumes Condition with the exception of removing the Lookback User Input or different than the same Condition with the Lookback User Input set to 0, then I was not able to discern the difference from your most recent post. So if it is supposed to be different, then I would need additional clarification from you as to your intent. Otherwise, please try the following RealCode Condition:

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Higher Closes and Volumes
'|******************************************************************
'# Consecutive = UserInput.Integer = 3
Static Count As Integer
If isFirstBar Then
	Count = 0
Else If Price.Last > Price.Last(1) AndAlso _
	Volume.Value > Volume.Value(1) Then
	Count += 1
Else
	Count = 0
End If
If CurrentIndex >= Consecutive Then
	If Count >= Consecutive Then
		Pass
	End If
Else
	SetIndexInvalid
End If


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
nimal
Posted : Monday, March 11, 2013 8:52:24 PM
Registered User
Joined: 2/14/2006
Posts: 117

Thanks for the reply. The problem with the code dated   January 3, 2013 2:14:05 PM  is this. If I set the look back to zero it looks at the current bar and 2 prior bars. That is if I want 3 consequtive higher closes.

If I set the look back as 7 on an hourly chart or any other time frame, the consequtive bars extend beyond the current date.  I want to avoid both these results eventhough I have been using this code now for sometime.

Reason why I want to use volume surge is this. I have been using volume surge in place of volume for sometime and I am kind of used to it. If I have any code which uses volume I will have to have both volume surge and volume on my chart because my other conditions use volume surge.

Actually, what I want is to find stocks which , during the current day, show consequtive higher closes accompanied by higher volume surges during any time of the day.

Please see what you can do.

 

Bruce_L
Posted : Tuesday, March 12, 2013 11:41:01 AM


Worden Trainer

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

Please try the following RealCode Condition:

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Higher Closes and Volume Surges
'|******************************************************************
'# VS = indicator.Library.Volume Surge
'# Consecutive = UserInput.Integer = 3
Static Count As Integer
Static Valid As Boolean
Static TrueForDay As Boolean
If isFirstBar Then
	Count = 0
	Valid = False
	TrueForDay = False
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
	Count = 0
	Valid = True
	TrueForDay = False
Else If Price.Last > Price.Last(1) AndAlso _
	VS.Value > VS.Value(1) Then
	Count += 1
Else
	Count = 0
End If
If Valid = True Then
	If Count >= Consecutive Then
		TrueForDay = True
	End If
	If TrueForDay = True Then
		Pass
	End If
Else
	SetIndexInvalid
End If

It should probably be noted that we do not offer a programming service. The solutions provided in the forums are intended to provide examples which can be used to learn how to use the software 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.