Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on calling 'OnExecution'

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

    Error on calling 'OnExecution'

    What's the cause ? What's the fix ?

    8/26/2016 8:39:55 AM
    Strategy Error on calling 'OnExecution' method for strategy 'bgw_a1_OR_Trade_WIPTemp/bbbd8ba248c04ba6a26359eb31aa8e5f': Object reference not set to an instance of an object.

    I've attached the "Log".

    Thanks,
    Bruce
    Attached Files

    #2
    Hello Bruce,

    The error means that something was called that was null.

    The fix is to check for null before calling a value (that can be null).

    For example if you are checking the state of an order:

    private IOrder myOrder;

    if (myOrder != null && myOrder.OrderState == OrderState.Filled)
    {
    // execute code
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      OK, thanks.

      So something like forgetting to put this " CancelOrder(ORTrdMac4StopOrder); "
      but remembering to set to 'null', like this " ORTrdMac4StopOrder = null; "
      would also cause of my error message, duh . . .

      Comment


        #4
        Hello BGWTEX,

        You'll want to make sure that ORTrdMac4StopOrder is not null before calling CancelOrder() on it.
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Thanks ZacharyG, I got that part. But I got to wondering . . .

          Is it OK to set to null, ORTrdMac4StopOrder = null; right after the CancelOrder(), CancelOrder(ORTrdMac4StopOrder); ? I guess it is, looks like I've been doing it.

          Comment


            #6
            Hello BGWTEX,

            Yes, you can set ORTrdMac4StopOrder to null after calling CancelOrder() on it.
            Zachary G.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by PaulMohn, Today, 03:49 AM
            0 responses
            3 views
            0 likes
            Last Post PaulMohn  
            Started by inanazsocial, Today, 01:15 AM
            1 response
            7 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  
            Working...
            X