Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OCO Order Handling issue

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

    OCO Order Handling issue

    Hi,

    · I’ve implemented OnOrderUpdate() and OnExecution() for handling the my Stop/Limit.
    · I only use “ExitLongStop” & “ExitLongLimit” in this strategy.




    o My Logic in OnExecution:
    1. If a new/cumulate Order filled or partially filled then I place a Limit and Stop order for the total Position Quantity.
    2. If the Limit or the Stop order filled or partially filled then I need t o make sure I cancel the other order (Limit or Stop).
    3. Using “ExitLongStop” & “ExitLongLimit” with parameter “LiveUntilCancel” set to true.

    o My Logic in OnOrderUpdate:
    1. If my order name “MyStopOrder” or “MyLimitOrder” with OrderState = “PendingSubmit” then add then to my token collection.
    2. If the Order state is “Cancelled , Filled or Rejected” remove it from my token collection and Reset Flat.

    o My Logic in OnBarUpdate:
    1. Entry orders…
    2. Exit orders…
    3. Modify the target price via “ExitLongLimit” if some of the indicators values changed and no new entry or exit at this bar.
    4. I modify the Limit /Stop order for almost on each bar.

    o My problems are:
    1. These “ExitLongStop” & “ExitLongLimit” do not automatically set “OCO” types orders. So I’ve implemented calling CancelOrder(oStop/oLimit) to cancel the opposite side of the order manually. But this is not working!!
    2. May be I need to implement “ExitLongStopLimit” instead of the above? Please advice.
    3. In real-time: Once the Limit / Stop hit there is always one limit/stop not cancelled. (Please note: in Historical mode all looks ok, I checked the order/execution history)
    4. Is there a way to set OCO for “ExitLongStop” & “ExitLongLimit”?
    5. What is the best way to implement “Stop & Limit” with OCO?
    o Thank you.

    Samuel M.
    (Lifetime licence user)

    #2
    Hi sammano,

    One way to automatically get OCO stops and targets is to use the Set() methods for your order generation - http://www.ninjatrader-support.com/H...verview36.html

    If this is not an option for you, I would recommend following your strategy in realtime with TraceOrders = True in the Initialize() (http://www.ninjatrader-support.com/H...aceOrders.html) and see where the 'false' order placement occurs and for what reason.

    Comment


      #3
      Thank you for the prompt reply.

      I cannot use Set() methods for many reasons!
      So I have to debug & trace order state. I will try.

      Alternatively, if I replace these “ExitLongStop” & “ExitLongLimit” with "ExitLongStopLimit" will it automatically create OCO order?

      Will the orders handled in the same way with simulation data feed as the real-time data?

      Comment


        #4
        Hi sammano,

        No, only the Set() orders will do this. Please also make sure you review this link here, since OCO behavior depends also on your realtime broker connection - http://www.ninjatrader-support2.com/...ead.php?t=5349

        Yes, the handling is the same, since you will be using the internal simulation engine for fills...realtime fills can and will vary because it is not possible to predict the real market behavior at different price levels and their queues.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        574 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        332 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X