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 janefoster, Yesterday, 11:50 PM
            0 responses
            2 views
            0 likes
            Last Post janefoster  
            Started by kaywai, 07-13-2024, 09:05 PM
            3 responses
            25 views
            0 likes
            Last Post kaywai
            by kaywai
             
            Started by stafe, Yesterday, 01:32 PM
            2 responses
            19 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by Jakub, Yesterday, 11:06 AM
            2 responses
            24 views
            0 likes
            Last Post ashpang
            by ashpang
             
            Started by MatthewLesko, 05-21-2021, 09:37 PM
            4 responses
            167 views
            0 likes
            Last Post Mahmad1323  
            Working...
            X