Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't get correct daily close

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

    Can't get correct daily close

    Hi NinjaTraders!

    I'm having trouble trying to understand why the daily closing prices don't match the closing prices of shorter time frames (1M, 5M ...) at the end of the trading session.
    For example, I use OpenTick as my data provider, and have charts open for NDX (NASDAQ 100 index), S&P500 index and SPY.

    It's only when I chart daily candles that the closing prices match the official closing prices from the exchange. On shorter time frames, shouldn't the closing price of the last candle of the session (at 4:00PM ET) be the same as the daily closing price?

    What am I missing?

    -- Peter

    #2
    On intraday time frames, the opening and closing will based on ticks received in either real-time or from their historical servers. The open will be the first tick that falls inside your defined session start time and the close price will be the last tick that falls before the chart session close time. In theory this should match the daily bar close provided by that the intraday session times match the session times that the OT used to build their daily bars.
    RayNinjaTrader Customer Service

    Comment


      #3
      Modify the chart template

      You would have to define the session start and close on the chart template in order for it to work as you want; the defaults are from 12 midnight to 12 midnight.

      You modify the template by double-clicking in the chart, to bring up the chart properties dialog box.

      I would suggest that you then save the template, either to a name or as the default. That way when you open a chart with that template selected; or load the template at any time, your chart will be set up the way that you want.

      Comment


        #4
        Thanks koganam.
        Setting both the session begin and end to 12:00 AM does sometimes provide the correct close price on shorter time frames - but that then leaves 9.5 hours of flat-line on the charts in each day and really messes up the plotting of indicators. I have "Exclude weekend" set to true, and "Show unstable period for indicators" set to false.
        These settings don't seem to have any effect.


        Also, sometimes there are large erroneous price spikes visible in the after hours data. For example: on 2008-09-30, there is a huge spike on the NDX at 17:20 in the OpenTick data.
        I'm not sure if the NDX premarket index values computed by the exchange are included in the official index.

        I would really like to eliminate these out-of-session periods from the charts and from the DataSeries itself so that my analysis code isn't misled.

        There does seem to be something wrong with either the OpenTick data or the NinjaTrader charts:
        On 2008-10-09 the official NDX 4:00PM close was 1275.10 .
        On a 5 minute chart it is the 4:05PM candle that has this close price.
        On a 1 minute chart it is the 4:02PM candle that has this close price.
        On a 15 minute chart it is the 4:15PM candle that has this close price.

        So, the intraday charts are usually wrong at the end of the session by at least one time period.

        And the session open prices have a similar problem:

        The official NDX session open price on 2008-10-09 was 1353.59 .
        On an NT daily chart of OpenTick data the open price is 1349.55 .
        On the intraday charts the first candle on the charts also have this incorrect open price.

        NinjaTrader_Ray - I'm using only historical data from OpenTick that was obtained today (Saturday) so I still don't understand this behavior.

        -- Peter
        Last edited by pcdev; 10-12-2008, 12:45 AM.

        Comment


          #5
          I am not sure what further explanation I can give other than on an intraday chart, the OHLC will be based on the data set filtered by your session definition times.
          RayNinjaTrader Customer Service

          Comment


            #6
            I must not have been clear enough in my original response.

            What I meant was that YOU have to define the session times as YOU want them to be, and NOT use the default 24 hour schedule. One suggestion would be to set the session start to 0930 EDT and the session close to 1600 EDT; or 1615 EDT if you trade options (with or rather than stock). That will exclude data outside those hours completely from the chart.

            The other, somewhat more flexible way to do this is to modify the indicators that you use, so that you can set session times as indicator parameters in the properties: a somewhat less flexible way is to simply put lines such as these as the first statements in the OnBarUpdate() function.

            if ((ToTime(Time[0]) < ToTime(09, 30, 00))) return;
            if ((ToTime(Time[0]) > ToTime(16, 15, 00))) return;


            Of course, you can combine the statement into one statement if you think that is more efficient.

            Remember to recompile the indicator if you do this. Also note that Ninja Trader support is very unlikely to support you if you make such modifications to the supplied indicators. One way around that is to save the indicator to a different name and then compile it. That way you have your own version that is separate from the supplied version. So eg., you would have "my_RSI" indicator that was created from a modified standard NT supplied RSI indicator.

            Almost all the personal indicators that I write for myself use one or other of these methods to limit calcaulation using session data. Doing it this way allows one to leave the chart templates intact, so that one can see the after hours action, but not have those actions affect the behavior of the indicators. ie., the indicators will only process data relative to the defined session, even though the chart will show all data.

            Comment


              #7
              Originally posted by koganam View Post
              What I meant was that YOU have to define the session times as YOU want them to be, and NOT use the default 24 hour schedule. One suggestion would be to set the session start to 0930 EDT and the session close to 1600 EDT; or 1615 EDT if you trade options (with or rather than stock). That will exclude data outside those hours completely from the chart.
              I guess I didn't explain that I have been doing exactly that.
              The problem however is that on intraday charts, the 9:30AM open and 4:00PM close prices are usually NOT the same as the official prices for those times. So I can only conclude that the exchange is deciding the official open and close prices based on ticks that arrive outside of the session times. That explanation seems to agree with the fact that the OpenTick data does sometimes have the correct close price but at one or two periods after the actual session close time.
              That still does not explain however why the daily open prices are different.


              Originally posted by koganam View Post
              The other, somewhat more flexible way to do this is to modify the indicators that you use, so that you can set session times as indicator parameters in the properties: a somewhat less flexible way is to simply put lines such as these as the first statements in the OnBarUpdate() function.

              if ((ToTime(Time[0]) < ToTime(09, 30, 00))) return;
              if ((ToTime(Time[0]) > ToTime(16, 15, 00))) return;


              Of course, you can combine the statement into one statement if you think that is more efficient.
              I see! I suspected that I might need to do that. I wonder why NinjaTrader doesn't do it by default according to the template properties?


              Originally posted by koganam View Post
              Remember to recompile the indicator if you do this. Also note that Ninja Trader support is very unlikely to support you if you make such modifications to the supplied indicators. One way around that is to save the indicator to a different name and then compile it. That way you have your own version that is separate from the supplied version. So eg., you would have "my_RSI" indicator that was created from a modified standard NT supplied RSI indicator.

              Almost all the personal indicators that I write for myself use one or other of these methods to limit calcaulation using session data. Doing it this way allows one to leave the chart templates intact, so that one can see the after hours action, but not have those actions affect the behavior of the indicators. ie., the indicators will only process data relative to the defined session, even though the chart will show all data.
              Thanks very much for your advice! I think I will do that too. I'm quite comfortable rewriting the indicators - that is one of the great features of NinjaTrader.


              -- Peter

              Comment


                #8
                Originally posted by NinjaTrader_Ray View Post
                I am not sure what further explanation I can give other than on an intraday chart, the OHLC will be based on the data set filtered by your session definition times.
                Thanks Ray - I guess I'm going to have to live with this inconsistency.

                As I mentioned in the previous post - it must be something to do with the exchange using out-of-session data to set the official session close prices, which makes it difficult match those on intraday charts.

                Is there any reasonable explanation though for the differences in open prices?

                -- Peter

                Comment


                  #9
                  Time stamps for bars ?

                  The open price may look different depending on how bars are time stamped. If NT stamps them on close, while OT stamps them on open for example (or vice-versa), they would likely be different. In which case, of course, you would have to modify your indicator to read the immediate antecedent bar to get the correct data.

                  Please note that I am not saying that this is what is happening: I am just explaining one reason why the open prices could look inconsistent.

                  Unfortunately, as OT will still not accept new users, I have no way of checking this myself.

                  That having been said, as trading is so inexact in any event, does it REALLY make that much of a difference in your decisions? I understand that if the variation is very large, it very well could. Then again, as I almost never trade in the first 30 minutes anyway, maybe my view is skewed. I trade options almost exclusively, so yes, I MUST wait: unlike stock prices, option prices are still in a price discovery state early in the open.

                  Just a thought; I am not questioning your judgement or skills.

                  Comment


                    #10
                    Originally posted by koganam View Post
                    The open price may look different depending on how bars are time stamped. If NT stamps them on close, while OT stamps them on open for example (or vice-versa), they would likely be different. In which case, of course, you would have to modify your indicator to read the immediate antecedent bar to get the correct data.

                    Please note that I am not saying that this is what is happening: I am just explaining one reason why the open prices could look inconsistent.
                    It looks to me like the prices from OpenTick are timestamped correctly. Interestingly, I now see that the prices on other platforms - such as thinkorswim are also different intraday at the end of the session from the daily data.


                    Originally posted by koganam View Post
                    Unfortunately, as OT will still not accept new users, I have no way of checking this myself.
                    I wasn't aware that OpenTick was restricting customers - they routinely bill my credit card each month and I haven't noticed anything else going on .
                    The only reason I have OpenTick is for use with NinjaTrader.

                    Originally posted by koganam View Post
                    That having been said, as trading is so inexact in any event, does it REALLY make that much of a difference in your decisions? I understand that if the variation is very large, it very well could. Then again, as I almost never trade in the first 30 minutes anyway, maybe my view is skewed. I trade options almost exclusively, so yes, I MUST wait: unlike stock prices, option prices are still in a price discovery state early in the open.

                    Just a thought; I am not questioning your judgement or skills.
                    I agree completely. I also trade options, so I know all about waiting to get a good price!

                    I've spent a large part of my working life developing software, so maybe that's where I get my tendency to strive for perfection - a bad trait for trading, I know. I'm still working on that

                    -- Peter

                    Comment


                      #11
                      For clarification, although NT time stamps bars at the end of the bar, the ticks that make up the bar are still the same ticks that most providers who time stamp start of bar use.

                      We use 00:00:00 to 00:00:59 for minute bars for example.
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Ray View Post
                        We use 00:00:00 to 00:00:59 for minute bars for example.
                        Thanks Ray, it's easy get confused when comparing candles on different platforms.

                        Then the last minute bar of the session timestamped as 16:00:00 should have all the ticks within 15:59:00 and 15:59:59 (inclusive). That makes sense to me.

                        -- Peter

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by jeronymite, 04-12-2024, 04:26 PM
                        3 responses
                        43 views
                        0 likes
                        Last Post jeronymite  
                        Started by frankthearm, Today, 09:08 AM
                        4 responses
                        10 views
                        0 likes
                        Last Post frankthearm  
                        Started by yertle, Today, 08:38 AM
                        5 responses
                        15 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by adeelshahzad, Today, 03:54 AM
                        3 responses
                        18 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by bill2023, Yesterday, 08:51 AM
                        6 responses
                        27 views
                        0 likes
                        Last Post NinjaTrader_Erick  
                        Working...
                        X