Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is there a reason why my target order would not be placed

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

    Is there a reason why my target order would not be placed

    Hi,

    This is my code where my entry is filled in OnBarUpdate and the target order is in OnExecution as follows;

    Code:
    protected override void OnExecution(IExecution execution)
            {
                /* We advise monitoring OnExecution() to trigger submission of stop/target orders instead of OnOrderUpdate() since OnExecution() is called after OnOrderUpdate()
                which ensures your strategy has received the execution which is used for internal signal tracking.
                
                This first if-statement is in place to deal only with the short limit entry. */
                if (entryOrder != null && entryOrder.Token == execution.Order.Token)
                {
                    // This second if-statement is meant to only let fills and cancellations filter through.
                    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
                    {    
                        // Simple target
                        targetOrder = ExitLongLimit(0, true, 1, execution.Price + 1 * TickSize, "target", "long entry");
                        
                        double myExecutionPrice = execution.Price;
                        //Print(myExecutionPrice.ToString());
                        
                        // Resets the entryOrder object to null after the order has been filled
                        if (execution.Order.OrderState != OrderState.PartFilled)
                        {
                            entryOrder     = null;
                        }
                    }
                }
                
                // Reset our stop order and target orders' IOrder objects after our position is closed.
                if ((stopOrder != null && stopOrder == execution.Order) || (targetOrder != null && targetOrder == execution.Order))
                {
                    if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled)
                    {
                        stopOrder = null;
                        targetOrder = null;
                    }
                }
            }

    #2
    suprsnipes, you're working on NT7 here correct? Then please also use the NT7 targetted sample framework and recheck - http://www.ninjatrader.com/support/f...ead.php?t=7499

    You also want to make sure the signal names are correct - how is your entry order exactly named?

    Comment


      #3
      This fixed it but I'm not entirely sure how?

      Code:
      targetOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 1 * TickSize, "target", "long entry");
      suprsnipes

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      647 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      368 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      108 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      571 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      573 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X