• 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 PrimoItch, Today, 04:35 PM
      0 responses
      3 views
      0 likes
      Last Post PrimoItch  
      Started by Serge A, Today, 04:03 PM
      0 responses
      3 views
      0 likes
      Last Post Serge A
      by Serge A
       
      Started by horace chow, Today, 04:00 PM
      0 responses
      2 views
      0 likes
      Last Post horace chow  
      Started by JBTrader2005, Today, 03:57 PM
      0 responses
      2 views
      0 likes
      Last Post JBTrader2005  
      Started by Austiner87, Yesterday, 09:29 PM
      1 response
      18 views
      0 likes
      Last Post NinjaTrader_Kate  
      Working...
      X