Announcement

Collapse
No announcement yet.

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.

    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.

        Comment


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

          Regards,

          JFR

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          86 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          151 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          79 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          52 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          59 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X