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

LiveUntilCancelled - how to modify orders

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

    LiveUntilCancelled - how to modify orders

    With LiveUntilCancelled true

    to modify orders, is it enough to use the EnterLongLimit(0, true, DefaultQuantity, entryPrice, "live until cancelled long");
    or it needs to be explicitly cancelled.
    In other words if I keep submitting
    EnterLongLimit(0, true, DefaultQuantity, entryPrice, "live until cancelled long");
    without cancelling I will end up in creating a queue of many pending orders?


    Thank You.
    G

    #2
    Originally posted by giogio1 View Post
    With LiveUntilCancelled true

    to modify orders, is it enough to use the EnterLongLimit(0, true, DefaultQuantity, entryPrice, "live until cancelled long");
    or it needs to be explicitly cancelled.
    Modifying an existing order doesn't cancel the existing order.

    In this case, because this is Managed mode, modifying the existing order means you re-issue the EnterLongLimit(0, true, ...) with the exact same SignalName but the LimitPrice or Quantity is different than what exists in the current order.

    If you cancel the order first (which you can if you want to) and call EnterLongLimit(0, true, ...) again with the exact same SignalName, LimitPrice, and Quantity as the order that was previously cancelled, well, you can do that, too. But the 2nd order will be different, meaning the OrderId and reference to the returned IOrder object will be different.

    Originally posted by giogio1 View Post
    In other words if I keep submitting
    EnterLongLimit(0, true, DefaultQuantity, entryPrice, "live until cancelled long");
    without cancelling I will end up in creating a queue of many pending orders?
    No, if you call EnterLongLimit(0, true, ...) and the Quantity, LimitPrice, and SignalName are all the exact same as an existing order, NinjaTrader will effectively(*) do nothing.

    (*) NinjaTrader will either 1) do nothing, because it sees there is logically nothing to change in the existing order or 2) send the order to your broker (which means you will see OrderState updated to PendingChange) at which point it will be your broker's system that will decide there is logically nothing to change in the existing order.

    Whether #1 or #2 happens depends upon if you are backtesting, market replay, Sim101, or connected to a live account with real-time data.

    -=o=-

    In my opinion, you should always collect the returned IOrder reference returned by EnterLongLimit() and use that to identify the IOrder object when you see it again in OnOrderUpdate() and OnExecution().
    Last edited by bltdavid; 09-03-2018, 11:34 PM.

    Comment


      #3
      Thanks for your post giogio1, and thanks for your response bltdavid!

      If you use the same Signal Name with the Managed Approach's order methods and the order already exists, it will be updated (changed if necessary.)

      If you are submitting orders with LiveUntilCancelled set to true, then the orders will stay alive until the TIF is reached or a CancelOrder() is submitted on the order object.

      For the thread's reference, I've included links to the Advanced Order Handling section of the help guide and a link to the SampleOnOrderUpdate Strategy which demonstrates how order objects and CancelOrder() can be used further.

      Advanced Order Handling - https://ninjatrader.com/support/help...r_handling.htm

      SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

      Please let us know if you have any additional questions.
      JimNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bortz, 11-06-2023, 08:04 AM
      47 responses
      1,606 views
      0 likes
      Last Post aligator  
      Started by jaybedreamin, Today, 05:56 PM
      0 responses
      8 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      18 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      4 views
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      13 views
      0 likes
      Last Post Javierw.ok  
      Working...
      X