Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

cancel an order not filled after 30 secondes

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

    cancel an order not filled after 30 secondes

    Hi

    i'm running a strategy on 5 minutes close and i would like to cancel my entryorder if it is not filled after 30 secondes.

    How can i do this ?

    i know the method to cancel the order after x number of bar, but here this is a different approached... i'm running in 5 minutes and i want to cancel it after 30 secondes.

    #2
    Hello Thomas79,

    Thank you for your post.

    This would require adding another bar series such as the 30 seconds bar type and setting your strategy to CalculateOnBarClose = False and use the FirstTickOfBar to calculate your 5 minute bar close conditions.

    For information on using CalculatOnBarClose = False and FirstTickOfBar please visit the following link: http://www.ninjatrader.com/support/f...ad.php?t=19387

    For information on using multiple time frames in your code please visit the following link: http://www.ninjatrader.com/support/h...nstruments.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      quite complicated... it'a pity that

      elseif (entryOrder != null && CurrentBar > barNumberOfOrder + 0.1)
      {
      CancelOrder(entryOrder);
      }

      does not work.

      0.1 = 30 secondes within a 5 minutes bars...

      Comment


        #4
        Hello Thomas79,

        Thank you for your response.

        That would not work as the OnBarUpdate() is called on the close of the 5 minute bar as you currently have it set up. You would need to to use something like the following:
        Code:
                protected override void Initialize()
                {
        			Add(PeriodType.Second, 30);
        			CalculateOnBarClose = true;
                }
        		
        		protected override void OnBarUpdate()
        		{	
        			if(BarsInProgress == 0)
        			{
        				//Process items on 30 seconds close.
        			}
        			if(BarsInProgress == 1)
        			{
        				//Process items on the 5 minute close.
        			}
        		}

        Comment


          #5
          Originally posted by Thomas79 View Post
          Hi

          i'm running a strategy on 5 minutes close and i would like to cancel my entryorder if it is not filled after 30 secondes.

          How can i do this ?

          i know the method to cancel the order after x number of bar, but here this is a different approached... i'm running in 5 minutes and i want to cancel it after 30 secondes.
          As you are not working with COBC = false, you will have to use a different event handler that runs independently of OnBarUpdate(). OnMarketData() comes to mind.
          1. You will have to record the time of the order,
          2. then use OnExecution() to set a flag if the order is filled,
          3. then use OnMarketData() to cancel the order, if the flag is not set.

          Alternatively, you could cancel the order if Position.MarketPosition is still MarketPosition.Flat; in which case you do not need the tracking from OnExecution().
          Last edited by koganam; 04-30-2014, 06:18 AM.

          Comment

          Latest Posts

          Collapse

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