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

Account.Submit for orders, OCO and Partial Fill

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

    Account.Submit for orders, OCO and Partial Fill

    Consider the following scenario for this discussion.
    1. Entry order is placed long with a quantity of 100 and filled.
    2. A limit order and stop order is created after being filled. The limit order is for a quantity of 50, and the stop order is created as a quantity of 100. They are both part of the same OCO group.
    3. The limit order is now partially filled, say with a fill quantity of 10.
    Executing the above scenario using the API's in Account class, or executing using the chart trader is providing the same results. Testing was performed using live market data and a simulation account.

    As the limit order is partially filled, the stop order quantity adjusts. The stop order quantity adjusts as a percent. After step 3, the limit order will now be for 40, as expected, but the stop order will now be for 80.

    If the instrument then moves to stop out the rest of the order, there will be a quantity of 10 left unfilled.

    If the above scenario is executed via code, code in the ExecutionUpdate event handler for Account could adjust the stop order to make sure it will close out the position and not leave the 10 shares hanging. The code however will be running on the users computer, and not at the broker. This leads to the following questions.

    Is the OCO mechanism for orders handled completely locally and not by the broker?

    #2
    Hello ntbone ,

    OCO handling varies depending on the broker being used and settings chosen. In some situations you have the option to enable local OCO when configuring a connection such as the NinjaTrader brokerage. Other connections which default to local OCO will present a warning when configuring the connection that OCO is being simulated, other connections may use server side OCO.



    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks.

      What is the best way to override NinjaTrader's OCO behavior?

      I have some code that is attempting to update the stop orders with the desired quantity changes, but the default OCO behavior for simulation accounts is still applying its changes first. I am not sure when it applies it so timing seems important, otherwise its possibly my changes could be overridden but it would also be nice to not have that extra redundant change.

      Comment


        #4
        Hello ntbone,

        You cannot change the behavior of OCO, this is controlled internally or by the broker depending on the situation/connection used. If you want to do something other than what the default OCO handling does, you would need to not use OCO and just use logic of your own to control your targets.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by elirion, Today, 01:36 AM
        0 responses
        0 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by gentlebenthebear, Today, 01:30 AM
        0 responses
        2 views
        0 likes
        Last Post gentlebenthebear  
        Started by samish18, Yesterday, 08:31 AM
        2 responses
        9 views
        0 likes
        Last Post elirion
        by elirion
         
        Started by Mestor, 03-10-2023, 01:50 AM
        16 responses
        389 views
        0 likes
        Last Post z.franck  
        Started by rtwave, 04-12-2024, 09:30 AM
        4 responses
        31 views
        0 likes
        Last Post rtwave
        by rtwave
         
        Working...
        X