Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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, 04: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 :



        Or GetDayBar :

        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 Waxavi, Today, 02:00 AM
                0 responses
                2 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Started by elirion, Today, 01:36 AM
                0 responses
                4 views
                0 likes
                Last Post elirion
                by elirion
                 
                Started by gentlebenthebear, Today, 01:30 AM
                0 responses
                4 views
                0 likes
                Last Post gentlebenthebear  
                Started by samish18, Yesterday, 08:31 AM
                2 responses
                9 views
                0 likes
                Last Post elirion
                by elirion
                 
                Started by Mestor, 03-10-2023, 01:50 AM
                16 responses
                391 views
                0 likes
                Last Post z.franck  
                Working...
                X