• 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 Tradarr, Today, 06:25 PM
      2 responses
      13 views
      0 likes
      Last Post Tradarr
      by Tradarr
       
      Started by cocopod, Today, 04:47 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_JoshG  
      Started by digibob, Today, 02:47 AM
      2 responses
      14 views
      0 likes
      Last Post NinjaTrader_Kate  
      Started by mntemel, Today, 03:31 PM
      4 responses
      23 views
      0 likes
      Last Post mntemel
      by mntemel
       
      Started by mrlucky1x, Today, 03:14 PM
      2 responses
      7 views
      0 likes
      Last Post mrlucky1x  
      Working...
      X