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