Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 9/30/2006 Posts: 317
|
I would like help creating a condition/filter:
Stocks that are today above previous day high or stocks that are today below previous day low.
I would like to be able to use it as a condition in my strategies.
Thanks in advance
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I guess that would depend in if you mean currently outside the range of the previous day:
If Price.Last > Price.High(1) OrElse Price.Last < Price.Low(1) Then Pass
Or outside the range of the previous day at any time during the current day:
If Price.High > Price.High(1) OrElse Price.Low < Price.Low(1) Then Pass
Or entirely outside the range of the previous day for the entire current day:
If Price.Low > Price.High(1) OrElse Price.High < Price.Low(1) Then Pass
Or something else entirely.
Writing Conditions in RealCode
Creating Conditions
Scanning with Conditions
Filtering List
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 9/30/2006 Posts: 317
|
This is the correct one I'm looking for.
If Price.Last > Price.High(1) OrElse Price.Last < Price.Low(1) Then Pass
I tried that condition but seems to work only on daily charts. How do I modify it so it works with minute charts during the session. Say for instance I have a 10 minute chart and want to enter the market as soon as the price crosses above the previous day high or as soon as current price crosses below the low of the previous day. As soon as either condition above mentioned is met I want to begin my strategy.
Hope it makes sense.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
That would be a bit more complicated:
'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Outside Previous Range
'|******************************************************************
Static High(1) As Single
Static Low(1) As Single
Static Days As Integer
If isFirstBar Then
High(0) = Single.NaN
High(1) = Single.NaN
Low(0) = Single.NaN
Low(1) = Single.NaN
Days = 0
Else If Price.DateValue.DayOfYear <> Price.DateValue(1).DayOfYear Then
High(1) = High(0)
High(0) = Price.High
Low(1) = Low(0)
Low(0) = Price.Low
Days += 1
End If
High(0) = System.Math.Max(High(0), Price.High)
Low(0) = System.Math.Min(Low(0), Price.Low)
If Days >= 2 Then
If Price.Last > High(1) OrElse _
Price.Last < Low(1) Then
Pass
End If
Else
SetIndexInvalid
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 9/30/2006 Posts: 317
|
Bruce,
Thanks a lot that works great... please update the code so it shows stocks that are today below previous day low as well.
right now it is only showing me when price is above previous day hi.
Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I'm getting stocks below the previous day low when I run it. You may wish to try recopying the RealCode.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 9/30/2006 Posts: 317
|
I did but still it won't, not sure why. Could you please share the workspace. Thanks
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You should be able to Save the attached Layout to the \My Documents\StockFinder 5\(Your Username)\My Layouts\ folder and then Load it into StockFinder 5 by selecting File | Open Layout Attachments: Outside Previous Range.sfLayout - 41 KB, downloaded 694 time(s).
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 9/30/2006 Posts: 317
|
Thank you
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |