Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 2/1/2010 Posts: 7
|
What would the code be for a condition that requires the highest high of the last five days to be >= to the upper value of an envelop on THAT SAME DAY.
I've started with the code below, but that only compares todays envelop price with the last five days.
Thank you,
Janaka
'|*****************************************************************|
'|*** StockFinder RealCode Condition - Version 5.0 www.worden.com
'|*** Copy and paste this header and code into StockFinder *********
'|*** Condition:HH5 >= Upper Band and < 75% above Upper Band
'|*** Example: if price.percentChange > 1 then pass
'|******************************************************************
'# MA = chart.MovingAverage
'# ECTop = chart.EnvelopeChannels.0
'# ECBottom = chart.EnvelopeChannels.1
If price.MaxHigh(5) >= ECTop.value Then pass
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
If you want to compare each of the last five Bars to the Upper Envelope Channel then you need to do so explicitly.
'# ECTop = chart.EnvelopeChannels.0
Static Count As Integer
If isFirstBar Then Count = 0
If Price.High >= ECTop.Value Then
Count += 1
Else
Count = 0
End If
If Count >= 5 Then Pass
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/1/2010 Posts: 7
|
Thanks Bruce.
What I'm really trying to get is if during the last 5 days, the highest high of those last five days also was >= to the ECTop on that same day. Say I'm scanning on Wednesday night and the highest high of the last 5 days, including Wednesday, happend on Monday. I'm wanting to know if that high on Monday was >= the ECTop on Monday.
Thanks, Janaka
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Then you would probably want something more like the following:
'# ECTop = chart.EnvelopeChannels.0
Dim Test As Boolean = False
If CurrentIndex >= 5 Then
For i As Integer = 0 To 4
If Price.High(i) = Price.MaxHigh(5) AndAlso _
Price.High(i) >= ECTop.Value(i) Then
Test = True
Exit For
End If
Next
If Test = True Then
Pass
End If
Else
SetIndexInvalid
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/1/2010 Posts: 7
|
Thanks, Bruce. I appreciate your help.
Janaka
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 7/24/2010 Posts: 5
|
Bruce, I am trying to use this code. After cutting, pasting and applying it, I get an error I don't understand.
"Name ECTop not declared" in the "Price.High (i) >= ECTop.Value (i) Then" line
Can you give some assistance here? Thanks
Bill
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
wheysek,
The first line of the RealCode Condition:
'# ECTop = chart.EnvelopeChannels.0
Needs to be created by Dragging and Dropping the Envelope Channel from the Chart into the Code tab of the RealCode Editor.
Writing Conditions in RealCode
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |