Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Indicator to cancel new entry

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

    Indicator to cancel new entry

    I am working on make an indicator that cancels the orders before submit to broker after a condition is reached.

    the problem is After I cancel the order, The order will be keep on pending cancel forever. (see the image for reference, the unknown orders was with same problem but I restart the ninja)


    my code is like this:


    // subscribe
    account.AccountItemUpdate += OnAccountItemUpdate;
    account.PositionUpdate += OnPositionUpdate;
    account.ExecutionUpdate += OnExecutionUpdate;
    account.OrderUpdate += OnOrderUpdate;

    .//

    private void OnOrderUpdate(object sender, OrderEventArgs e)
    {
    Print ("On order update");
    if (e.Order != null )
    {
    Print("Orden " + e.Order.Name + " orden id=" + e.Order.OrderId + " state =" + e.Order.OrderState);
    if (account.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar) <= Limit*(-1) && e.Order.OrderState == OrderState.Initialized)
    {
    Print("We are going to cancel the order.");
    Order sa = null;
    sa = e.Order;
    account.Cancel(new[] { sa });
    }
    }
    }



    how I can cancel the new orders before they are sumitted to the broker, for market and limits orders?


    #2
    Hello Jackrpo,

    Generally this type of logic should reside with the script submitting the orders so it can just prevent the order from being sent at all, are you trying to block manual orders from being submitted?

    If you are trying to block manually placed orders, the general suggestion would be to instead create your own order entry tool using an Addon. you could then prevent the manual order from being submitted through your tool by denying the button click. Disabling your tool can be based on your condition rather than trying to cancel an already submitted order.

    If the orders are other script orders, this logic would be best placed in the script its self to control the orders directly. Preventing the order from being submitted at all would be best.

    Another item which can come up with this is that the cancel method is not guaranteed to cancel an order so this would not be suggested for this type of use case or blocking an already submitted order. Cancelling an order simply lets the broker know to cancel the order but it may still fill within that time if it is possible, preventing the order from being submitted to begin with would be suggested instead.


    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello Jackrpo,

      Generally this type of logic should reside with the script submitting the orders so it can just prevent the order from being sent at all, are you trying to block manual orders from being submitted?

      If you are trying to block manually placed orders, the general suggestion would be to instead create your own order entry tool using an Addon. you could then prevent the manual order from being submitted through your tool by denying the button click. Disabling your tool can be based on your condition rather than trying to cancel an already submitted order.

      If the orders are other script orders, this logic would be best placed in the script its self to control the orders directly. Preventing the order from being submitted at all would be best.

      Another item which can come up with this is that the cancel method is not guaranteed to cancel an order so this would not be suggested for this type of use case or blocking an already submitted order. Cancelling an order simply lets the broker know to cancel the order but it may still fill within that time if it is possible, preventing the order from being submitted to begin with would be suggested instead.


      I look forward to being of further assistance.

      Hello Jesse, thanks you so much for your support

      Yes, I am trying to block manual orders from being submitted

      I will check the option to disable the buttons of chart trader.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ScottWalsh, 04-16-2024, 04:29 PM
      6 responses
      27 views
      0 likes
      Last Post ScottWalsh  
      Started by frankthearm, Today, 09:08 AM
      10 responses
      35 views
      0 likes
      Last Post frankthearm  
      Started by GwFutures1988, Today, 02:48 PM
      0 responses
      2 views
      0 likes
      Last Post GwFutures1988  
      Started by mmenigma, Today, 02:22 PM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by NRITV, Today, 01:15 PM
      2 responses
      9 views
      0 likes
      Last Post NRITV
      by NRITV
       
      Working...
      X