Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting yesterday prices

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Getting yesterday prices

    Currently I am using

    priorClosePrice = PriorDayOHLC().PriorClose[0];

    to get the yesterday last transaction price. However some instruments have their orices disseminated until 16:15. For theses cases I want to get yesterday transaction price at 16:00.
    How can I do this?

    #2
    Originally posted by dafonseca View Post
    Currently I am using

    priorClosePrice = PriorDayOHLC().PriorClose[0];

    to get the yesterday last transaction price. However some instruments have their orices disseminated until 16:15. For theses cases I want to get yesterday transaction price at 16:00.
    How can I do this?
    Code:
    double CloseAt1600 = Close[Bars.GetBar(Time[0].Date.AddDays(-1).Add(new TimeSpan(16, 0, 0)))];

    Comment


      #3
      when using your fornula I am getting the 16.00 price of the day before tomorrow.
      What is wrong?

      Comment


        #4
        Originally posted by dafonseca View Post
        when using your fornula I am getting the 16.00 price of the day before tomorrow.
        What is wrong?
        Sorry, I got confused again with the documented "Bars.GetBar()" and the undocumented "GetBar()"

        You can use either:
        Code:
        double CloseAt1600 = Close[CurrentBar - Bars.GetBar(Time[0].Date.AddDays(-1).Add(new TimeSpan(16, 0, 0)))];
        or else
        Code:
        double CloseAt1600 = Close[GetBar(Time[0].Date.AddDays(-1).Add(new TimeSpan(16, 0, 0)))];
        Remember that the second, seemingly more intuitive version is not documented, and, therefore, ipso facto unsupported.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        62 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        33 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        44 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        58 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        47 views
        0 likes
        Last Post CarlTrading  
        Working...
        X