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 |

Placing retracement labels based on the ZigZag indicator Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
miles3w
Posted : Sunday, February 21, 2010 7:40:10 PM
Registered User
Joined: 3/29/2007
Posts: 11
Hi,

I'm trying to create labels using RealCode that would place the calculated retracement value at the ZigZag indicator's inflection points

So for each ZigZag inflection point, I would be calculating the % retracement as follows:

100 * ZZ(i) / ( Abs ( zz(i+1) - zz(i+2))

I been playing with RealCode, but have been unable to get the label command to work.

Thanks for your help,

- Miles

Bruce_L
Posted : Monday, February 22, 2010 4:40:29 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I'm not sure I understand your % retracement calculations, but you might want to try replacing everything after the Inherits line in the Class tab of a RealCode Indicator with the following (the '# ZZP = indicator.ZigZagPercent line represents a Zig Zag Percent Indicator that has been Dragged and Dropped into the RealCode Editor):

    Sub New
        AutoLoop = False
        '# ZZP = indicator.ZigZagPercent
    End Sub
    Public Overrides Function Plot() As System.Single
        If ZZP.Line.Count >= 3 Then
            For i As Integer = 2 To ZZP.Line.Count - 1
                AddToOutput(ZZP.Line.DateValue(i), _
                    ZZP.Line.Value(i), 100 * ZZP.Line.Value(i) / _
                    System.Math.Abs(ZZP.Line.Value(i - 1) - ZZP.Line.Value(i - 2)))
            Next
        End If
    End Function
End Class

You'll need to Edit the Indicator and check Show Custom Labels if you want the Labels displayed on the Chart.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Wednesday, February 24, 2010 8:26:37 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
Bruce 

How can I get this to plot the % Gain/Loss from zig to zag?

I have no idea what the values that it returns now are.
Bruce_L
Posted : Thursday, February 25, 2010 8:59:15 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
    Sub New
        AutoLoop = False
        '# ZZP = indicator.ZigZagPercent
    End Sub
    Public Overrides Function Plot() As System.Single
        If ZZP.Line.Count >= 3 Then
            For i As Integer = 2 To ZZP.Line.Count - 1
                AddToOutput(ZZP.Line.DateValue(i), _
                    ZZP.Line.Value(i), 100 * (ZZP.Line.Value(i) / _
                    ZZP.Line.Value(i - 1) - 1))
            Next
        End If
    End Function
End Class

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
thnkbigr
Posted : Thursday, February 25, 2010 1:47:32 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207
This is great 

How can show only 2 decimals so I can make the chart cleaner.
Bruce_L
Posted : Thursday, February 25, 2010 1:56:05 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
    Sub New
        AutoLoop = False
        '# ZZP = indicator.ZigZagPercent
    End Sub
    Public Overrides Function Plot() As System.Single
        If ZZP.Line.Count >= 3 Then
            Dim Perc As Single
            For i As Integer = 2 To ZZP.Line.Count - 1
                Perc = 100 * (ZZP.Line.Value(i) / ZZP.Line.Value(i - 1) - 1)
                AddToOutput(ZZP.Line.DateValue(i), _
                    ZZP.Line.Value(i), Perc.ToString("0.00"))
            Next
        End If
    End Function
End Class

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