Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Object reference not set to an instance of an object.

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

    Object reference not set to an instance of an object.

    Hello,

    In my strategy, I tried to add a second data series, and the strategy returned an error: "Error on calling 'OnStateChange' method: Object reference not set to an instance of an object."
    Please advise what did I do wrong? Is it because my second data series time period is larger than the primary? My chart has only the primary data series displayed.

    else if (State == State.Configure)
    {

    AddDataSeries(Data.BarsPeriodType.Tick, 1);

    // Add daily VIX data series
    AddDataSeries("^VIX", BarsPeriodType.Minute, 1);
    }

    Best,

    Billy​

    #2
    Hello Billy​,

    Are you 100% certain that code is causing the issue?

    Have you created a new test script and added only that code and ensured the reduced test script with only that code is able to reproduce?

    I'm testing and I am not able to reproduce.

    Can you provide an export of the reduced test script that has only the code you posted in post # 1?

    To export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:
    1. Click Tools -> Export -> NinjaScript...
    2. Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
    3. Click the 'Export' button
    4. Enter a unique name for the file in the value for 'File name:'
    5. Choose a save location -> click Save
    6. Click OK to clear the export location message
    By default your exported file will be in the following location:
    • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
    Below is a link to the help guide on Exporting NinjaScripts.
    http://ninjatrader.com/support/helpG...-us/export.htm

    Once exported, please attach the file as an attachment to your reply.​
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      Thank you for your response, turns out it was something else. I was accessing Time[0] before the DataLoaded state, I have fixed the problem.

      Best,

      Billy

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      53 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X