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

    I'm working on a strategy and ramdomly i start to have this error in some charts but not in others, where, as far as i can tell, the only difference is the Forex pair i use.

    The error says "Unhandled exception: Object reference not set to an instance of an object.

    As you can see in the images attached, i show my workspace, first with the Ninjascripts reloaded in the four charts. The strategy is the same for all the charts.

    As you can see the strategy loads two buttons and a quantity selector and displays the status "Waiting for realtime data". At this state, the buttons are disabled, as they are only enabled when a specific condition is met. The quantity selector appears enabled with a 10 as a default value.

    When i select with the mouse the quantity selector and change its value with the mouse wheel to 9, in this example, in two of the charts a get the error, while in the other two the strategy works and as part of the strategy displays some additional information. If conditions were met and one of the buttons were enabled and cliked, the error is the same.

    Wierd thing is that if in an errored chart i change the pair to a working pair, the strategy works normally and when i change back to the failed pair, the strategy begins to fail again.

    At some point in the past, i deleted _Workspaces.xml and even changed workspaces, but now as you can see in the file new workspace and new workspace one error one good images, sometimes it works for a chart and sometimes it does not.

    Can you please help me understand and fix what is going on? If error were the same in all charts, no matter what the pair, nor the workspace, i would say it is the strategy code, but it is so wierd that i cannot figure it out.

    Please help.

    Thank you and best regards,

    RoBott.
    Attached Files

    #2
    Hello RoBott,

    I would recommend debugging the script to find the exact object that is null.

    You could start by commenting out all logic until the error stops, and then un-comment code one line at a time until the error returns to find the line with the null object.

    You could also use prints every few lines to see which print is the last appearing before the error is hit.

    Below is a link to a post on using prints.


    What is the line of code that is causing the error?
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X