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

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 andrewtrades, Today, 04:57 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        3 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        7 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X