Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bug: OnBarUpdate processing historical bars with State.Realtime

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

    #31
    Hello Harry,

    Thanks for clarifying.

    I think you are running into a race condition. The value being displayed is the value calculated from OnRender (try changing the date used and the OnBarUpdate will reflect the same). This is processing asynchronously as OnBarUpdate is also processing.

    Our advice would be not to call CalculateTradingDay() in OnRender and calculate this in a data driven method like OnBarUpdate. (You can still use the begin / end time, however, don't trigger the calculation unless you are in a data driven method)

    Regarding the issue with the historical bars being marked as real-time, until this is corrected in a future version of NinjaTrader, IsSuspendedWhileInactive set as false would prevent the incorrect behavior.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #32
      Hello Chelsea,

      Thank you for your answer.

      Originally posted by NinjaTrader_ChelseaB View Post

      I think you are running into a race condition. The value being displayed is the value calculated from OnRender (try changing the date used and the OnBarUpdate will reflect the same). This is processing asynchronously as OnBarUpdate is also processing.

      Our advice would be not to call CalculateTradingDay() in OnRender and calculate this in a data driven method like OnBarUpdate. (You can still use the begin / end time, however, don't trigger the calculation unless you are in a data driven method)
      This makes sense to me.

      I have now modified my code and use 2 different session iterators for the same bar series. One is reserved for the use with OnBarUpdate(), the other one is reserved for the use with OnRender(). Could you confirm that this would avoid the race condition?

      Also I would like to suggest to include the limitation on the use of CalculateTradingDay() and GetNextSession() in the help guide. I think that this issue is more a question of documentation than a real problem. I did not understand that it would be affected by multi-threading.


      Originally posted by NinjaTrader_ChelseaB View Post

      Regarding the issue with the historical bars being marked as real-time, until this is corrected in a future version of NinjaTrader, IsSuspendedWhileInactive set as false would prevent the incorrect behavior.
      I understand that this behavior will be corrected with a future release?

      Comment


        #33
        Hello Harry,

        My recommendation is that you calculate values in a data driven method.

        Anything that is data related that is used in OnRender or any other non-data-driven method is subject to a race condition as they will process asynchronously.

        Limit any calculations or algorithms you may be tempted run in OnRender() simply to rendering. You should always favor pre-computed values and store them for rendering later as the preferred approach to working with the OnRender() method (e.g., reusing brushes, passing values from OnBarUpdate, Calculating the session iterator, etc.)

        I have not received a tracking ID yet for the historical bars in the state of real-time, and I cannot guarantee that any thing reported will be corrected in a new version.
        However, you would want to wait until a new version is released and check for the fix by using the ID.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #34
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello Harry,

          Limit any calculations or algorithms you may be tempted run in OnRender() simply to rendering. You should always favor pre-computed values and store them for rendering later as the preferred approach to working with the OnRender() method (e.g., reusing brushes, passing values from OnBarUpdate, Calculating the session iterator, etc.)
          The values cannot be precomputed anywhere else. In the specific case I wanted to find out whether the last bar of the chart belongs to the same session as the second but the last bar.

          When an indicator is set to Calculate.OnBarClose, the last bar of the chart is not yet processed by OnBarUpdate(). Therefore it is impossible to pre-compute this value in OnBarUpdate(). CalculateTradingDay() therefore needs to be called in OnRender().

          I am aware that CalculateTradingDay() is expensive in terms of CPU load, and I am only calling it when the last bar of the chart has changed - because a new one was added via real-time data or because the user has scrolled the chart horizontally. It is not possible to do this calculation elsewhere.

          Comment


            #35
            Hello Chelsea,

            I want to point to further problems with minimized charts.

            (1) OnRender is not correctly synchronized with OnBarUpdate(). This means that

            -> when OnRender() is called OnBarUpdate has not yet terminated running and the plot values for the last bar BarsArray.Count - 1 are not yet available
            -> this is particularly the case for multi-timeframe indicators which run a secondary bar series
            -> plots are incompletely shown on the chart
            -> OnRender() is not called again after OnBarUpdate() has been completed

            In this scenario it is only the next incoming real-time tick that will trigger an update of OnRender() and complete the chart. The user is left with an incomplete chart until the first real time tick is registered.

            (2) When minimizing a chart, it often disappears from the windows task bar and can no longer be accessed. The video below shows a case where the chart can no longer be accessed.

            Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.

            Comment


              #36
              Can you confirm my findings?

              Comment


                #37
                I have now been patiently waiting for an answer for 14 days.

                This is an issue that has been brought up by a customer of mine, who did not yet switch to NinjaTrader 8 because he is partly dissatisfied.

                The customer wanted to make use of the newly introduced tabs, but did not want to have the indicators suspended while inactive.

                Currently there are three bugs related to inactive charts (or tabbed charts).

                The first bug has been confirmed inofficially (historical bars being processed as real-time bars) but no ticket has been opened.

                For the other two bugs (OnRender not being called after OnUpdate is running and minimized charts disappearing from the task bar) I have not even received an answer.

                Only the sessioniterator problem has been clearly identified as a race condition and can be easily fixed by proprer coding, Therefore this item was a false problem.

                Please, is anybody out there who would kindly confirm the 3 bugs that they can be dealt with?

                Comment


                  #38
                  Hello Harry,

                  Apologizes for the no response for an extended period of time.

                  We have been investigating this with our development team and it is taking longer than expected. We will be following up here when we have detail on this matter and the individual scenarios you have detailed.

                  Comment


                    #39
                    Originally posted by NinjaTrader_PatrickH View Post
                    Hello Harry,

                    Apologizes for the no response for an extended period of time.

                    We have been investigating this with our development team and it is taking longer than expected. We will be following up here when we have detail on this matter and the individual scenarios you have detailed.
                    Patrick,

                    Thank you for your feedback!

                    Comment


                      #40
                      Hello Harry,

                      Thank you again for your patience.

                      On the Historical Bars processing in the State Realtime this is expected behavior due to the NinjaScript object being in the state of real-time and therefore when brought back into view it will process the historical bars but in it's current state.

                      On the OnRender() items I have listed the following items:
                      • OnRender() not synced to OnBarUpdate()
                      • BarsArray.Count-1 is not available
                      • PlotSeries has no values

                      I went through the thread but could not find an example of this or further details. I tested a few case scripts on my end but they did not produce what I understand the bullet points above as. Do you have a workspace we could use to test with and potentially a test script to run to see these bullet points?

                      The Chart window disappearing from the Windows Task Bar is something I could not reproduce in my testing. Would you happen to have a test workspace for this as well?

                      I look forward to your response.

                      Comment


                        #41
                        Hello Patrick,

                        Thank you for coming back. We are discussing three different problems.

                        (A) Historical bars being processed as real-time bars.
                        (B) On Render being called prior to OnBarUpdate() and not afterwards resulting in exceptions and empty charts (can be cured via a refresh with F5)
                        (C) Minimized charts disappearing from the Windows task bar.

                        I will use the letters A,B,C to address the problems.

                        (C) For the minimized chart, I have created a little video that shows how it disappears. This often happens for no specific reason. I have at least two customers who have complained about that behavior and confirmed it.

                        Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


                        When the window is gone, you can get it back by switching to a different workspaces and then going back to the original workspace. The window will now reappear. This behavior is not 100% reproducible, but the video shows it (I had to try several times to make it appear).

                        Comment


                          #42
                          Originally posted by Harry View Post
                          (C) For the minimized chart, I have created a little video that shows how it disappears. This often happens for no specific reason. I have at least two customers who have complained about that behavior and confirmed it.

                          Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.
                          Hello Harry,

                          Thank you for your response.

                          I have reviewed the video from earlier in the thread as well. This is something we have been unable to reproduce on our end. Would you perhaps have an example workspace and/or script to reproduce this on our end?

                          I look forward to your response.

                          Comment


                            #43
                            Originally posted by NinjaTrader_PatrickH View Post
                            Hello Harry,

                            Thank you for your response.

                            I have reviewed the video from earlier in the thread as well. This is something we have been unable to reproduce on our end. Would you perhaps have an example workspace and/or script to reproduce this on our end?

                            I look forward to your response.
                            I did not use any specific workspace. As you notice from the video, I just had two windows open for the Ninjascript Editor and then had a single chart added. The chart disappeared after minimizing it.

                            Several customers of mine have observed the same behavior.

                            Comment


                              #44
                              Hello Harry,

                              Thank you for your response.

                              Each item has been reported to development.If you have any reproducible scenario or files that may assist please let me know.

                              Comment


                                #45
                                Hello Harry,

                                May I ask you to test out a new use profile on your PC for the minimized chart windows not showing on the Windows Task Bar view case?
                                You can find publicly available instructions on setting up a test environment at the following link: https://support.microsoft.com/en-us/...e-user-account

                                I look forward to your response.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by hazylizard, Today, 08:38 AM
                                2 responses
                                8 views
                                0 likes
                                Last Post hazylizard  
                                Started by geddyisodin, Today, 05:20 AM
                                2 responses
                                18 views
                                0 likes
                                Last Post geddyisodin  
                                Started by Max238, Today, 01:28 AM
                                5 responses
                                47 views
                                0 likes
                                Last Post Max238
                                by Max238
                                 
                                Started by giulyko00, Yesterday, 12:03 PM
                                3 responses
                                13 views
                                0 likes
                                Last Post NinjaTrader_BrandonH  
                                Started by habeebft, Today, 07:27 AM
                                1 response
                                16 views
                                0 likes
                                Last Post NinjaTrader_ChristopherS  
                                Working...
                                X