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

Buy Morning Gap based on percentage Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
Designer
Posted : Sunday, November 7, 2010 8:30:32 PM
Registered User
Joined: 9/30/2006
Posts: 317
I need help creating a strategy for:

BUY If the stock gaps up at morning open at a selected percentage of previous day close.
Say I want to buy if morning gap is up between 0.25% and 1% of previous day close. (I would like to be able to change the percentages for backtesting.)

SELLSHORT If the stock gaps down at morning open at a selected percentage of previous day close.
Say I want to sellshort if morning gap is down between 0.25% and 1% of previous day close.

Thanks in advance.
Bruce_L
Posted : Monday, November 8, 2010 9:29:09 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
On a Daily Chart, you could use something like the following RealCode Condition for your Buy Condition:

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Gap on Open vs Prev Close
'|******************************************************************
'# Top = UserInput.Single = 1
'# Bottom = UserInput.single = 0.25
Dim PercDiff As Single = 100 * (Price.Open / Price.Last(1) - 1)
If isFirstBar Then
    SetIndexInvalid
Else If Bottom <= PercDiff AndAlso _
    PercDiff <= Top Then
    Pass
End If

If you are using an Intraday Bar Interval, you would need to check for the beginning of a new Trading Day.

'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Gap on Open vs Prev Close
'|******************************************************************
'# Top = UserInput.Single = 1
'# Bottom = UserInput.single = 0.25
Static Valid As Boolean
If isFirstBar Then
    Valid = False
    SetIndexInvalid
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
    Valid = True
    Dim PercDiff As Single = 100 * (Price.Open / Price.Last(1) - 1)
    If Bottom <= PercDiff AndAlso _
    PercDiff <= Top Then
        Pass
    End If
Else If Valid = False Then
    SetIndexInvalid   
End If

The SellShort Condition can be created by just editing the Top setting of the Condition to -0.25 and the Bottom setting of the Condition to -1.

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