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 DJ888, 04-16-2024, 06:09 PM
            4 responses
            12 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by terofs, Today, 04:18 PM
            0 responses
            9 views
            0 likes
            Last Post terofs
            by terofs
             
            Started by nandhumca, Today, 03:41 PM
            0 responses
            6 views
            0 likes
            Last Post nandhumca  
            Started by The_Sec, Today, 03:37 PM
            0 responses
            3 views
            0 likes
            Last Post The_Sec
            by The_Sec
             
            Started by GwFutures1988, Today, 02:48 PM
            1 response
            9 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Working...
            X