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

gap study continuation and breakaway Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
pianopilot
Posted : Monday, May 22, 2017 11:14:41 AM
Registered User
Joined: 5/27/2011
Posts: 45

Hi Bruce,

I am grateful for the help you gave me last week in gap fills. But as I continue my study of Gaps, I am finding that many stocks that gap up or down, measured from Close (1) to Open, do not "fill" the opening gap during the day, but Continue in the directio of the Gap. For example, Stock XYZ Closes yesterday at $10.00, but Opens today at $12.00. During this day Stock XYZ Never fills the gap by moving back down to $12.00 but continues up in price, and Closes the day with price Above $12.00. 

Stock XYZ may drop in price for a while, but Never fills the gap a any time.  I think this type gap is called a "Continuation Gap" or a "Breakaway Gap."

Can you code a condition for StockFinder the tracks stocks that "continue" in the direction of the gap AND Never fill that day, but close higher for Up Gaps, and lower for down gaps? Inputs would be size (%) and direction, for daily and intraday study.

Thanks,

Ed

 
 
Bruce_L
Posted : Monday, May 22, 2017 11:40:07 AM


Worden Trainer

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

Is the % the size of the initial gap (as we did in the last condition) or the minimum size of the condition before it returns true (or do we need % inputs)?



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
pianopilot
Posted : Monday, May 22, 2017 2:08:20 PM
Registered User
Joined: 5/27/2011
Posts: 45


At this time my concern is for the % input to be the size of the initial gap. (It seems like different Size Gaps have different behaviors, thus the input to compare.)

The condition should return True as long as today's close is Above today's Open if gapping up from Close (1); and vise versa, True as long as today's close is Below todays Open if gapping down from Close(1).

Thanks,

Ed

Bruce_L
Posted : Monday, May 22, 2017 2:53:59 PM


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:Continuation Gap
'|******************************************************************
'# Percent = UserInput.Single = 1
Static Filled As Boolean
Static Gapped As Boolean
Static FirstDay As Boolean
Static PrevClose As Single
Static TodayOpen As Single
If isFirstBar Then
	Filled = False
	Gapped = False
	FirstDay = False
	PrevClose = Single.NaN
	TodayOpen = Single.NaN
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
	Filled = False
	Gapped = False
	FirstDay = True
	PrevClose = Price.Last(1)
	TodayOpen = Price.Open
	If Percent > 0 Then
		If Price.Open >= (1 + Percent / 100) * PrevClose Then
			Gapped = True
		End If
	Else If Percent < 0 Then
		If Price.Open <= (1 + Percent / 100) * PrevClose Then
			Gapped = True
		End If
	End If
End If
If FirstDay = True Then
	If Gapped = True Then
		If Filled = False Then
			If Percent > 0 Then
				If Price.Low <= PrevClose Then
					Filled = True
				Else If Price.Last > TodayOpen Then
					Pass
				End If
			Else If Percent < 0 Then
				If Price.High >= PrevClose Then
					Filled = True
				Else If Price.Last < TodayOpen Then
					Pass
				End If
			End If
		End If
	End If
Else
	SetIndexInvalid
End If


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
pianopilot
Posted : Tuesday, May 23, 2017 1:02:25 AM
Registered User
Joined: 5/27/2011
Posts: 45

Hi Bruce,

Thanks for the code, it works great and will help in the study of gap behavior. In intra-day study it signals with each candle the meets the conditions. Of course, since StockFinder is quite limited in downloadable data, the daily backtesting is great.

Blessings,

Ed

Bruce_L
Posted : Tuesday, May 23, 2017 9:24:53 AM


Worden Trainer

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

You're welcome.



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