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

Help: Bars.IsFirstBarOfSession is throwing NULL ref exception

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

    Help: Bars.IsFirstBarOfSession is throwing NULL ref exception


    Hello,
    I'm getting a null ref exception when using Bars.IsFirstBarOfSession.
    After a lot of crying and debugging I figured out it happens only with Tick Replay enabled and my strategy requires Tick Replay...
    My OnBarUpdate is also configured with Calculate=OnEachTick.
    I managed to isolate the problem in a simple script: Here

    Here is a screenshot of the exception, notice that the stack trace points that the error is occurring inside GetIsFirstBarOfSession which I don't have the
    source code for unfortunately...


    #2
    Can you explain more about how you run this?

    Which instrument?
    What kind of chart?

    How much Market Replay data did you download?
    Where did you download your Market Replay data from?

    Does it happen on any instrument for any Market Replay data?

    Comment


      #3
      I was testing on the ES 03-21 contract in playback mode.
      1 minute chart with 5 days back but it fails with 10 and 20 also.
      Tick Replay enabled(if you disable it then there is no problem, but I need Tick Replay to be enabled).
      There is no shortage of historical data, I downloaded from my cqg account the whole contract.
      Didn't test other instruments, I need this one to work
      Last edited by weedjitsu; 04-18-2021, 10:22 AM.

      Comment


        #4
        Gotcha, thanks.

        For me to reproduce, what days for Market Replay should I download?
        It's a PITA to download lots of replay data. Since ES 03-21 is an older
        contract, can you tell me the exact days I should focus on?

        Also, what is the exact date & time should I start the Replay session at?

        And finally, a suggestion ...

        Your first post reveals some media savviness -- can you create a video
        showing the fewest steps necessary to start the playback session, bring
        up the chart, start the strategy, and reproduce the error -- all in order?

        Why go to that trouble? Well, you want to nail this bug, right? You want
        this fracking issue fixed, the offending programmers tarred & feathered,
        and you want the satisfaction of seeing NT Support having to admit the
        un-deniability of the bug, right? Great, give the court some undeniable
        evidence and create a how-to video for your exact reproduction steps.

        I mean, if your video can methodically walk everyone through everything
        you do, they'll have no where to run -- and it should get fixed faster.

        A short video of just a few minutes is probably plenty.



        PS: I've used screencast-o-matic with great success -- and it's free.
        Last edited by bltdavid; 04-18-2021, 11:25 AM. Reason: mentioned ES 03-21 is an older contract

        Comment


          #5
          After further investigation is definitely looks like a bug in the platform.
          I wasn't able to reproduce it on a live connection, only on playback.
          I tried testing on the ES 06-21 and at first it stopped happening but then I tried to move my playback to some other time and it started happening again.
          So the way to reproduce it is this:
          1) Open ninja and connect to a playback connection for the ES 06-21.
          2) Open a 1 min chart with Tick Replay enabled
          3) Add the example strategy I attached above
          4) Open output window to see the error
          5) Enable the strategy and it should work fine
          6) Disable the strategy and move the playback time about 24 hours forward
          7) Now enable the strategy and the error should pop in the output window

          Here are some screenshots:






          Maybe I'm doing something wrong but if it turns out to be a bug is there a way around it because I need tick replay on and I need to use this property(Bars.IsFirstBarOfSession)

          Comment


            #6
            Hello weedjitsu,

            I am not able to reproduce this behavior using 8.0.24.2.

            Below is a link to a video of the test.


            Attached is the exported test script.

            Using 8.0.24.2, and following the exact steps shown in this video, are you experiencing different behavior with the provided test script?
            Attached Files
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi,
              You didn't set the calculate to be on each tick and you used market replay and I use historical data.
              Also notice I wrote that it works for the first time but then if you pause the replay and restart the strategy with the replay in a new place it will crash(steps 5-7).
              What's the difference between market replay and historical data?
              Last edited by weedjitsu; 04-20-2021, 02:37 AM.

              Comment


                #8
                Historical data populates the historical bars on your chart,
                this happens whether you are connected to a Real-Time data
                provider or Market Replay.

                Market Replay is data that is substituted for "live" data, so
                that from a certain point forward, the real-time data normally
                used to build brand new bars is coming from the Market Replay
                downloaded files.

                Think of your normal live "real-time" data stream coming from
                your data provider -- Market Replay provides an alternative to
                that -- it provides a past "real-time" data stream coming from
                Market Replay downloaded files.

                And just like a real-time data provider, Market Replay does not
                know how to populate past historical bars -- the chart needs
                historical data to do that.
                Last edited by bltdavid; 04-20-2021, 05:58 AM. Reason: emphasis on live vs past

                Comment


                  #9
                  Are you running 8.0.24.2?

                  Did you run NT Support's test script as they asked?
                  Did that script fail?

                  You need to be specific.
                  When you say "it will crash" -- which script are you referring to?
                  Last edited by bltdavid; 04-20-2021, 06:01 AM.

                  Comment


                    #10
                    Hello weedjitsu,

                    Thank you for the further clarification about using Historical data and TickReplay, I was able to reproduce and have reported the behavior.

                    I will update with any further information I hear back from development.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello weedjitsu,

                      Our latest build appears to have this fixed due to another issue that was corrected.

                      I'd like to have you test. May I have you write in to [email protected] and reference ticket ID# 3062000 so that I may provide you a link to download?
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by weedjitsu View Post
                        Hello,
                        I'm getting a null ref exception when using Bars.IsFirstBarOfSession.
                        After a lot of crying and debugging I figured out it happens only with Tick Replay enabled and my strategy requires Tick Replay...
                        My OnBarUpdate is also configured with Calculate=OnEachTick.
                        I managed to isolate the problem in a simple script: Here

                        Here is a screenshot of the exception, notice that the stack trace points that the error is occurring inside GetIsFirstBarOfSession which I don't have the
                        source code for unfortunately...
                        I've had the same error.
                        Then I noticed that it only came with M1 and not with M5. Then I cleared the cache and the error was gone,

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by andrewtrades, Today, 04:57 PM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by chbruno, Today, 04:10 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post chbruno
                        by chbruno
                         
                        Started by josh18955, 03-25-2023, 11:16 AM
                        6 responses
                        436 views
                        0 likes
                        Last Post Delerium  
                        Started by FAQtrader, Today, 03:35 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post FAQtrader  
                        Started by rocketman7, Today, 09:41 AM
                        5 responses
                        19 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X