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 futurenow, 12-06-2021, 05:49 PM
            19 responses
            969 views
            0 likes
            Last Post Redders
            by Redders
             
            Started by Josephina55, 06-14-2025, 06:30 PM
            0 responses
            16 views
            0 likes
            Last Post Josephina55  
            Started by mathfrick2023, 05-08-2025, 12:51 PM
            8 responses
            77 views
            0 likes
            Last Post Yogaman
            by Yogaman
             
            Started by several, 04-22-2025, 05:21 AM
            2 responses
            249 views
            0 likes
            Last Post Lukasxgtx  
            Started by cherkoul, 06-12-2025, 11:21 PM
            0 responses
            18 views
            0 likes
            Last Post cherkoul  
            Working...
            X