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 |

Painting Bars to Reflect Change in Trend Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
itchn2trade
Posted : Thursday, December 10, 2009 10:22:36 PM
Registered User
Joined: 8/10/2008
Posts: 30
Hello - I would like to create rule where everytime a candle makes a 3 period High or Low the color of the candles change until a High or Low is made in the opposite direction at which time the candle colors would change.  For example, when a stock makes 3 period high all candles from that point forward will be filled in Green until such a time that a 3 period low is made and from that point forward all candles will be filled in Red until another 3 period high is made.  Please advise.  Thanks!
Bruce_L
Posted : Friday, December 11, 2009 9:09:56 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
It seems to me from your description that there would actually be four possible states.

1 - No 3-Period High or Low has yet occurred.
2 - The last 3-Period High or Low was a High.
3 - The last 3-Period High or Low was a Low.
4 - The last 3-Period High or Low was both a High and a Low.

The following RealCode Paint Scheme takes into account all four possibilities:

Static State As Color
If CurrentIndex >= 2 Then
    If Price.High >= Price.MaxHigh(2, 1) Then
        If Price.Low <= Price.MinLow(2, 1) Then
            State = Color.Yellow
        Else
            State = Color.Lime
        End If
    Else If Price.Low <= Price.MinLow(2, 1) Then
        State = Color.Red
    End If   
Else
    State = Color.White
End If
PlotColor = State

You can left-click on an Indicator to bring up its Edit window and select Edit (to the right of Paint Scheme) | Edit (to the right of Apply Realcode) to get to the Code tab of the RealCode Editor where the RealCode Paint Scheme would need to be Applied.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Matman
Posted : Thursday, January 14, 2010 8:36:15 PM
Registered User
Joined: 3/20/2005
Posts: 45
Bruce,

I'm trying to convert this code to a rule that gives me a true condition when one of the colors is true. If there are more than two bars of the same color in a row then it will not fire correctly. Here is the code I have so far for the yellow condition:

If CurrentIndex >= 2 Then
 If Price.High >= Price.MaxHigh(2, 1) AndAlso _
  Price.Low <= Price.MinLow(2, 1) Then
  Pass
 End If
End If

Any help would be appreciated.

Thanks,

Matman
Bruce_L
Posted : Wednesday, January 20, 2010 4:51:29 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
If you start with the original RealCode and store the State as a number instead of a Color, you can just check for the State:

Static State As Integer
If CurrentIndex >= 2 Then
    If Price.High >= Price.MaxHigh(2, 1) Then
        If Price.Low <= Price.MinLow(2, 1) Then
            State = 4
        Else
            State = 2
        End If
    Else If Price.Low <= Price.MinLow(2, 1) Then
        State = 3
    End If   
Else
    State = 1
End If
If State = 4 Then Pass

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Matman
Posted : Wednesday, January 20, 2010 7:54:08 PM
Registered User
Joined: 3/20/2005
Posts: 45
Bruce,

Works great, as usual. Thanks

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