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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X