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

Issue after cancelling order

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

    Issue after cancelling order

    Hello everyone. I would like to know of anyone could help me. After I cancel a limit order, the system is not recognizgin new entry signals. Hence, I cannoy enter the amrjet again. Here is wht Ninjaout shows:

    [ALQUIMIAStrategy 2][09/21/2021 08:16:00 AM] Bar count Abv/Bel 200EMA: 14, EMA20-EMA200: 11.529, EMA200: 15110.25, slope200ma: 0.15, BarsSinceExit: 14 Day Sess: True, Aft Sess: True, Steps: 1
    [ALQUIMIAStrategy 2][09/21/2021 08:16:00 AM] Bar count Abv/Bel 200EMA: 14, EMA20-EMA200: 11.55, EMA200: 15110.25, slope200ma: 0.15, BarsSinceExit: 14 Day Sess: True, Aft Sess: True, Steps: 1
    [ALQUIMIAStrategy 2][09/21/2021 08:16:00 AM] Bar count Abv/Bel 200EMA: 14, EMA20-EMA200: 11.55, EMA200: 15110.25, slope200ma: 0.15, BarsSinceExit: 14 Day Sess: True, Aft Sess: True, Steps: 1
    [ALQUIMIAStrategy 2][09/21/2021 08:16:00 AM] Bar count Abv/Bel 200EMA: 14, EMA20-EMA200: 11.55, EMA200: 15110.25, slope200ma: 0.15, BarsSinceExit: 14 Day Sess: True, Aft Sess: True, Steps: 1
    [ALQUIMIAStrategy 2][09/21/2021 08:16:00 AM] Bar count Abv/Bel 200EMA: 14, EMA20-EMA200: 11.55, EMA200: 15110.25, slope200ma: 0.15, BarsSinceExit: 14 Day Sess: True, Aft Sess: True, Steps: 1
    [ALQUIMIAStrategy 2][09/21/2021 08:16:00 AM] Bar count Abv/Bel 200EMA: 14, EMA20-EMA200: 11.55, EMA200: 15110.25, slope200ma: 0.15, BarsSinceExit: 14 Day Sess: True, Aft Sess: True, Steps: 1
    [ALQUIMIAStrategy 2][09/21/2021 08:16:00 AM] Bar count Abv/Bel 200EMA: 14, EMA20-EMA200: 11.571, EMA200: 15110.25, slope200ma: 0.15, BarsSinceExit: 14 Day Sess: True, Aft Sess: True, Steps: 1
    [TRADE][09/21/2021 08:16:00 AM][ALQUIMIAStrategy 2] [MNQ 12-21] Cancel OLD entry limit Order

    [TRADE][09/21/2021 08:16:00 AM][ALQUIMIAStrategy 2] [MNQ 12-21] Cancel OLD entry limit Order

    [TRADE][09/21/2021 08:16:00 AM][ALQUIMIAStrategy 2] [MNQ 12-21] Cancel OLD entry limit Order

    [TRADE][09/21/2021 08:16:00 AM][ALQUIMIAStrategy 2] [MNQ 12-21] Cancel OLD entry limit Order

    [TRADE][09/21/2021 08:16:00 AM][ALQUIMIAStrategy 2] [MNQ 12-21] Cancel OLD entry limit Order

    [TRADE][09/21/2021 08:16:00 AM][ALQUIMIAStrategy 2] [MNQ 12-21] Cancel OLD entry limit Order

    [TRADE][09/21/2021 08:16:00 AM][ALQUIMIAStrategy 2] [MNQ 12-21] Cancel OLD entry limit Order

    [TRADE][09/21/2021 08:16:00 AM][ALQUIMIAStrategy 2] [MNQ 12-21] Cancel OLD entry limit Order

    THIS MESSAGE CONTINUE TO GOES FOREVER.

    Here is how my cancel orders is coded:

    #region Trade Settings
    //if (IsFirstTickOfBar)
    if (Steps != 0 | IsFirstTickOfBar)
    {
    Print(string.Format("[ALQUIMIAStrategy 2][{0}] Bar count Abv/Bel 200EMA: {1}, EMA20-EMA200: {2}, EMA200: {3}, slope200ma: {4}, BarsSinceExit: {5} Day Sess: {6}, Aft Sess: {7}, Steps: {8}",
    Time[0].ToString(format), Counter200[0], Math.Round((EMA20[0] - EMA200[0]),3), ema200, Math.Round(slope200ma, 2), BarsSinceExitExecution(), InDaySession, InAftSession, Steps));
    }

    // cancel old limit entry orders
    if (entryOrder != null && CurrentBar > EntryIndex + BarsToKeepRestingOrders
    || (entryOrder != null && Close[0] < PriceLong - 15 && entryOrder.Name == "LongMarketEntry" )
    || (entryOrder != null && Close[0] > PriceShort + 15 && entryOrder.Name == "ShortMarketEntry"))
    {
    Print(string.Format("[TRADE][{0}][ALQUIMIAStrategy 2] [{1}] Cancel OLD entry limit Order", Time[0].ToString(format), Instrument.FullName));
    Print("");
    CancelOrder(entryOrder);
    Steps = 0;
    Counter200[0] = 0;
    Counter200[1] = 0;

    THANKS SO MUCH,

    Juan Francisco

    #2
    Hello jfrimondi,

    Thank you for your note.

    When are you resetting entryOrder to null? If you don't reset this to null when the order is cancelled, this would keep being processed. Are you monitoring in OnOrderUpdate for the cancellation and resetting when the order is cancelled?

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hello. Thanks for your quick response.

      This is how my OrderUpdate region is coded:

      #region Order Update
      protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string nativeError)
      {
      // check if the current order matches the orderName passed in "EnterLong"()
      // Assign entryOrder in OnOrderUpdate() to ensure the assignment occurs when expected.
      // This is more reliable than assigning Order objects in OnBarUpdate, as the assignment is not guaranteed to be complete if it is referenced immediately after submitting
      if (order.Name == "LongMarketEntry" || order.Name == "ShortMarketEntry")
      entryOrder = order;

      // if entry order exists
      if (entryOrder != null && entryOrder == order)
      {
      if ( order.OrderState == OrderState.Filled) // order.OrderState == OrderState.Cancelled ||
      {
      Steps = 0;
      Print("Entry order Filled : " + Steps);
      // Do something here
      entryOrder = null;
      }

      Can you give me an example of resetting order tu null, please? Thanks again

      Comment


        #4
        Hello jfrimondi,

        Thank you for your reply.

        You've got the bit where it would check if the order was cancelled commented out there. So do this instead:

        // if entry order exists
        if (entryOrder != null && entryOrder == order)
        {
        if ( order.OrderState == OrderState.Filled)
        {
        Steps = 0;
        Print("Entry order Filled : " + Steps);
        // Do something here
        entryOrder = null;
        }
        else if (order.OrderState == OrderState.Cancelled)
        {
        Print("Entry order cancelled");
        entryOrder = null;
        }
        }

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          I believe that the issue was fixed! Thanks so much.

          Regards,

          JFR

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by strategist007, Today, 07:51 PM
          0 responses
          3 views
          0 likes
          Last Post strategist007  
          Started by StockTrader88, 03-06-2021, 08:58 AM
          44 responses
          3,969 views
          3 likes
          Last Post jhudas88  
          Started by rbeckmann05, Today, 06:48 PM
          0 responses
          5 views
          0 likes
          Last Post rbeckmann05  
          Started by rhyminkevin, Today, 04:58 PM
          4 responses
          58 views
          0 likes
          Last Post dp8282
          by dp8282
           
          Started by iceman2018, Today, 05:07 PM
          0 responses
          6 views
          0 likes
          Last Post iceman2018  
          Working...
          X