Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicators not showing on last bar

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

    Indicators not showing on last bar

    Indicators for my charts are not presented for the most recent price bar. For example, on a daily chart, last Friday's price bar is shown, reflecting the day's activity, but none of the companion indicators are shown, last updated for Thursday. Indicators are just simple moving averages and MACD. I have also just done a refresh of the data and chart. Is this correct, or do I need to configure the indicators with an option perhaps?

    #2
    Originally posted by MrSmartGuy View Post
    Indicators for my charts are not presented for the most recent price bar. For example, on a daily chart, last Friday's price bar is shown, reflecting the day's activity, but none of the companion indicators are shown, last updated for Thursday. Indicators are just simple moving averages and MACD. I have also just done a refresh of the data and chart. Is this correct, or do I need to configure the indicators with an option perhaps?
    If CalculateOnBarClose is true, then there will be nothing shown on the forming bar, because it has not closed. Change the CalculateOnBarClose property using the PropertyGrid for the indicators.

    Comment


      #3
      Thank you, koganam. I changed the calculate on bar close property to false and then the indicators appeared. But still, even with the property set to true, should not a daily bar be updated on a Monday morning for Friday's bar, as that bar is closed?

      Comment


        #4
        Originally posted by MrSmartGuy View Post
        Thank you, koganam. I changed the calculate on bar close property to false and then the indicators appeared. But still, even with the property set to true, should not a daily bar be updated on a Monday morning for Friday's bar, as that bar is closed?
        On a daily chart, typically, yes. But it depends on the TradingHours template: as that is what defines the start and end of a new session. What does the terminal date read on your daily chart?

        IOW, for stocks, the calendar date will almost always make this true: for some futures, it might not.

        Comment


          #5
          Thanks again. No luck with "session template" experiments. It was set to use "use instrument settings," and I tried US Equities (both extended and regular hours) with no change, i.e. indicator still not updated. This is for SPY, so a fairly straightforward instrument.

          One further clue -- when I enable my strategies to run on the daily bars, the execution time is 3:00 p.m. central time, which makes sense for SPY. It would seem that if the strategy code thinks that 3:00 is the end of the day, then so should the indicator code.

          Although I have a workaround to make progress, I would still like to get to the bottom of it all at some point.

          Comment


            #6
            Hello MrSmartGuy,

            When Calculate on bar close (COBC) is set to True, the indicator would never plot on the current bar.

            Each bar is closed as the new bar opens. Without a new tick to open the new bar, the current bar does not close. Until the bar closes, the code to the set the value for that bar is not run.

            This means that Friday's bar will close after the first tick that starts Monday's session is received.

            As the new tick is received, this makes a new building bar for Monday and the plot for Friday will appear.

            The SPY uses the US Equities RTH session template by default. The hours of this are from 9:30 AM to 4:00 PM EST Monday through Friday.

            This means that Friday's bar should appear closed Monday morning at 9:30 AM EST.


            When COBC is set to false, the Plot can be set on every received tick using 0 for 0 bars ago.

            When the plot appears all depends on when the .Set() is called.If it is only triggered when the bar closes, then it doesn't appear until there is a new bar on the chart. Because of this you would never see the indicator plot on the current bar, no matter what session template is used when COBC is true.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thank you for the details, Chelsea. If I could please get your thoughts on implementation options, please.

              OK, I understand that with the COBC parameter set to true, then the actual calculation, and therefore usefulness of the calculation, will not occur until the next bar opens. Could you share with us why things are not synced with the open and close of the exchanges trading the instrument?

              Moving forward, most of my decisions are made in the evening, after the market closes, so, if I hear you right, I can set the COBO param to false to see the indicators, and that does seem to work on my charts. That's workable, although the processing of each tick could be a significant processing load, as well as internet data traffic. Considering all of these concerns, what do you recommend for someone like me processing daily data after the market close each day, in preparation for the next day? That's a lot of data to move, when only the final result is desired, and would seem to only add to the load of the NT servers, which I'm sure is significant.

              -- I've only come across individual COBC flags for each indicator. Is there a global option?

              -- If I switched the flag off at night to see the indicators, would I find myself waiting of the download of all the tick data for the day?

              -- Perhaps there are time checks to put in the "on bar update" processes code to minimize processing load?

              -- I currently have separate code for daily, weekly, and monthly "on bar update" calls. Will all three processes see each tick arriving?

              Surely I am not the first person to deal with us. What guidance can you provide? Thanks!

              Comment


                #8
                Hello MrSmartGuy,

                When you mention "Could you share with us why things are not synced with the open and close of the exchanges trading the instrument?", I am not understanding what you are referring to by this.

                When the first bar closes, the open of the first bar of the session will match the open of the session.

                Are you comparing a minute chart on NinjaTrader with a minute chart on the exchange's website?

                Do you have a screenshot to show that these are showing different prices?


                Regarding internet usage, NinjaTrader is already receiving every real-time tick and every market data event in real time for every instrument you have in a window like a chart or superdom. Indicators added to that chart, are allowed to call and process that already received real-time data. Once a chart is opened to an instrument, it is fully connected to a live stream of that instrument. Adding or subtracting indicators does not use any more or less of this live stream.

                Regarding NinjaTrader servers, any script that is running on your machine, is only running on your machine. If you add too many indicators, this can overload your local computer's CPU and will slow down performance for you but this will not happen for any NinjaTrader server or any other users computers.

                Setting a script to run in Calculate on bar close will cause the CPU usage of your local computer to increase. However, if you want your indicator to continuously update in real time, that would be necessary to do.

                It would be possible to edit the code of each indicator separately and add code that prevents the script from working in real time unless the time is close to the end of the session. This logic would have to be custom coded by you or by a consultant and added to the code of each indicator.

                There is no global option for Calculate on bar close.

                When you mention "If I switched the flag off at night to see the indicators, would I find myself waiting of the download of all the tick data for the day?", I am not understanding what you are asking. Are you asking if you set Calculate on bar close to false that new tick data would not be received the next day? No, with COBC set to false, new data will still come in the next day.

                Yes, you can add a check to the code of a script to prevent the script from running in real time until a certain time.

                For example if you write at the top of OnBarUpdate():
                if (!FirstTickOfBar || (ToTime(Time[0]) > 140000 && ToTime(Time[0]) < 80000))
                {
                return;
                }

                This would stop processing unless it was either the first tick of the bar or the time is after 2 PM and before 8 AM.

                Yes, all bar types process on every tick when COBC is false.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hi Chelsea,

                  I have attached a screen shot of a simple SPY daily chart with an SMA indicator added to it. This clearly shows the lack of synchronization that I am referring to. The screen just, just taken today, Thursday, at 1100 central time, shows the price bar with its Wednesday close, but the SMA is only calculated through to the Tuesday bar.

                  So, in the middle of the trading day, when there is absolutely no question that another price bar has started, there is no updated indicator from the prior day. Bottom line is that the price bar has updated correctly, but not the companion indicators, i.e. they are not properly synchronized.

                  Thank you for your efforts in considering this.

                  MSG
                  Attached Files

                  Comment


                    #10
                    Hi MrSmartGuy,

                    I am still not understanding how these are not synchronized.

                    The indicator does not show on the last bar on the chart because the last bar on the chart has not closed (triggering the plot to be set) because calculate on bar close is set to false.

                    This is as I have explained in post #6.

                    "Each bar is closed as the new bar opens. Without a new tick to open the new bar, the current bar does not close. Until the bar closes, the code to the set the value for that bar is not run."

                    However, the value for the second to last bar on the chart (the most recently fully closed bar) should have an accurate value. Are you finding the SMA value on the second to last bar is incorrect?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by MrSmartGuy View Post
                      Hi Chelsea,

                      I have attached a screen shot of a simple SPY daily chart with an SMA indicator added to it. This clearly shows the lack of synchronization that I am referring to. The screen just, just taken today, Thursday, at 1100 central time, shows the price bar with its Wednesday close, but the SMA is only calculated through to the Tuesday bar.

                      So, in the middle of the trading day, when there is absolutely no question that another price bar has started, there is no updated indicator from the prior day. Bottom line is that the price bar has updated correctly, but not the companion indicators, i.e. they are not properly synchronized.

                      Thank you for your efforts in considering this.

                      MSG
                      Look at the date. Today's bar is not on the chart.

                      Comment


                        #12
                        Thanks koganam,

                        MrSmartGuy, is your question 'why isn't there a bar on the SPY daily chart for today?'?

                        Are you currently connected to a real-time data feed?

                        Can you show the Chart Trader area so that we may see you have ask and bid prices receiving?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Chelsea, koganam:

                          Yes, koganam, today's bar is not on the chart, per your observation, as a new bar only appears at the end of the day after trading for SPY closes. Each evening, I get a new price bar reflecting the day's price action. The indicators also advance by one day, but they are always lagging by one day, as shown in the chart I provided. As the price bar closes at this time, then why would the indicators not update, also. That bar is set in concrete, and will never change again.

                          Chelsea -- please recognize that there are two issues here. The first issue is when things are updated, and right now the price bar is updated shortly after trading closes for SPY each evening, with the indicators coming along 24 hours later.

                          The second issue is whether or not the price bar and indicators are synchronized, regardless of when they appear. To me, a full one day lag between the price bar and its companion indicators does not represent synchronization between the printing of the price bar and the indicators. If NT also delayed the printing of the price bar for 24 hours then, while I would still not like the answer, at least the claim could be made that they are synchronized.

                          Sometimes an old-fashioned telephone call can more quickly resolve such things. Please private message me when a good time is to talk and where to call, and I will call you.

                          MSG

                          Comment


                            #14
                            Hello MrSmartGuy,

                            As I mentioned in post #6, the bar is closed when the new bar opens. That means that a bar will not be closed until there is a new building bar on the chart.

                            The bar is not closed after the end of the session.

                            The bar is closed after the first tick of the new session is received opening the new bar.

                            The indicator on the chart is using the Open, High, Low, and Close of the bar on the chart. If the open, high, low, and close of the chart is accurate then its the exact same information that is supplied to the indicator.

                            Unless you are supplying a secondary data series with some other instrument or time frame, there is not away for the indicator to be out of sync with the bar it is plotted on when it is using the information from that bar after the bar closes for its input source for its calculations.

                            So, yes, the bars on the chart and the indicators using those bars for their input source are synchronized.

                            In the screenshot, the bar for the 19th has not opened. Thus, the bar on the 18th has not closed. If the bar for the 18th has not closed, then OnBarUpdate has not run yet for that bar and the plot has not yet been set.

                            You are not seeing the indicator on the current bar because the current bar has not closed. When the current bar closes, there will be a new bar on the chart and the indicator will plot for the current bar that has just closed.

                            If you would like a call, you will need to send an email to platformsupport [at] ninjatrader [dot] com.
                            Last edited by NinjaTrader_ChelseaB; 11-19-2015, 01:30 PM.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by MrSmartGuy View Post
                              Chelsea, koganam:

                              Yes, koganam, today's bar is not on the chart, per your observation, as a new bar only appears at the end of the day after trading for SPY closes. Each evening, I get a new price bar reflecting the day's price action. The indicators also advance by one day, but they are always lagging by one day, as shown in the chart I provided. As the price bar closes at this time, then why would the indicators not update, also. That bar is set in concrete, and will never change again.

                              Chelsea -- please recognize that there are two issues here. The first issue is when things are updated, and right now the price bar is updated shortly after trading closes for SPY each evening, with the indicators coming along 24 hours later.

                              The second issue is whether or not the price bar and indicators are synchronized, regardless of when they appear. To me, a full one day lag between the price bar and its companion indicators does not represent synchronization between the printing of the price bar and the indicators. If NT also delayed the printing of the price bar for 24 hours then, while I would still not like the answer, at least the claim could be made that they are synchronized.

                              Sometimes an old-fashioned telephone call can more quickly resolve such things. Please private message me when a good time is to talk and where to call, and I will call you.

                              MSG
                              To what data feed are you connected? I would surmise that it is the free Kinetick EOD?
                              Last edited by koganam; 11-19-2015, 02:10 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by WHICKED, Today, 12:56 PM
                              2 responses
                              14 views
                              0 likes
                              Last Post WHICKED
                              by WHICKED
                               
                              Started by Felix Reichert, Today, 02:12 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Felix Reichert  
                              Started by Tim-c, Today, 02:10 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Tim-c
                              by Tim-c
                               
                              Started by cre8able, Today, 01:16 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post cre8able  
                              Started by chbruno, 04-24-2024, 04:10 PM
                              3 responses
                              49 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Working...
                              X