• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get official open and close price?

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

    How to get official open and close price?

    I have a session template that shows me an hour before the market open and 30 minutes after the close (e.g. from 8:30am EST to 4:30pm EST). From within code how can I get the official exchange opening price at 9:30am EST and closing price at 4:00pm for stocks?
    Last edited by overflowing; 07-25-2012, 03:56 PM.

    #2
    overflowing, you can work with those OnMarketData event args - http://www.ninjatrader.com/support/h...aeventargs.htm

    You would need to store the data needed to variables and access those in your OnBarUpdate() then.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Does this work with historical data or is this only realtime? I need to know historical opens and closes.

      Comment


        #4
        This would be realtime going forward as offered directly from your provider. For historical data, you would need to use GetBar for example :

        http://www.ninjatrader.com/support/h...nt7/getbar.htm

        Or GetDayBar :

        http://www.ninjatrader.com/support/h.../getdaybar.htm
        BertrandNinjaTrader Customer Service

        Comment


          #5
          GetDayBar() docs say:

          This bar is a virtual bar built off of the underlying data series. In some cases, the trading day bar can be used to represent a daily bar. Since this bar is virtual, its property values are calculated based on session definitions contained in the trading day only. This does not necessarily represent the actual day.
          Does this mean that it will use my session template start and end times to determine the open and close price? If so then these values would be incorrect.

          I'm wondering if I should add an additional Day type dataseries and use that to get the open and close?

          Comment


            #6
            Sorry overflowing, you're correct - the GetDayBar() would not work for you, as it would be confined by the session template applied as well. Either add a daily series or use GetBar() to get the data at your desired open / close times for the sessions.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              With GetBar() I would be getting the open price at 9:30AM EST, however not all stocks open at precisely 9:30. So if I use this method then its possible I might get the price at 9:30AM but not the official opening price, correct?

              If I use a Day series will this give me the correct opening? I believe day data is handled differently from intraday data. Assuming this gives the exchange opening price it seems this would be the only way to get the correct opening price.

              Comment


                #8
                Correct, with GetBar() you would need additional checks if you have a late opening stock then.

                Besides using an added daily series, you can check into our pivots indicator - it loads Day bars asynchronously using non NinjaScript methods, check under it's custom methods implemented under the misc section in the code.
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by pjsmith, Today, 02:42 AM
                0 responses
                2 views
                0 likes
                Last Post pjsmith
                by pjsmith
                 
                Started by moyerchopra, Yesterday, 11:43 PM
                0 responses
                1 view
                0 likes
                Last Post moyerchopra  
                Started by ttodua, Yesterday, 11:40 PM
                0 responses
                2 views
                0 likes
                Last Post ttodua
                by ttodua
                 
                Started by edmata1109, 12-04-2019, 09:19 PM
                8 responses
                28 views
                0 likes
                Last Post koganam
                by koganam
                 
                Started by maindoor, 12-03-2019, 10:45 PM
                9 responses
                64 views
                0 likes
                Last Post koganam
                by koganam
                 
                Working...
                X