| Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
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
|
|

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

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

 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
|
|
|
Guest-1 |