Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 2/26/2008 Posts: 10
|
Trainer,
I'm trying to create:
a Stop that is activated by a Close below the Low of the Daily Bar with the Highest Traded Price in the last 8 Days.
How can I do that????
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
If the last 8 days includes today, try using the following RealCode Condition as an Exit Rule in BackScanner:
'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 4.9 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Stop Variation
'|******************************************************************
If CurrentIndex >= 7 Then
Dim LowOfHigh As Single = Single.NaN
For i As Integer = 0 To 7
If Price.High(i) = Price.MaxHigh(8) Then
LowOfHigh = Price.Low(i)
Exit For
End If
Next
If Price.Last < LowOfHigh Then
Pass
End If
Else
SetIndexInvalid
End If
If the last 8 days ended yesterday, try using the following RealCode Condition instead:
'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 4.9 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Stop Variation
'|******************************************************************
If CurrentIndex >= 8 Then
Dim LowOfHigh As Single = Single.NaN
For i As Integer = 1 To 8
If Price.High(i) = Price.MaxHigh(8, 1) Then
LowOfHigh = Price.Low(i)
Exit For
End If
Next
If Price.Last < LowOfHigh Then
Pass
End If
Else
SetIndexInvalid
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/26/2008 Posts: 10
|
Bruce,
There must be an error in that Code, as there are no results showing up, even when you can manually "see" events that should trigger.
Could you recheck it for me???
Curtis
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I made a slight modification to both RealCode examples. Please try them again.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/26/2008 Posts: 10
|
OK, Bruce. THAT works.
That's the problem in RealCode, of course. Sticky little details.
Now is it possible to be able to "paint" the action as it is actually used, as a Stop? In other words, only showing the first instance of the circumstance?
If not, I understand, but it sure would make the charts cleaner and easier to read. This type Real Code technique, to limit repetiton of circumstance painting, that I would incorporate into all SF Rules.
Thanks for your efforts.
Curtis
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
How you eliminate "repetition" depends on what is meant by the term and the particular Rule (which can affect what is meant by "repetition").
In it's simplest definition, "repetition" would just eliminate the Rule from returning True more than one Bar in a Row. What is normally meant however is the first time something has occurred since something else.
In the case of say Price being above a Moving Average versus crossing up through a Moving Average, this is fairly simple. You are looking for the first time it is above the Moving Average since it was below the Moving Average.
Your example is more complicated however. As a Stop in a trade, it would be fairly simple in that you would be looking for the first time it is True since entering the position. But as a standalone Rule that is not aware of a trade, you are probably looking for the first time the Close was below the Low of the Highest Bar in the last eight days until there is another Highest Bar in the last eight days (although it could be since something else):
'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 4.9 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:Stop Variation
'|******************************************************************
If CurrentIndex >= 8 Then
Static Bar As Integer
Static First As Boolean
If isFirstBar Then
Bar = -1
First = False
End If
Dim LowOfHigh As Single = Single.NaN
For i As Integer = 0 To 7
If Price.High(i) = Price.MaxHigh(8) Then
LowOfHigh = Price.Low(i)
If Bar <> CurrentIndex - i Then
First = True
Bar = CurrentIndex - i
End If
Exit For
End If
Next
If First = True AndAlso _
Price.Last < LowOfHigh Then
Pass
First = False
End If
Else
SetIndexInvalid
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/26/2008 Posts: 10
|
Bruce,
That looks to do EXACTLY what I intended. THANKS!!
Curtis
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |