Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unhandled exception: Object Rererence set to an instance of an object

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

    Unhandled exception: Object Rererence set to an instance of an object

    Good morning:
    I have an add-on based on the “AddOnShell (No tabs)” example provided in the forum.
    In one of the CheckBox fields I have the following code:Click image for larger version

Name:	220309 a.JPG
Views:	120
Size:	46.7 KB
ID:	1193053

    When I click the checkbox being flat in any position the following is shown in the NinjaScriptOutput:
    Click image for larger version

Name:	220309 b.JPG
Views:	99
Size:	7.4 KB
ID:	1193054

    And the following error
    Click image for larger version

Name:	220309 c.JPG
Views:	105
Size:	11.1 KB
ID:	1193055

    Due to the messages in the output window I know that the error comes in the line 485
    Question:
    How can I workaround this? taking in mind that when I am in a position the `if´ works perfectly?

    Thank you very much!!

    #2
    Hello efeuvejota01,

    Thank you for your post.

    The most likely culprit here would be that the position object is null. Are you assigning position a value in OnPositionUpdate?



    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Thank you Kate!!
      I changed the line for
      " if ((position == null) || (position.MarketPosition!=MarketPosition.Flat))"
      and now is working as intended.
      Thank you

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      571 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      331 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      549 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      550 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X