Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple exits

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

    Multiple exits

    I've got a strategy that orders long 2 contracts and I would like to exit them with 2 different targets.
    I'm using the OnOrderUpdate for more precision (and the latest beta).

    My problem is when my first target is hit, my stop order is cancelled (which is fine because I want the stop to be moved to breakeven, but I can't submit any new stop order?

    Trace order message:
    15/02/2008 10:02:22 Ignored PlaceOrder() method: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=7014.0 SignalName='' FromEntrySignal='' Reason='This was an exit order but no position exists to exit'

    And I still have a position on 1 contract...

    I would like to know if there is a workaround this or if I should break my entry in 2 orders (in that case my order would be submit as 2 buy orders of 1 contract or 1 buy order of 2?).

    Thanks

    #2
    Someone will follow up to this within the next day.
    RayNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Ray View Post
      Someone will follow up to this within the next day.
      Any news?

      Thanks

      Comment


        #4
        Not yet. Sorry, team has been out in NY for Traders Expo, you should see a response by tomorrow.
        RayNinjaTrader Customer Service

        Comment


          #5
          Ok no worries. Thanks

          Comment


            #6
            Hi ryker,

            For multiple exits there are several approaches you can take. The splitting your order in two approach is outlined in this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=3751

            If you wish to continue the approach you were originally trying please check out this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=3917

            Basically you do not need to use SetStopLoss() or SetProfitTarget(). Handle the OCO manually through your NinjaScript so your stop order won't be cancelled.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by Josh View Post
              Hi ryker,

              For multiple exits there are several approaches you can take. The splitting your order in two approach is outlined in this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=3751

              If you wish to continue the approach you were originally trying please check out this reference sample: http://www.ninjatrader-support.com/v...ead.php?t=3917

              Basically you do not need to use SetStopLoss() or SetProfitTarget(). Handle the OCO manually through your NinjaScript so your stop order won't be cancelled.
              Josh,
              Thanks for your answer. I'd like to continue the way I've started but I do not use any SetStopLoss or ProfitTarget, I try to handle everything manually.

              My stop loss:
              Code:
               
              [FONT=Courier New][SIZE=2]stopOrder = ExitLongStop([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], order.Filled, stopPrice, [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"Stop"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], order.FromEntrySignal);[/SIZE][/FONT]
              is cancelled as soon as the target is hit and then I'm not able to set any stop loss or new target for the remaining of the position (using the same way). I tried various settings and this still doesn't work as expected... I might have missed something obvious though ...

              Comment


                #8
                If you could post a simple as possible strategy demonstrating your issue maybe I can further assist. It is hard to fully grasp your current implementation with only one line of code.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  It looks like it's working now (tried to post an example of the problem and managed to solve it while preparing the piece of code).

                  Thanks for your help.

                  Comment


                    #10
                    Thanks for reporting back. Glad it is resolved for you.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Actually I think I found some hints for my problem, it is when my order has a partial fill.
                      For a buy of 2 contracts, I have a buy order and another buy order, I'm not sure how to handle that, as it looks like to me that if I try to enter another stop order it will be cancelled, any ideas on how to handle those situations?

                      Thanks
                      Last edited by ryker; 02-25-2008, 01:35 PM.

                      Comment


                        #12
                        Could this part of the code you wrote (I'm using it as a reference):
                        // Resets the entryOrder object to null after the order has been filled or partially filled
                        entryOrder = null;

                        could cause the problem I see?

                        PS: I've attached an example of how I manage scaling out of a position.

                        Thanks
                        Attached Files
                        Last edited by ryker; 02-25-2008, 02:23 PM.

                        Comment


                          #13
                          In your code you should have no problem detecting a partial fill with the use of the IOrder object. When you detect the fill has changed you can just cancel your old stop order and place a new one that will cover your entire position.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Just to be clear the IOrder object should not change if my order has been partially filled and then fill completely?
                            That would be appreciated to have some examples on how to handle partial fills as I can't find any.

                            Thanks

                            Comment


                              #15
                              Originally posted by Josh View Post
                              In your code you should have no problem detecting a partial fill with the use of the IOrder object. When you detect the fill has changed you can just cancel your old stop order and place a new one that will cover your entire position.
                              My problem is mostly when I've got a partial fill and a complete fill, then if my first target is hit I try to move my stop to breakeven but my order is ignored: 'This was an exit order but no position exists to exit'.

                              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