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

  • StealthM93
    replied
    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.

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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.
    https://ninjatrader.com/support/foru...269#post802269

    Leave a comment:


  • StealthM93
    replied
    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

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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.

    Leave a comment:


  • StealthM93
    replied
    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.

    Leave a comment:


  • StealthM93
    replied
    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

    Leave a comment:


  • StealthM93
    replied
    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

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    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.
    https://ninjatrader.com/support/foru...121#post791121

    Leave a comment:


  • 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

Latest Posts

Collapse

Topics Statistics Last Post
Started by ezrollin, Today, 08:51 PM
1 response
21 views
0 likes
Last Post bltdavid  
Started by Rubix, Today, 09:31 PM
0 responses
14 views
0 likes
Last Post Rubix
by Rubix
 
Started by ark321, Today, 05:12 PM
1 response
21 views
0 likes
Last Post NinjaTrader_EricB  
Started by futurenow, Today, 09:08 PM
0 responses
4 views
0 likes
Last Post futurenow  
Started by fafafdenis, Today, 04:56 PM
1 response
5 views
0 likes
Last Post NinjaTrader_EricB  
Working...
X