Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error when retrieving instrument type

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

    Error when retrieving instrument type

    Hello,

    Iam getting the error "Error on calling 'OnStateChange' method: Object reference not set to an instance of an object." with this line of code.

    if (PositionsAccount[0].Instrument.MasterInstrument.InstrumentType == InstrumentType.Forex)

    Is this syntax correct?

    Thanks

    #2
    Hello guillembm,
    Thanks for your post.

    PositionsAccount will not be accessible inside most of OnStateChange(). If you would like this logic to be inside OnStateChange() you will want to put it inside State.RealTime. Otherwise, you can put it inside OnBarUpdate().

    https://ninjatrader.com/support/help...tatechange.htm

    Please let me know if you have any questions.
    Josh G.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Graci117, Today, 09:02 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by ETFVoyageur, Today, 07:55 PM
    0 responses
    7 views
    0 likes
    Last Post ETFVoyageur  
    Started by janio973, Today, 07:24 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by aligator, 01-06-2022, 12:14 PM
    4 responses
    246 views
    0 likes
    Last Post john_44573  
    Started by reynoldsn, Today, 05:56 PM
    0 responses
    14 views
    0 likes
    Last Post reynoldsn  
    Working...
    X