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 StockTrader88, 03-06-2021, 08:58 AM
                44 responses
                3,966 views
                3 likes
                Last Post jhudas88  
                Started by rbeckmann05, Today, 06:48 PM
                0 responses
                4 views
                0 likes
                Last Post rbeckmann05  
                Started by rhyminkevin, Today, 04:58 PM
                4 responses
                54 views
                0 likes
                Last Post dp8282
                by dp8282
                 
                Started by iceman2018, Today, 05:07 PM
                0 responses
                5 views
                0 likes
                Last Post iceman2018  
                Started by lightsun47, Today, 03:51 PM
                0 responses
                8 views
                0 likes
                Last Post lightsun47  
                Working...
                X