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 pibrew, Today, 06:10 PM
            0 responses
            4 views
            0 likes
            Last Post pibrew
            by pibrew
             
            Started by pibrew, 04-28-2024, 06:37 AM
            2 responses
            17 views
            0 likes
            Last Post pibrew
            by pibrew
             
            Started by Philippe56140, 04-27-2024, 02:35 PM
            7 responses
            56 views
            0 likes
            Last Post kevinenergy  
            Started by arunkumar3, 08-25-2023, 12:40 PM
            3 responses
            169 views
            0 likes
            Last Post Trader2024!  
            Started by DJ888, 04-26-2024, 10:57 PM
            2 responses
            17 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Working...
            X