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

Cancelled pending exit order, since associated position is closed,

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

    Cancelled pending exit order, since associated position is closed,

    Hello NT8 Forum,

    I'm developing a strategy that enters with 6 contracts, 4 are scalpers and 2 are runners. I have a single market order for the entry with quantity of 6. I handle the setup of partial fills until all 6 are filled. However, I'm getting some scalp target orders cancelled when I get partial fills. For example, with 2 entries and then 4 entries, the 4 target limit orders are set but when the first two targets are met the next two are getting canceled, leaving two position unaccounted for in my scalper logic. (The other two are handled by the runners logic.)
    I get this message in the cancelled order process: Cancelled pending exit order, since associated position is closed
    But, as explained, there are two remaining positions. Is this happening since 2 positions were filled by a separate order than the other 4?
    Even though I use the same Entry Signal Name, there are two Order ids for fulfillment. Therefore, when creating the TP orders (ExitLongLimit orders), the remaining two TP orders are getting canceled since one of the associated Order Ids have been completed with the 2 completed scalps. Is this correct?
    (Sorry, if that was clear as mud. )

    Thanks,
    Stealth

    #2
    Hello Stealth,

    If you are attempting to scale in, scale out, I recommend you use unique signal names and individual orders for each quantity that will be scaled.


    Cancelling an order would not close a position. Are you having trouble cancelling orders, are you having trouble with an exit order that was submitted that did not fill, or both?

    Use TraceOrders and Print() to see what orders are being submitted and filled, and include the output saved to a text file with your next post.

    Below is a link to a forum post that demonstrates using prints and TraceOrders to understand behavior.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      I recommend you use unique signal names and individual orders for each quantity that will be scaled.
      Yes, that is what I'm doing now. Rewriting my code to uniquely handle each contract. Thanks, Chelsea!

      Kind regards,
      Stealth

      Comment


        #4
        Hello Chelsea/NT8 Support,

        A quick follow up... As described above, I'm looking to set 4 scalping orders once my entry price is hit. I now have 4 unique entries (Entry Signal Names..."Scalp1", "Scalp2", etc). In the OnExecutionUpdate, which gets call for each order, I am trying to use SetProfitTarget and SetStopLoss. That is, I would like to set 4 sets of OCO Profit Target and Stop Loss orders each for the scalp entries. It doesn't appear that NT8 likes this since it creates each Profit Target and Stop Loss order with the same signal names ("Profit Target"/"Stop Loss"). Is what I'm trying to do possible?

        Thanks,
        Stealth

        Comment


          #5
          More info... For each scalp entry, I have the following code:

          SetProfitTarget(scalpTrades[i].EntrySignalName, CalculationMode.Price, scalpTrades[i].TargetPrice, false);
          SetStopLoss(scalpTrades[i].EntrySignalName, CalculationMode.Price, scalpTrades[i].StopLossPrice, false);

          So, I'm using the unique Entry Signal Name SetProfitTarget/SetStopLoss method call.

          Comment


            #6
            Hello Stealth,

            When using unique From entry signals with the exit orders, like SetStopLoss(), this will create a separate stop and target for each entry with a unique signal name.

            If you want 4 stop losses and profit targets use 4 unique entry signal names. Call SetStopLoss() 4 times with each unique signal name. 4 separate stop losses will be produced.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea,

              Thank you for confirming that should work. So, I did get it to work when I moved the SetProfitTarget and SetStopLoss calls immediately after the entry call in OnBarUpdate. Like this:

              Code:
              scalpTrades[i].EntryOrder = EnterShort(scalpTrades[i].Quantity, scalpTrades[i].EntrySignalName);
              SetProfitTarget(scalpTrades[i].EntrySignalName, CalculationMode.Ticks, (tpDelta / TickSize), false);
              SetStopLoss(scalpTrades[i].EntrySignalName, CalculationMode.Price, stopLossInitial, false);
              Before, I had these statements in the OnExecutionUpdate

              Code:
              SetProfitTarget(scalpTrades[i].EntrySignalName, CalculationMode.Ticks, (tpDelta / TickSize), false);
              SetStopLoss(scalpTrades[i].EntrySignalName, CalculationMode.Price, stopLossInitial, false);
              Also, for the Profit Target I was using CalculationMode.Price but the price that I was getting was 10 points off from the current price, not even with in the bar range. The same was happening for the Stop Loss entry. Very strange. Both issues were fixed when moving the calls to OnBarUpdate and then using Ticks for the Profit Target call.

              Thanks!
              Stealth

              Comment


                #8
                Hello StealthM93,

                Set methods should always be set or reset before the entry is called. These cannot be unset and will continue to use old information if not reset.

                See my ProfitChaseStopTrailSetMethodsExample_NT8 example which demonstrates.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you, Chelsea! That's what I'm now doing based on your comment, Set methods should always be set or reset before the entry is called. That aspect of my strategy is now working.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by algospoke, Yesterday, 06:40 PM
                  2 responses
                  23 views
                  0 likes
                  Last Post algospoke  
                  Started by ghoul, Today, 06:02 PM
                  3 responses
                  14 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by jeronymite, 04-12-2024, 04:26 PM
                  3 responses
                  45 views
                  0 likes
                  Last Post jeronymite  
                  Started by Barry Milan, Yesterday, 10:35 PM
                  7 responses
                  22 views
                  0 likes
                  Last Post NinjaTrader_Manfred  
                  Started by AttiM, 02-14-2024, 05:20 PM
                  10 responses
                  181 views
                  0 likes
                  Last Post jeronymite  
                  Working...
                  X