• 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

CancelOrder() unmanaged approach

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

    CancelOrder() unmanaged approach

    Hi All:

    In my strategy I use an unmanaged approach to check if my order has been filled and to limit the number of trades per bar. Below is a snippet..

    private IOrder entryOrder = null;

    protected override void OnBarUpdate()

    {

    entryOrder = EnterLongLimit(0, true, DefaultQuantity, bidPrice, "MyStrategyOrder");

    }

    protected override void OnExecution(IExecution execution)
    {

    // Check if Order is Filled or Partially Filled
    if (entryOrder != null && entryOrder == execution.Order)
    {
    thisBarTrades++;
    }


    If this working order is not filled, I would like to cancel the order after X amount of bars. I viewed examples of cancelling orders in the MANAGED APPROACH, but how does one cancel a working order in an unmanaged approach?

    Thanks in advance

    #2
    geekodude, it would be the same as in managed, using the IOrder you wish to cancel in the dedicated CancelOrder() method. In your snippet you are in managed still, with your Enter() method call. Unmanaged would be using the SubmitOrder method then for trade entry.

    http://www.ninjatrader.com/support/h...er_methods.htm
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand, thanks for the quick reply.

      After literally sleeping on this problem last night, the solution is to define & set these variables:

      private IOrder entryOrder = null;
      private IOrder MyCancelOrder = null;

      protected override void OnBarUpdate()

      {

      entryOrder = EnterLongLimit(0, true, DefaultQuantity, bidPrice, "MyStrategyOrder");
      MyCancelOrder = entryOrder;

      }

      And from the documentation Ninjatrader provides on how to cancel an order after X amount of bars in the Managed Approach here

      http://www.ninjatrader.com/support/h...er_methods.htm

      I was able to cancel an existing order in OnBarUpdate() and limit the number of trades per bar using OnExecution(IExecution execution)

      WOW!
      Last edited by geekodude; 04-24-2014, 10:31 AM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by TazoTodua, Today, 12:21 AM
      0 responses
      7 views
      0 likes
      Last Post TazoTodua  
      Started by U0000999, Today, 12:20 AM
      0 responses
      7 views
      0 likes
      Last Post U0000999  
      Started by sidviciousX, Yesterday, 06:47 AM
      1 response
      21 views
      0 likes
      Last Post bltdavid  
      Started by Mykro, Yesterday, 10:22 PM
      0 responses
      7 views
      0 likes
      Last Post Mykro
      by Mykro
       
      Started by rudccv, Yesterday, 08:42 PM
      0 responses
      6 views
      0 likes
      Last Post rudccv
      by rudccv
       
      Working...
      X