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

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.


    JesseNinjaTrader Customer Service

    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.



        JesseNinjaTrader Customer Service

        Comment


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

          Click image for larger version

Name:	msg.png
Views:	56
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.
            JesseNinjaTrader Customer Service

            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 &&.

                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by llanqui, Today, 03:53 AM
                0 responses
                6 views
                0 likes
                Last Post llanqui
                by llanqui
                 
                Started by burtoninlondon, Today, 12:38 AM
                0 responses
                10 views
                0 likes
                Last Post burtoninlondon  
                Started by AaronKoRn, Yesterday, 09:49 PM
                0 responses
                15 views
                0 likes
                Last Post AaronKoRn  
                Started by carnitron, Yesterday, 08:42 PM
                0 responses
                11 views
                0 likes
                Last Post carnitron  
                Started by strategist007, Yesterday, 07:51 PM
                0 responses
                14 views
                0 likes
                Last Post strategist007  
                Working...
                X