Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bracket Orders

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

    Bracket Orders

    Hello,

    I have an issue with bracket orders. I send enter long limit orders and when are partially filled or total filled I send bracket orders.
    Normally works ok, but sometimes with a lot of contracts (and partially fillings) the orders are cancelled misteriously.

    I send to you a test.


    First, I send one enter long limit order. When is partially filled I send 1stop+1profit orders. Every bracket orders (1stop+1profit) have a unique name. In this moment all is correct.




    Second, a new enter long limit order (named BidOrder2) is filled. I send the corresponding bracket orders. In this moment all is correct.




    For testing, I change the price for the two profit orders linked to BidOrder1. No problem. It's ok.




    Continue ...
    Attached Files

    #2
    The first bracket orders are filled. The profit orders are filled and the stop orders are cancelled by NinjaTrader (not my code).








    The process is repeated again for every bid order.

    Normally is all ok, but sometimes some orders are cancelled misteriously. In the next image the bracket orders linked to BidOrder5 are cancelled when the first profit order is filled.




    Then my position is mistaken. I am into the market, but I haven´t any stop&profit orders living.





    I don´t understand why occurs this. ¿Could you help me, please?

    Thanks very much.

    Comment


      #3
      Hello,


      This is most likely in-flight execution, which is a risk of electronic trading. Please review this link:



      I suggest using TraceOrders() to sort out what is going on:
      DenNinjaTrader Customer Service

      Comment


        #4
        Thanks Ben, but I don't understand this NinjaTrader's behaviour.
        In this case, the bid order are 100 contracts and 96 !!! are cancelled. Is this the risk by in-flight execution ??? It's a risk very expensive.

        Here, I am long with 300 contracts ...



        Each BidOrder has some associated stop+profit orders.



        Then, one Profit order is filled and all associated orders are cancelled :




        Is this a risk by in-flight execution ???

        Thanks.

        PD: (I attach the trace file)
        Attached Files

        Comment


          #5
          cls71,

          It may or may not be. You need to evaluate it yourself through the use of TraceOrders = true. I suggest you simplify your strategy down significantly. Then you will need to slowly step through and watch the TraceOrders for all of your orders and determine what is triggering the cancellation of them. After that you just need to debug your code and address the cases that caused the cancellations.

          In this case, I have no idea how you are submitting your profit/stops, but you need to keep in mind, to scale-out you need to scale-in first.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            One question Josh, please;

            I am long in 950 with 100 contracts and I have these orders working:

            1 stop in 910 with 30 contracts
            1 profit in 1.000 with 30 contracts
            1 stop in 910 with 70 contracts
            1 profit in 1.000 with 70 contracts

            The four orders have the same FromEntrySignal parameter.
            Then, if the profit order 30contracts is filled ... does what happen ? :
            a) NT cancels the stop order (30contracts)
            or b) NT cancels the stop order (70contracts)

            What is the NT's logical for searching the associated order ?

            Thanks very much

            (I think this is the problem: some orders with the same FromEntrySignal parameter).

            Comment


              #7
              When profit 30 contract fills, everything else gets cancelled.

              30 stop
              70 profit
              70 stop

              All cancelled. This is what I mean by you need to scale-in to scale-out. Now I reviewed this thread again and you mention you are getting all of these profit/stops due to partial fills so under your scenario you cannot scale-in first. To address this you need to be using "By strategy position" instead of "Per entry execution". Go to Tools->Options->Strategies->NinjaScript and under "Order handling" for "Stop & target submission" select "By strategy position".
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Thanks Josh, but "By strategy position" doesn´t work. My strategy only send Longs and ... I am short sometimes with "By stategy position" selected. ???

                ...


                when I send profit & stop orders and they are working or accepted ... they "are" in the "broker". These orders are out of my strategie's logic. They are filled by the broker or NinjaTrader (now I am running the simulator datafeed). My code doesn't fill neither cancel any order. I'd like know why some orders are cancelled "misteriously".

                Well, I have found in the Help this text about "Per entry execution":
                <LI class=rvps1>Downside is that if your strategy trades large volume and you receive a lot of partial fills, the strategy will be managing a lot of live orders, the more orders the more potential things that can go wrong
                ... things that can go wrong ??? ... Could I know what things ???

                I am managing correctly all my orders in order arrays. Each order (enter, profit, stop) is a new order object, and it is saved into an array. I am debugging with VS and checking the order state and all is ok ... until a random profit order is filled and all orders associated to his EnterOrder are cancelled. I think that is well explained in the post with the images.

                (Sorry, but my english skill is low and I don't explain correctly)

                Regards

                Comment


                  #9
                  Not sure why you are having difficulties with "By strategy position". "By strategy position" just means your profit/targets will be submitted as one order for your single entry order provided you are using Set() methods. Anything that goes wrong from just submitting a long you will need to debug out your strategy.

                  Like I have mentioned earlier, you cannot use "Per entry execution".
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Thanks Josh, but I am not using SetProfitTarget neither SetTrailStop. I only use EnterLongLimit, ExitLongLimit and ExitLongStop (my strategy is only Long). I check the partial filled and I send the bracket orders that correspond them, each order with its unique name. (Each order is a new object).

                    Well, I will use the OnPositionUpdate event for putting rigth the position (... again).

                    Regards

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    572 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    331 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    101 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    549 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    550 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X