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

Playback vs Times[0][0] Object reference not set to an instance of an object

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

    Playback vs Times[0][0] Object reference not set to an instance of an object

    Hi NT bods,

    Getting null exceptions in playback connection for

    private in hr;
    private string s_hr;

    hr = Times[0][0].Hour;
    s_hr = Times[0][0].Hour.ToString();

    >> Strategy 'some_strat': Error on calling 'OnBarUpdate' method on bar 4176: Object reference not set to an instance of an object.

    is this expected ?

    Cheers,
    Mark





    #2
    everything else is commented out in onbarupdate() this is all I have left..

    Code:
    if(CurrentBars[0] < (200) ) return;
                if(CurrentBars[2] < (200) ) return;
                Print("Made it to line 452");
                printdata2=false;
                tradetime=false;
                st_hr=2;
                end_hr=12;
                if(Time[0].Hour==0||Time[0].Hour==null||Time[0].Hour==-1)return;
                Print("DEBUG: Times[0][0].Hour --> "+Time[0].Hour);

    Comment


      #3
      corrupt playback data ? disconnected, reset db, exited, cleaned up db files, fired up, downloaded 7th and 8th jan again .. seems to work ok now !?!?!

      how can we check for this ? corrupt / missing data possibly ? null check etc ?

      Comment


        #4
        Hello 12tkram,

        Thanks for opening the thread.

        From observations, the only item from the snippet in post #2 that I think would be giving a null reference error would be the following if the additional data series was not loaded for the script.

        Code:
         
         if(CurrentBars[2] < (200) ) return;
        If you were running an instance of the script that did not call AddDataSeries twice, then this could explain how the error was received. I would need to be testing the full script and see the same observations to draw a conclusion to the replay data being the issue, but I would also check this to be sure that the replay data downloaded would cause an issue here. I wouldn't have any suggestions for checking the integrity of Market Replay data before the script runs. The Market Replay data should always work as is, and if there are issues running on that data, redownloading it would be a good step to troubleshoot issues with corrupt data.

        If you encounter the issue again, please attach an example script that can demonstrate the issue and let me know how it can be tested to encounter the issue, and I will be happy to take a closer look with you.

        I look forward to being of further assistance.
        JimNinjaTrader Customer Service

        Comment


          #5
          it was corrupt data, just need a way of checking for it .. and yes, i have the standard data series and also 2 x added data series for days and ticks .. series 2 is ticks ..

          so, how could i check for corrupt data ? so i can print a meaningful message before it takes a hit ..

          thanks for looking Jim

          Cheers
          Mark

          Comment


            #6
            Hello Mark,

            I would not have any suggestions for checking for corrupt data and there would not be a good way to check the integrity of the Market Replay data from the script's end. The playback data should work as is, and if you are seeing issues that do not seem attributed to the script, I would suggest redownloading that data to troubleshoot further.

            If there are issues where data consistently becomes corrupt, or if you are seeing a particular issue when testing against a particular set of data, then those would be separate issues we should look into.
            JimNinjaTrader Customer Service

            Comment


              #7
              thanks Jim, thats the problem, I did not know it wasn't related to the script, I had just flipped from back testing to fwd testing and wanted to re-run the days data to see if the trades lined up with what I saw in the back test for the day, this was the first time ever running the code in playback mode ... and with the lack of error message detail and code line numbers for the abend i spent till gone midnight commenting out the code, adding print statements and re-running commenting lines in one at a time .. incredibly frustrating .. I have used quote a few IDEs and I have to say as much as I love NT this is a real negative for me .. other trading IDEs I have used give code abend line numbers and char position on that line which helps no end when tracking down issues .. just my $0.02c .. keep up the good work

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by helpwanted, Today, 03:06 AM
              1 response
              12 views
              0 likes
              Last Post sarafuenonly123  
              Started by Brevo, Today, 01:45 AM
              0 responses
              9 views
              0 likes
              Last Post Brevo
              by Brevo
               
              Started by aussugardefender, Today, 01:07 AM
              0 responses
              5 views
              0 likes
              Last Post aussugardefender  
              Started by pvincent, 06-23-2022, 12:53 PM
              14 responses
              242 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              9 responses
              387 views
              1 like
              Last Post Gavini
              by Gavini
               
              Working...
              X