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 |

Plotting Yesterday's OHLC Lines Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
jhilton
Posted : Friday, August 7, 2009 5:45:36 PM
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)?
Bruce_L
Posted : Monday, August 10, 2009 11:59:24 AM


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
db
Posted : Wednesday, January 5, 2011 11:11:45 AM
Platinum Customer 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
Bruce_L
Posted : Wednesday, January 5, 2011 11:30:27 AM


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
db
Posted : Wednesday, January 5, 2011 11:47:32 PM
Platinum Customer 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
Bruce_L
Posted : Thursday, January 6, 2011 8:55:05 AM


Worden Trainer

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

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