Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Execution Interface

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

    Execution Interface

    Re. https://ninjatrader.com/support/help...er_methods.htm

    On the OnExecutionUpdate() event, is it correct to use

    If (execution.MarketPosition == MarketPosition.Long) ?


    #2
    Hello

    You can use that, that is a property of the event and the execution object.


    Comment


      #3
      ok thanks, do you see anything wrong with this statement ...

      if (execution.MarketPosition == MarketPosition.Long && (execution.Name == "long stop" || execution.Name == "long target" || execution.Name == "Exit on session close"))

      sample population (from visual studio debug) is:

      {execution='NT-00001-67' instrument='MES 12-22' account='Sim101' exchange=Default price=3906.5 quantity=1 marketPosition=Long orderId='NT-00002-67' time='2022-10-31 04:25:19' sod=False statementDate='0001-01-01'}
      Last edited by dibDab; 11-01-2022, 10:29 AM.

      Comment


        #4
        Hello dibDab,

        That's not really something I could answer as I don't have all the details, you can use Prints to identify if the values you are using are correct for the situation. You would need to output the variables you used there and see if that matches the condition you made.



        Comment


          #5
          doesn't like the "==" operator, same problem using execution.Order == OrderAction.BuyToCover

          Click image for larger version

Name:	msg.png
Views:	94
Size:	1.9 KB
ID:	1221753
          not sure what else to use?
          Last edited by dibDab; 11-01-2022, 11:30 AM.

          Comment


            #6
            Hello dibDab,

            The error is saying you are trying to compare an order vs an int which wouldn't be a comparison that you can do. An enum such as OrderAction.BuyToCover equates to an integer when used in a condition which is why you see that in the error. You are trying to compare an enum against an order object.

            The enum is named after the property it represents which is OrderAction, you would have to use execution.Order.OrderAction if you wanted to make that type of comparison.

            Comment


              #7
              apologies cut & paste error, I get "==" operator error with

              execution.Order.OrderAction == OrderAction.Sell & execution.MarketPosition == MarketPosition.Long

              in protected override void OnExecutionUpdate
              Last edited by dibDab; 11-01-2022, 12:16 PM.

              Comment


                #8
                Hello dibDab,

                In what you provided you only used one &, for a condition you need &&.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                54 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                130 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                71 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                44 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                49 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X