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

Ninjatrader orders and ATM

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

    Ninjatrader orders and ATM

    Hi Team,

    I'm working in an add-on to cancel orders based in a set of conditions. I'm not creating the order with the add-on. Only want to react with the orders that I put in the superdom and in the chart trader. I mean orders created with NinjaTrader.

    I need to have any special consideration related to order states? I ask this because i see that atm orders and with out it behave different. I know seems to be a general question, but if someone can hihglightme if theres is any special consideration. I try to code it, but get loops with phantom orders and with out being the creator of the orders I don't know if I'm missing something important. If someone knows wich are the states that need to take into account, sure will be helpfull.

    Cheers

    #2
    Hello Protech,

    Welcome to the forums!

    You can access an account's OrderUpdate event to see the order updates for that account.

    You can then interact with orders that have reached a state of Accepted or Working and the state can be referenced in the OrderUpdate event handler. Attempting to cancel orders outside of these states can lead to unexpected behavior.

    OrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

    The Strategy OnOrderUpdate method can be referenced for a list of OrderStates, their meaning and can give further insight for using OrderUpdate.

    OnOrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm

    Orders can then be cancelled with Account.Cancel.

    Account.Cancel - https://ninjatrader.com/support/help...nt8/cancel.htm

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hi NinjaTrader_Jim

      Thank you for your great answer. Last question on this. I have read all related with add-ons. About the example that is posted in the add-on section and related to the orders buttons. I readed about multithreading considerations. In this case with the buttons what someone is doing is creating the order. My question is:

      Taking the above scenario, I need to be aware of multithreading considerations if I don't create the order and only want to cancel orders created by NinjaTrader? Any insights about this will be really appreciated.

      Thank you for your time

      Comment


        #4
        Hello Protech,

        I would not expect to encounter multi threading issues if you check for orders in the OrderUpdate event that have reached an OrderState of Accepted/Working.

        I have not had any issues testing the following where my OnOrderUpdate method is subscribed to the OrderUpdate event from an account:

        Code:
        private void OnOrderUpdate(object sender, OrderEventArgs e)
        {
            if (e.OrderState == OrderState.Accepted)
                myAccount.Cancel(new [] { e.Order });
        }
        If you encounter a case where this is not working for you, please provide some small scripts that can be used to reproduce those symptoms so we can advise further.
        JimNinjaTrader Customer Service

        Comment


          #5
          Hi NinjaTrader_Jim
          Thank you so much for your answer. I have it clear now.

          Comment


            #6
            Hi NinjaTrader_Jim

            I'm trying to work with the ATM Strategy for Super Dom and other places in NinjaTrader. Want to play with the orders at this different states. How can I have access to the strategy created in the superdom (or chart trader) to manage it, I mean...cancel the order in the different states, If I need it? I try it in the help guide, but didn't find it.

            Cheers

            Comment


              #7
              Hello Protech,

              We will start to venture into unsupported territory here, but to accomplish, you will need to pick up on orders in OnOrderUpdate and then identify if they belong to an Atm strategy.

              I have an experimental script that you can use for some inspiration, but please do not think of it as a complete and official example.

              An undocumented method that may be helpful to experiment with would be Order.GetOwnerStrategy() to see if the order belongs to a strategy (Atm or NinjaScript.) The ATMStrategyMonitor example can give some direction for identifying if a strategy (StrategyBase) is an AtmStrategy.

              We look forward to assisting.
              Attached Files
              JimNinjaTrader Customer Service

              Comment


                #8
                Hi NinjaTrader_Jim

                This is why I like NinjaTader. You made my day. Thank you so much. A really inspirational help.

                Cheers

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by arvidvanstaey, Today, 02:19 PM
                4 responses
                11 views
                0 likes
                Last Post arvidvanstaey  
                Started by samish18, 04-17-2024, 08:57 AM
                16 responses
                59 views
                0 likes
                Last Post samish18  
                Started by jordanq2, Today, 03:10 PM
                2 responses
                9 views
                0 likes
                Last Post jordanq2  
                Started by traderqz, Today, 12:06 AM
                10 responses
                18 views
                0 likes
                Last Post traderqz  
                Started by algospoke, 04-17-2024, 06:40 PM
                5 responses
                47 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X