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

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:	87
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:	67
Size:	7.4 KB
ID:	1193054

    And the following error
    Click image for larger version

Name:	220309 c.JPG
Views:	73
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.
    Kate W.NinjaTrader Customer Service

    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 geddyisodin, Today, 05:20 AM
      3 responses
      20 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by lorem, Today, 09:18 AM
      1 response
      5 views
      0 likes
      Last Post lorem
      by lorem
       
      Started by bmartz, Today, 09:30 AM
      0 responses
      5 views
      0 likes
      Last Post bmartz
      by bmartz
       
      Started by GussJ, 03-04-2020, 03:11 PM
      14 responses
      3,245 views
      0 likes
      Last Post GussJ
      by GussJ
       
      Started by ArkansasClint, Today, 09:28 AM
      0 responses
      2 views
      0 likes
      Last Post ArkansasClint  
      Working...
      X