Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Updating OCO order quantity after partial and complete fill with CreateOrder?

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

    Updating OCO order quantity after partial and complete fill with CreateOrder?

    Hello there Ninjas!

    I am trying to accomplish the following:
    • If the order is completely filled, create an OCO immediately with stop loss and profit targets.
      • I have this accomplished using CreateOrder and then Submit but how to accomplish the next 2 points?
    • If the order is PARTIALLY filled, create an OCO immediately with stop loss and profit targets.
      • Then update the quantities of the OCO set once the order is completely filled to match the proper size?

    Had a few issues before where the order was only partially filled and therefore just sitting there without any risk management and looking for a solution so that there is always an OCO with accurate sizes no matter what.

    Thank you kindly!

    #2
    Well, that's where your programming and logic skills come in.

    Right?

    My suggestion:
    What you need to do is write an outline of what needs to happen
    in your code, these simple English statements are what most
    programmers call pseudo coding.

    For example,

    Code:
      if Entry order is PARTFILLED or FILLED then
        if Target and Stop orders DO NOT EXIST then
            create Target and Stop orders as OCO pair
        else
            update Target and Stop orders w/new Quantity
        endif
      endif
    Btw, it sounds like you are using the <Account>.CreateOrder
    method, is that correct?

    To update the target and stop orders, use <Account>.Change.

    You should realize that order management logic is practically non
    existent using those routines, thus you are faced with writing a lot
    of order management code your self. You could reduce that burden
    considerably by using a Managed or Unmanaged Strategy.

    My point is:
    You are treading in some very deep waters where advanced C#
    programming skills and tons of experience are extremely useful.

    Good luck!

    Last edited by bltdavid; 11-14-2021, 08:55 PM.

    Comment


      #3
      Hello focus333,

      I notice this is in general development and not strategy development on the forums.

      I'm thinking this implies you are using the Addon approach.

      Below is a link to an example of placing a stop and target using the Addon approach.


      If you were instead making a NinjaScript Strategy, and intended to post in the Strategy Development section of the forums, below is a link to examples of stops and targets with NinjaScript Strategies.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thank you both so much for your input, I was able to get it done!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        368 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X