Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Not all executions will have associated IOrder objects

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

    Not all executions will have associated IOrder objects

    Hi all,

    This question refers to the methods and properties of iExecution():

    http://www.ninjatrader.com/support/h...iexecution.htm

    Within OnExecution(), I am using execution.Order to test which of my stop types was actioned as an exit:

    Code:
    stopOrder != null && stopOrder == execution.Order
    This seems to work properly for some stops but not others (unless I have a bug of my own making of course). A clue to my issue I believe is the following statement from the help guide:

    Not all executions will have associated IOrder objects
    Would I be correct in thinking that only stops that are placing orders prior to execution have iOrder objects associated with them? Say my iOrder is called stopOrder, then for example stopOrder = ExitLongStop("myLongStop"...) would have an iOrder but stopOrder = ExitLong("myLongExit"...) would not.

    As a result of this, in order to capture both types of stop listed here, should I instead change my test in OnExecution() to something like:

    Code:
    stopOrder != null && stopOrder.Name == execution.Name
    Thanks in advance,
    darmbk.

    #2
    Hello Darmbk,

    Set() orders and ExitOnClose would not have an IOrder object.

    Additionally, stopOrder = ExitLong("myLongExit"...) is a market order and would go through as filled and would most likely not return the IOrder that you want for it.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hi Cal,

      So would I be able to use Name as a reference as I suggest instead of iOrder object?

      Thanks,
      darmbk.

      Comment


        #4
        Yes, the name check will match the IOrder name against the execution's order name.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by darmbk View Post
          Hi all,

          This question refers to the methods and properties of iExecution():



          Within OnExecution(), I am using execution.Order to test which of my stop types was actioned as an exit:

          Code:
          stopOrder != null && stopOrder == execution.Order
          This seems to work properly for some stops but not others (unless I have a bug of my own making of course). A clue to my issue I believe is the following statement from the help guide:



          Would I be correct in thinking that only stops that are placing orders prior to execution have iOrder objects associated with them? Say my iOrder is called stopOrder, then for example stopOrder = ExitLongStop("myLongStop"...) would have an iOrder but stopOrder = ExitLong("myLongExit"...) would not.

          As a result of this, in order to capture both types of stop listed here, should I instead change my test in OnExecution() to something like:

          Code:
          stopOrder != null && stopOrder.Name == execution.Name
          Thanks in advance,
          darmbk.
          The documentation is a bit simplistic on that point. I understand what it was trying to say. Unfortunately it is not quite correct. Every execution does have an associated IOrder. It is just that some of them are not directly exposed; as, for example those that come from Set() orders.

          However, there is an associated IOrder. This example shows how to access said IOrder: http://www.ninjatrader.com/support/f...ead.php?t=5790

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by r68cervera, Today, 05:29 AM
          0 responses
          2 views
          0 likes
          Last Post r68cervera  
          Started by geddyisodin, Today, 05:20 AM
          0 responses
          3 views
          0 likes
          Last Post geddyisodin  
          Started by JonesJoker, 04-22-2024, 12:23 PM
          6 responses
          33 views
          0 likes
          Last Post JonesJoker  
          Started by GussJ, 03-04-2020, 03:11 PM
          12 responses
          3,239 views
          0 likes
          Last Post Leafcutter  
          Started by AveryFlynn, Today, 04:57 AM
          0 responses
          6 views
          0 likes
          Last Post AveryFlynn  
          Working...
          X