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

Remove multiple orders / unmanaged approach

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

    Remove multiple orders / unmanaged approach

    Hello,

    I have multiple stop orders in the order tab. These were submitted by a strategy with an unmanaged approach.

    Is it possible somehow that I cancel the stop orders that are related to a specific symbol e. g. 5 orders out of 6 orders using a loop?

    Kind regards
    Gerik




    #2
    Hello Gerik,

    Are you asking how to do this as a regular action that your script would need to take or are the orders currently stuck/needing manually managed?

    Managing orders from outside the strategy will in some cases disable the strategy in case the position is closed. If this is something the strategy should regularly have happen then the best way would be to add a custom button or condition to trigger that action from the strategy its self. The strategy would have the full details on those orders already and by managing the position its self it can stay enabled. If you otherwise infrequently need to do this, don't mind the strategy being disabled an addon could be used to loop over an accounts order collection.

    Could you provide a bit more detail on the overall goal so that I can point out the correct info for the use case?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      thank you for your mail. A custom button I have already implemented. In the next step, I would like my script to double-check as a regular action whether there are already sell stop limit orders generated by the strategy.

      I have experienced situations where e.g. more than one stop order is visible. If that is the case I would like to cancel the remaining orders and just change the limit of one remaining stop limit order using ChangeOrder(). The objective would be to avoid that more orders are executed than initially intented, because there are just some residual orders.

      How can I loop over an accounts order collection and fetch, check and delete the stop orders?

      Kind regards
      Gerik

      Comment


        #4
        Hello Gerik,

        I would like my script to double-check as a regular action whether there are already sell stop limit orders generated by the strategy.

        With the managed or unmanaged approach you would need to track the orders you submit on your own using the OnOrderUpdate or OnExecutionUpdate events. By storing the orders as variables you can later cancel or change them when needed.

        There is a simple example of storing orders and calcelling them in the following post, the same concept would apply in your situation. You would store each unique order to its own variable and later use that variable to manage that order.


        By doing individual variables you don't need to worry about loops or collections. You can certainly make the code more complex and use a List<Order> if you wanted to store the observed orders to a collection for accessing them later.



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello Jesse,

          thank you for your message.

          I am tracking the orders already with the unmanaged approach using individual variables with the given sample script.

          However, there are situations when there is more than one stop order in the orderbook although having only one variable trailingStopLong.

          Is it somehow possible to look for any residual stop limit orders? I would guess if there are e.g. two stop limit orders that came from the strategy having the same name, it should be possible to fetch them again somehow.

          Sincerely
          Gerik

          Comment


            #6
            Hello Gerik,

            If you have the variables for the orders you could add a condition to check if each order is still working or filled. Instead of looping you would just have 4 conditions if you have 4 orders as an example.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            10 responses
            1,413 views
            0 likes
            Last Post Traderontheroad  
            Started by firefoxforum12, Today, 08:53 PM
            0 responses
            8 views
            0 likes
            Last Post firefoxforum12  
            Started by stafe, Today, 08:34 PM
            0 responses
            10 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by sastrades, 01-31-2024, 10:19 PM
            11 responses
            168 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by kmunroe478, Today, 05:39 PM
            0 responses
            6 views
            0 likes
            Last Post kmunroe478  
            Working...
            X