• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    Patrick H.NinjaTrader Customer Service

    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.
        			}
        		}
        Patrick H.NinjaTrader Customer Service

        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 uiwislth, Yesterday, 11:25 PM
          0 responses
          4 views
          0 likes
          Last Post uiwislth  
          Started by Steve L, Yesterday, 10:04 PM
          0 responses
          3 views
          0 likes
          Last Post Steve L
          by Steve L
           
          Started by marianfed, Yesterday, 09:47 PM
          0 responses
          5 views
          0 likes
          Last Post marianfed  
          Started by hir04068, Yesterday, 09:29 PM
          0 responses
          4 views
          0 likes
          Last Post hir04068  
          Started by iq200, 03-11-2018, 07:49 PM
          24 responses
          1,022 views
          0 likes
          Last Post mrlucky1x  
          Working...
          X