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 "real" previous day close value?

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

    How to get "real" previous day close value?

    Hello,

    Can someone tell me how to get the value of a previous day close value? My data provide is Interactive Brokers. In their TWS you can add a column "close" which shows "real" close day value of a previous day from which a day limit for a market is calculated. Is there a way to get it?

    Thanks in advance.......

    #2
    Hello,

    Thanks for your forum post.

    There are a couple ways to get this. To find out what works best for you. Which time frame chart are you going to be running this indicator on?

    I look forward to assisting you further.

    Comment


      #3
      Hello,

      I'm going to use 1 minute time frame.
      Thank you for reply.

      Comment


        #4
        Hello,

        The best way to do this is use the indicator that is build for this.

        PriorDayOHLC() indicator.



        PriorDayOHLC().PriorClose[0];

        This will do the trick for you.

        Let me know if I can be of further assistance.

        Comment


          #5
          Thank you very much for a tip. Unfortunately this method does not return expected value. It returns the value which is shown on a day bar chart as a close value but it is not the "real settlement" value from which the price limit for the next day is calculated. For example on 3th of April on ZC market real close day value was 736 and this method returns 732,5 which the value shown on a chart.
          Thanks again for help.
          Filip

          Comment


            #6
            Hello,

            No problem.

            It will always return the value on the chart Unfortunately as this is what your data feed provider provides the close price of the day. There would be no function in NinjaTrader to get settlement price instead.

            Let me know if I can be of further assistance.

            Comment


              #7
              PriorDayOHLC will give you the last close of the previous day for an intraday series (and I think if your session times aren't set properly it will include after hours trades).

              I'm not sure how ZC is handled, but I think for most instruments the "official" close is reported in the daily quote. So if you want to reference it you could add a Daily data series for the same instrument, and reference the Close of that series.

              Comment


                #8
                I actually don't understand why close value is different than settlement value. It is certainly not because of wrong session time in NT because it is in TWS different too. I believe it is something about how exchange handles closure of a market. I don't know the details of this process. As you mentioned I have tried to access Daily data series by GetDayBar() method but it returns the same incorrect value.
                Recently I suffered a big loss because market hit a daily price limit and was closed. I did not know I'm near to the limit and next day it opened with a gap. That is why I try to find how to write this indicator which will guarantee this will not happen again. TWS has this value available so it is pity there is probably no way to get it from there.

                Filip

                Comment


                  #9
                  The exchanges have a procedure for calculating the "official" close to make sure it's representative of the true price at that time, and not spiked in one direction or the other by a single trade. CME uses a volume-weighted average of all trades occurring during a specified period before the close (frequently the last 30 seconds):

                  http://www.cmegroup.com/market-data/...Procedures.pdf

                  But Corn is one of the exceptions: "The lead contract month in Corn, Soybean, Meal, Oil, and Oat futures is settled at the price at which the Pit Committee, in consultation with Exchange staff determines traded the preponderance of the volume in the closing range and the back contract months are settled to keep the spread relationships in line."

                  The PriorDayOHLC indicator, which works only on intraday bars, returns the last close it saw on the previous day. There is no way it can know the daily settlement price, which is only reported in the Daily quotes. You should be able to get it by Adding a set of Daily bars and referencing the Close of that series:

                  http://www.ninjatrader-support.com/H...ameInstruments

                  Comment


                    #10
                    I made an indicator (just a couple of lines of code) that I think will do what you want, it adds a daily bar series and plots the close of that.
                    Last edited by kdoren; 04-11-2011, 02:14 PM. Reason: Removed attachment, see more recent post for updated version

                    Comment


                      #11
                      Thank you very much for explanation on how CME settles Corn. I'm new to trading and there are many things that I don't understand yet.
                      Also thanks for the indicator, but unfortunately it returns the same value as PriorDayOHLC() method
                      In TWS you can add a column "close" it is under "price" menu in columns selection. This is the correct settlement price. Based on this price day price limit is calculated. What would help little bit would be to get at least day change value, but I was not successful on finding how to get it.
                      I'm getting little bit desperate...

                      Filip

                      Comment


                        #12
                        The indicator works properly, there must be something wrong with your data. I tried it with ZC 05-11 Globex with IQFeed and it returns 736 for the 4/1 close. Who is your data provider?

                        Under Historical Data Manager, download the "Day" data for your ZC contract for the date range you are testing.

                        Under "Tools->Opions->Data", check the box for "Get Data From Server (If Available)" and uncheck the box for "Save chart data as historical"

                        See if that helps.

                        Comment


                          #13
                          My provider is Interactive Brokers. I have done all you suggested but with no result. Take a look on charts.jpg.
                          Number 1 is yesterday's settlement value in TWS ( what I'm trying to get)
                          Number 2 value provided by your indicator.
                          Number 3 yesterday's close day corresponding with value of your indicator in TWS chart.

                          If I'm not missing something then it is not what I need.
                          Attached Files

                          Comment


                            #14
                            I tried it with IQFeed and it reports the correct daily close of $766.75 for 4/5.

                            It appears that Interactive Brokers reports the daily bar close as the same close as the last minute bar of the session. This is clearly wrong, the historical daily bars should report the official close, and that's what other data providers do. But IB isn't really in the data feed business, and I can't say I'm surprised. I find them to be unusable for historical data, mainly because of severe data throttling, but this is another reason to not use them for historical data. If you are auto-trading with NT7 with IB you have to use them for live data due to NT7 limitations. But I recommend you use IQFeed or some other provider for historical data (make sure you set up your IB connection in NT7 to not use IB for historical data).

                            Comment


                              #15
                              You should try using Kinetick for daily data; the data comes from IQFeed so it accurate, and it's free for daily data with NT7.

                              I'm not completely sure this will work (perhaps someone from NinjaTrader can comment), but try connecting to Kinetick BEFORE you connect to Interactive Brokers, and see it that works. Will NT7 get the daily data from Kinetic, and the intraday data from IB? I've read things that suggest it will work but I haven't tried it.

                              You'll have to be sure you're not pulling bad data out of your local database, so I would delete the daily data that's there, or re-download it, and/or check the box "Get Data From Server (If Available)"

                              -Kevin

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by inanazsocial, Today, 01:15 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post inanazsocial  
                              Started by trilliantrader, 04-18-2024, 08:16 AM
                              5 responses
                              22 views
                              0 likes
                              Last Post trilliantrader  
                              Started by Davidtowleii, Today, 12:15 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Davidtowleii  
                              Started by guillembm, Yesterday, 11:25 AM
                              2 responses
                              9 views
                              0 likes
                              Last Post guillembm  
                              Started by junkone, 04-21-2024, 07:17 AM
                              9 responses
                              70 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X