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 |

gaped trade Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
alexkhalil
Posted : Wednesday, July 16, 2008 7:14:27 PM
Registered User
Joined: 1/12/2008
Posts: 57
I am trying to find stocks that gap up or down by at least a point.
If they gap down then note the low of that day & if they gap up note the High of that day. Then I want to know the next day that low or high that we noted is traded again.

Let me give you an example (I hope this helps):

Stock DKS
On 5/22/08 it had a large gap down; with a low of 21.03
the stock continued to trade but did not touch that low till 6/19/08

I want to run my scan in blocks everyday but on 6/19 I would have wanted to see DKS lite up.

Thanks
Bruce_L
Posted : Thursday, July 17, 2008 9:38:59 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I'm not sure if the following RealCode Condition is what you want, but it does trigger for DKS on 6/19/08:

'#Cumulative
Static GapHigh As Single
Static GapLow As Single
If isFirstBar Then
    GapHigh = Single.NaN
    GapLow = Single.NaN
End If
If Price.High >= GapHigh Or Price.Low <= GapLow Then
    Pass
    If Price.High >= GapHigh Then GapHigh = Single.NaN
    If Price.Low <= GapLow Then GapLow = Single.NaN
End If
If Price.Low >= Price.High(1)+1 Then GapHigh = Price.High
If Price.High <= Price.Low(1)-1 Then GapLow = Price.Low

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
alexkhalil
Posted : Thursday, July 17, 2008 10:15:37 AM
Registered User
Joined: 1/12/2008
Posts: 57
Thanks!

Now if want to know the next time it actually closes above/below the noted gap price what changes would i need to make to the code?
Bruce_L
Posted : Thursday, July 17, 2008 12:54:33 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Could you please clarify your most recent request? It is not detailed enough for me to determine what you want.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
alexkhalil
Posted : Thursday, July 17, 2008 1:57:12 PM
Registered User
Joined: 1/12/2008
Posts: 57
Bruce,

you have it set to light up when it trades the low of the gap again, how can i change it to light up when it closes below the low of the gap?

Thanks
Bruce_L
Posted : Thursday, July 17, 2008 2:03:07 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I already have it setup so it lights up when the stock trades at or below the Low of the Gap Low Day or at or above the High of the Gap Up Day. If you don't want to include the possibility of equalities, change:

If Price.High >= GapHigh Or Price.Low <= GapLow Then
    Pass
    If Price.High >= GapHigh Then GapHigh = Single.NaN
    If Price.Low <= GapLow Then GapLow = Single.NaN

To:

If Price.High > GapHigh Or Price.Low < GapLow Then
    Pass
    If Price.High > GapHigh Then GapHigh = Single.NaN
    If Price.Low < GapLow Then GapLow = Single.NaN

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
alexkhalil
Posted : Thursday, July 17, 2008 3:08:21 PM
Registered User
Joined: 1/12/2008
Posts: 57
I know you  setup so it lights up when the stock trades at or below the Low of the Gap Low Day or at or above the High of the Gap Up Day

what I want is :  light up when the stock closes at or below the Low of the Gap Low Day or at or above the High of the Gap Up Day

thanks
Bruce_L
Posted : Thursday, July 17, 2008 3:10:25 PM


Worden Trainer

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

If Price.High >= GapHigh Or Price.Low <= GapLow Then
    Pass
    If Price.High >= GapHigh Then GapHigh = Single.NaN
    If Price.Low <= GapLow Then GapLow = Single.NaN

To:

If Price.Last >= GapHigh Or Price.Last <= GapLow Then
    Pass
    If Price.Last >= GapHigh Then GapHigh = Single.NaN
    If Price.Last <= GapLow Then GapLow = Single.NaN

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
alexkhalil
Posted : Thursday, July 17, 2008 3:54:23 PM
Registered User
Joined: 1/12/2008
Posts: 57
Thanks thats perfect.

One last thing, can I have a count that I can sort by how many days between Gap and the breaking of the gap?
Bruce_L
Posted : Friday, July 18, 2008 9:48:51 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Do you want it to be a running count that returns the number of days since the Gap while it is happening (and then drops back to zero or, probably better, a count that can't happen like negative one), do you want it to always return the number of days for the last Gap and fill or do you want it to return something else entirely.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
alexkhalil
Posted : Saturday, July 19, 2008 12:25:21 AM
Registered User
Joined: 1/12/2008
Posts: 57
I am looking for the number of bars between the GapHigh or GapLow and the day it passes it again which is the day that lights up. so in the DKS example above it would be 6/19/08 minus 5/22/08.

Thank you
jas0501
Posted : Saturday, July 19, 2008 3:05:54 AM
Registered User
Joined: 12/31/2005
Posts: 2,499

Below is a screen image of CMG. It is an interesting case as the gap lated 194 days before another gap occurred on 2/15/207. The condition indicator is a little different that your request. It is true from the first day until the day the price traget  is crossed. You can modifiy it for the close. The gap is a userinput and is set to 1.0

The indicator plots the day count and is -1 if no current gap. Following the screen image is the code for the indicator. Note the plot line can be replaced with the commented pass code at the botton to create the condition code.


'# gapSize = userinput.single = 1.00

static LowerLow as single
static HigherHi  as single
static daysSinceGap as single
static targetPriceTraded as boolean
Static wasUpGap As Boolean

Dim willPass As Boolean

If isFirstBar Then
 daysSinceGap = -1
 LowerLow = 0
 HigherHi  = 10000
 targetPriceTraded = False
 wasUpGap = false
end if

'
' check for existing gap
'
if daysSinceGap >= 0 then
 '
 ' unresolved gap price target
 '
 daysSinceGap += 1
 If wasupGap Then
  '
  ' was gap up, check for price traded
  '
  If price.high > higherHi And _
   price.Low < higherHi Then
   targetPriceTraded = True
   daysSinceGap = -1
   higherHi = 10000
  End If
 Else
  '
  ' was gap down, check for price traded
  '
  If price.low < lowerLow And _
   price.High > lowerLow Then
   targetPriceTraded = True
   daysSinceGap = -1
   lowerlow = 0
  End If
 End If
End If
'
' Note the target price could be traded
' and a new gap could be produced so check for gap
'
'----------
'
' set willPass as targetPricedTraded may get reset
'     during gap check
'
willPass = targetPriceTraded

If price.low > price.high(1) + gapsize Then
 '
 ' new gap up
 '
 wasUpGap = true
 HigherHi = price.high
 targetPriceTraded = false
 daysSinceGap = 0
ElseIf price.high < price.low(1) - gapsize Then
 '
 ' new gap down
 '
 wasUpGap = false
 lowerLow = price.low
 targetPriceTraded = false
 daysSinceGap = 0 
End If

'========================
' plot code
'========================

plot = daysSinceGap


'========================
' condition code, commented
'
' to create a condition indicator
' copy the code and paste into a condition edit window
' and remove the comment quote and the plot line above
'========================
'If willPass = True Then
' targetPriceTraded = False
' pass
'ElseIf daysSinceGap > -1 Then
' pass
'End If
'

 

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.