Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order is in a state that prohibit using it as a compound leg

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

    Order is in a state that prohibit using it as a compound leg

    I have a strategy that needs to modify orders quickly. It is running on each tick. Often I get the following error in fast moving markets when it modifies a limit Buy or Sell order with SetProfitTarget and SetStopLoss.

    Order is in a state that prohibits using it as a compound leg. Affected Order: Sell 1 Limit @ 6015.75
    How do I prevent this error or double check for it?
    How do I determine if it is profit Target or the Stop loss order that is causing it?

    I have already set RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors
    and I am double checking my entry order modification like so below



    Code:
    private bool IsSameOrderPrice(Order entryOrder, double newPrice)
    {
    // Check if the order is not null and is in a working state
    if (entryOrder == null || entryOrder.OrderState != OrderState.Working)
    {
    return false; // No valid order exists
    }
    
    // Compare the current limit price with the desired new price
    return entryOrder.LimitPrice == newPrice;
    }​
    
    
    _entryLimitOrder = EnterLongLimit(PosSize, entryPrice, EntryLimitLongName);
    
    SetProfitTarget(EntryLimitLongName, CalculationMode.Price,targetPrice);
    SetStopLoss(EntryLimitLongName, CalculationMode.Price,stopPrice,true);​

    #2
    Hello cutzpr,

    This error may be indicating the profit target is being filled before the stop loss can be accepted.

    Note, Set methods are intended to be called before calling an entry order method.

    Please see the forum post linked below.


    May I confirm the targetPrice variable is at least a few ticks greater than the current bid at the exact moment the SetProfitTarget() method is called?
    May I confirm the stopPrice variable is at least a few ticks lower than the current bid at the exact moment the SetStopLoss() method is called?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea,

      Thank you for your responce. I placed the TP and SL before the entry order to see if it would solve the issue. If it doesn't I will dive a bit deeper.

      Comment


        #4
        Hello cutzpr,

        May I confirm the targetPrice variable is at least a few ticks greater than the current bid at the exact moment the SetProfitTarget() method is called?
        May I confirm the stopPrice variable is at least a few ticks lower than the current bid at the exact moment the SetStopLoss() method is called?​
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Chelsea,
          The targetPrice and the stopPrice variable were one tick away from its currents current price when I was trying to modify the order. But it seems place the set methods before the modification of the entrylimit price and order fixed the issue.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          65 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          40 views
          0 likes
          Last Post PaulMohn  
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          166 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          101 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          162 views
          2 likes
          Last Post CaptainJack  
          Working...
          X