Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bracket Orders and PerEntryExecution

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

    Bracket Orders and PerEntryExecution

    Hello,

    I have the following problem:


    I send 1.000 contracts in a limit buy order by:

    Code:
     
    entryOrder = EnterLongLimit(0, true, 1000, 2450, "*- Long 01-*");

    When is filled into the OnExecution method, I send a bracket order: profit + stop by;

    Code:
     
    stopOrder = ExitLongStop( 0, true, execution.Order.Filled, execution.Order.LimitPrice - sizeStop, execution.Order.Name + " StopSec", execution.Order.Name );
     
    profitOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.LimitPrice + sizeProfit, execution.Order.Name + " ProfitSec", execution.Order.Name );
    There may be partial filling of the LimitOrder, which means that there will be several performances of the method OnExecution, but in the end everything is correct:
    one StopOrder for 1000 contracts and one ProfitOrder for 1000 contracts.

    Well, if the price rises and the profit order is partially filled (eg. 250 contracts) the stop order is completely cancelled.

    I am using "PerEntryExecution". Why doesn't work correctly ?

    Thanks

    #2
    cls71, thanks for the post - how does your code cancel the stops? Would it do so also on a partfilled state like in the OnOrderUpdate sample? Did you check with TraceOrders why your Stop gets cancelled in this state?

    Comment


      #3
      Hello Bertrand,

      the message in the trace is this:

      Code:
       
      17/07/2009 14:51:46 Cancelled pending exit order, since associated position is closed: Order='198f59d5a5d646139950da445f770a54/Sim101' Name='*-Long01-* StopSec' State=Accepted Instrument='VCTICK 09-09' Action=Sell Limit price=0 Stop price=1090 Quantity=1.000 Strategy='ZsTutorialOrdersBracket' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='198f59d5a5d646139950da445f770a54' Gtd='01/12/2099 0:00:00'
      but my position is not closed. The profilOrder is partially filled. Mi position is open.

      Thanks.

      Edit: I don't use the OnOrderUpdate() method.
      Last edited by cls71; 07-17-2009, 07:08 AM.

      Comment


        #4
        Thanks cls71, could you please post your code so we can take a look?

        Comment


          #5
          Hello Bertrand.

          This code is an example with two entry orders.

          When the profitOrder from the first entryOrder is filled, all orders are cancelled.
          Attached Files

          Comment


            #6
            Thanks cls71 - when I testdrive your script here, it immediately gets terminated as you attempt to place sell stop orders above the market, which results in order rejections.

            If you check the TraceOrders output you see that you already have 'a matching exit order in place', so I would suggest you also add unique ToString()'s for each of your stops and targets and recheck this.

            Comment


              #7
              First Step

              ok, I post the steps for reproducing the problem:


              1.- Load the script:




              2.- When the price falls then the entryOrders are filled and the brac****rders (profits + stops) are submitted. All ok.



              3.- When the price rises and the first profitOrder is filled (or partial filled), then all other orders are inexplicably cancelled.



              I don't understand this behaviour. And I think that the code is correct (... if the fromEntrySignal has some purpose ).

              Thanks.
              Attached Files

              Comment


                #8
                Thanks for your detailed reply cls71, I could reproduce this on my end on the simulated feed - I'll clarify this with a coworker and post back on Monday.

                Comment


                  #9
                  ok Bertrand. Thanks.

                  Comment


                    #10
                    Hello Bertrand,

                    Have you been able to find some solution for this issue?

                    Thanks very much

                    Comment


                      #11
                      cls71,

                      Unfortunately this is a known bug. Please try using ByStrategyPosition.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        ok. will be this bug fixed in NT v.7 ?
                        Thanks.



                        Originally posted by NinjaTrader_Josh View Post
                        cls71,

                        Unfortunately this is a known bug. Please try using ByStrategyPosition.

                        Comment


                          #13
                          Yes cls71, we expect this to be fixed in NinjaTrader 7.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          633 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          364 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          105 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          567 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          568 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X