• 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

Target Order of OCO orders continues to execute instead of being canceled.

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

    Target Order of OCO orders continues to execute instead of being canceled.

    Orders are created and executed as follows
    1. Entry order for 100 shares is fully filled.
    2. Once filled, a pair of orders is created for 50 of the shares. One of the orders is a stop order and one is a limit order. They are paired with an OCO. A second stop order is created for the other 50 shares.
    3. The limit order partially fills (say 5 shares) and then the stop order fills for the remaining. The other stop order also fills completely. The account goes to a position of 0.
    4. The limit order goes to a state of accepted, then cancel submitted, but then proceeds to go to a state of working, partially filled and filled. It then fills for some remaining amount of the shares.

    This has happened 3 times so far in testing with a simulation account using live market data. I have yet to be able to reproduce it via market replay of the live data.



    #2
    Hello ntbone,

    Thank you for the post.

    From the provided details nothing specific sticks out which may be the problem. If you are able to produce a simplified example of the logic you are using and the steps to see the problem, we can take a closer look into that case.

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

    Comment


      #3
      This continues to happen during live trading, but never reproduces when testing the specific problematic trades on playback. The playback timing/filling must be slightly different from a live feed. It happens about the same way every time.
      1. A limit and stop order are paired together as an OCO
      2. The limit/stop both partially fill until the position is closed.
      3. The limit order goes from "cancel submitted" to "working" and then to "Partially filled" and finishes filling out instead of canceling.
      I have a filtered log capturing all the events that I can provide by email if that helps at all.

      Comment


        #4
        Hello ntbone,

        Thank you for the reply.

        From reviewing the question again, I can say that it is not suggested to use two targets for a single entry when scaling out of a position. It would likely be suggested to create two entries of 50 quantity each in this case to avoid having two separate exits tied to a single entry. We have a sample using the managed approach which shows the correct way to scale out of a position here: https://ninjatrader.com/support/help...a_position.htm

        For the described use case if you didn't want to submit multiple entries, you would likely need to just use logic and cancel the order which needs to be stopped based on the order events seen by the script.






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

        Comment


          #5
          Can you provide more information as to why I would need to separate out the entry into two pieces? If I were to scale the position to now 200 units instead of 100 would I not possibly seem the same problem again? For every case I have investigated there have been some common attributes.
          • The initial entry order fills in pieces, does not fill all at once.
          • The limit order fills partially
          • The stop order fills the rest.
          • The limit order goes to canceled but doesn't complete.
          If I were to change my units to 200 units and divide up the entry into pieces as you described, I would end up having orders execute with the common attributes above and still see this problem occurring.

          Further, separating them out complicates the code for managing the orders and limits flexibility of future decision making. It is not necessarily known in advance how a given entry might be split up. Conditions could arise that change how the shares would be divided.

          I would like to understand why an OCO order that is canceled goes back to a working state instead of canceling out as it should.

          Comment


            #6
            Hello ntbone,

            The only other details I can provide with the given information is that is the suggestion given in the help guide sample for scaling out of a position. If you are submitting multiple targets for an entry and scaling out, that is what is suggested in the reference sample we provide. There have otherwise not been enough details provided for me to accurately say here. If you can provide a specific sample/steps which demonstrates the problem we can also look further into that. If using oco is otherwise getting in the way of what you are trying to do, that is generally a case which you can instead avoid using oco and use custom logic/the order events instead to handle that use case.


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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rudccv, Today, 08:42 PM
            0 responses
            1 view
            0 likes
            Last Post rudccv
            by rudccv
             
            Started by Newtrader101, Today, 03:54 PM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_ShawnB  
            Started by williamzz, Today, 03:28 PM
            0 responses
            7 views
            0 likes
            Last Post williamzz  
            Started by Robert87, Today, 11:07 AM
            0 responses
            14 views
            0 likes
            Last Post Robert87  
            Started by phta123, Today, 10:24 AM
            0 responses
            17 views
            0 likes
            Last Post phta123
            by phta123
             
            Working...
            X