Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancel Order Using Managed Approach

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

    #16
    That's saying that the object order, raised by OnOrderUpdate, matches your myEntryOrder object. "order" is used as it's descriptive for the type of object you're working with, but you can use anything there.

    This does the same thing:
    protected override void OnOrderUpdate(IOrder cupCake)
    {
    if (myEntryOrder != null && myEntryOrder == cupCake)
    Ryan M.NinjaTrader Customer Service

    Comment


      #17
      Gotcha. Thanks for the excellent help

      Comment


        #18
        Ryan, how could you do this with an ATM strategy? Leaving everything else the way it is now. When I try to compile, the line for myEntryOrder which creates the strategy ID will return the error: "Cannot implicitly convert type 'bool' to NinjaTrader.Cbi.IOrder'

        protected override void OnBarUpdate()
        {

        if ((myEntryOrder == null)
        && CrossAbove(Close, EMA(LengthMA), 1)

        {
        atmStrategyId = GetAtmStrategyUniqueId();
        orderId = GetAtmStrategyUniqueId();
        myEntryOrder = AtmStrategyCreate(Cbi.OrderAction.Buy, OrderType.Limit, (Close[0] ), 0, TimeInForce.Day, orderId, "myatmtemplatename", atmStrategyId);
        barNumberOfOrder = CurrentBar;
        }

        //Cancels Limit order************************************
        if ((myEntryOrder != null) &&(CurrentBar > barNumberOfOrder + 7))
        {
        CancelOrder(myEntryOrder);

        }
        }

        //ON ORDER UPDATE BELOW
        protected override void OnOrderUpdate(IOrder order)
        {
        if (myEntryOrder != null && myEntryOrder == order)
        {
        // Reset the entryOrder object to null if order was cancelled without any fill
        if (order.OrderState == OrderState.Filled || order.OrderState == OrderState.Cancelled)
        {
        myEntryOrder = null;
        }
        }

        }

        Comment


          #19
          You won't be able to use IOrders the same with an ATM strategy. You need the ATM methods for this.



          Ryan M.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          60 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          147 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          97 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          284 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X