Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Code for highest high of last 5 days intersecting with event corresponding to that day. Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
janaka
Posted : Wednesday, August 18, 2010 1:09:55 PM
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
   
Bruce_L
Posted : Wednesday, August 18, 2010 1:39:37 PM


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
janaka
Posted : Wednesday, August 18, 2010 5:57:24 PM
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
Bruce_L
Posted : Thursday, August 19, 2010 9:14:40 AM


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
janaka
Posted : Friday, August 20, 2010 3:04:52 PM
Registered User
Joined: 2/1/2010
Posts: 7
Thanks, Bruce. I appreciate your help.
Janaka
Bruce_L
Posted : Friday, August 20, 2010 3:05:47 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
You're welcome.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
wheysek
Posted : Saturday, September 25, 2010 11:55:20 AM
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
Bruce_L
Posted : Monday, September 27, 2010 9:02:32 AM


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