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 inanazsocial, Today, 01:15 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by rocketman7, Today, 02:12 AM
      0 responses
      10 views
      0 likes
      Last Post rocketman7  
      Started by dustydbayer, Today, 01:59 AM
      0 responses
      2 views
      0 likes
      Last Post dustydbayer  
      Started by trilliantrader, 04-18-2024, 08:16 AM
      5 responses
      23 views
      0 likes
      Last Post trilliantrader  
      Started by Davidtowleii, Today, 12:15 AM
      0 responses
      3 views
      0 likes
      Last Post Davidtowleii  
      Working...
      X