Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 7/28/2006 Posts: 36
|
Price History allows SF users to plot yesterday's close line. Is there any way for users to plot yesterday's open, high, and low lines using Real Code (or any other SF facility)?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You could Plot a line extending from yesterday's Open by replacing everything after the Inherits line in the Class tab of a RealCode Indicator with the following:
Sub New
AutoLoop = False
End Sub
Public Overrides Function Plot() As System.Single
Dim Start As Integer = Price.Bar.Count - 1
Dim Open As Single
While Price.Bar.DateValue(Start).DayOfYear = _
Price.Bar.DateValue(Start - 1).DayOfYear _
AndAlso Start > 0
Start -= 1
End While
Start -= 1
While Price.Bar.DateValue(Start).DayOfYear = _
Price.Bar.DateValue(Start - 1).DayOfYear _
AndAlso Start > 0
Start -= 1
End While
Open = Price.Bar.OpenValue(Start)
If Start > 0 Then
For i As Integer = Start To Price.Bar.Count - 1
AddToOutput(Price.Bar.DateValue(i), Open)
Next
End If
End Function
End Class
You could Plot a line extending from yesterday's High by replacing everything after the Inherits line in the Class tab of a RealCode Indicator with the following:
Sub New
AutoLoop = False
End Sub
Public Overrides Function Plot() As System.Single
Dim Start(1) As Integer
Start(0) = Price.Bar.Count - 1
Dim High As Single
While Price.Bar.DateValue(Start(0)).DayOfYear = _
Price.Bar.DateValue(Start(0) - 1).DayOfYear _
AndAlso Start(0) > 0
Start(0) -= 1
End While
Start(0) -= 1
Start(1) = Start(0)
High = Price.Bar.HighValue(Start(0))
While Price.Bar.DateValue(Start(0)).DayOfYear = _
Price.Bar.DateValue(Start(0) - 1).DayOfYear _
AndAlso Start(0) > 0
If Price.Bar.HighValue(Start(0)) >= High Then
Start(1) = Start(0)
High = Price.Bar.HighValue(Start(0))
End If
Start(0) -= 1
End While
If Price.Bar.HighValue(Start(0)) >= High Then
Start(1) = Start(0)
High = Price.Bar.HighValue(Start(0))
End If
If Start(0) > 0 Then
For i As Integer = Start(1) To Price.Bar.Count - 1
AddToOutput(Price.Bar.DateValue(i), High)
Next
End If
End Function
End Class
You could Plot a line extending from yesterday's Low by replacing everything after the Inherits line in the Class tab of a RealCode Indicator with the following:
Sub New
AutoLoop = False
End Sub
Public Overrides Function Plot() As System.Single
Dim Start(1) As Integer
Start(0) = Price.Bar.Count - 1
Dim Low As Single
While Price.Bar.DateValue(Start(0)).DayOfYear = _
Price.Bar.DateValue(Start(0) - 1).DayOfYear _
AndAlso Start(0) > 0
Start(0) -= 1
End While
Start(0) -= 1
Start(1) = Start(0)
Low = Price.Bar.LowValue(Start(0))
While Price.Bar.DateValue(Start(0)).DayOfYear = _
Price.Bar.DateValue(Start(0) - 1).DayOfYear _
AndAlso Start(0) > 0
If Price.Bar.LowValue(Start(0)) <= Low Then
Start(1) = Start(0)
Low = Price.Bar.LowValue(Start(0))
End If
Start(0) -= 1
End While
If Price.Bar.LowValue(Start(0)) <= Low Then
Start(1) = Start(0)
Low = Price.Bar.LowValue(Start(0))
End If
If Start(0) > 0 Then
For i As Integer = Start(1) To Price.Bar.Count - 1
AddToOutput(Price.Bar.DateValue(i), Low)
Next
End If
End Function
End Class
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 1/30/2005 Posts: 25
|
Hi Bruce,
These are great formulas, but if the high of yesterday is the opening bar and the next one is the next highest high the line/marker is put on the second bar. I have tried to modify the code, but not good enough to correct it. A example chart to look at is the SPY on Jan 4, 11 where the first bar is the high of yesterday (today is the 5th), but marker is on the second bar. Thanks ahead of time for the help. Darrell
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
I added an additional check for the High or Low after the second While loop. This is more consistent with the way the RealCode works for the Open.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Platinum Customer
Joined: 1/30/2005 Posts: 25
|
Thank you Bruce. You guys are great at helping us and I really do appriciate your pride in the quality of work you do.
Darrell
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
You're welcome.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |