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

Order Submit & Fill

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

    Order Submit & Fill

    so far I've found NinjaScript really good to develop trading strategies (probably the best) but is there any way to simulate the realities e.g. let say I want to see how my code handles the following ...

    when certain conditions exist, I want to submit a long stop limit order *(liveuntilcancelled) for 4 contacts but instead of 4 simultaneous fills , I get:

    1st contract filled at 13:45:05
    2nd contract filled at 13:45:06
    3rd contract filled at 13:45:07
    4th contract filled at 13:45:08

    with further action taking place down stream after each fill.

    iis there a way to simulate this, if not what's the best way to code it?​
    Last edited by dibDab; 12-08-2022, 10:38 AM.

    #2
    Hello dibDab,

    There isn't a way to code how the Simulation Engine fills orders in real-time or the Backtest engine fills orders in historical.

    There is an option to enforce real-time partial fills on the Simulation Engine, however you do not get control of how those orders are part filled.


    Instead, submit 4 separate orders.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      good enough for me, thanks.

      is there an easy way to code an order submit (qty=4) as order submit (qty=1) x 4 times with a 1 second delay?

      don't need to code it for me but any advise or tips would help.
      Last edited by dibDab; 12-08-2022, 11:15 AM.

      Comment


        #4
        do I have this right?

        when using conditional orders and a live broker I run the risk of partial fills. If I submit myOrder (qty=4), this results in OnOrderUpdate events (where I can store myOrder = order) and later possibly 4 partial fill OnExecutionUpdate events.

        further ... if execution also submits exit orders (e.g. stoploss and target)

        should I submit my exit orders with partial qty on each partial fill?

        re. your comment above "Instead, submit 4 separate orders." to try and test this.

        if I repeat my entry order 4 times qty=1, I only get one signal qty=1, does that sound right?

        if it is then if the stoploss is repeated 4 times, will they also be ignored?.

        hoping this is not how it works, otherwise I need to find another way to handle partial fills?
        Last edited by dibDab; 12-09-2022, 07:02 AM.

        Comment


          #5
          Hello dibDab,
          is there an easy way to code an order submit (qty=4) as order submit (qty=1) x 4 times with a 1 second delay?
          You could add a 1 second series with AddDataSeries(), and call an order method on each update of OnBarUpdate() and incrementing a counter integer, until the counter is 4.

          You could also use a timer in realtime. This would not work historically.
          when using conditional orders and a live broker I run the risk of partial fills.
          NinjaTrader does not support conditional brokerage side orders. All orders with a quantity of greater than 1 are subject to partial fills. A high volume market is less likely to experience partial fills.
          If I submit myOrder (qty=4), this results in OnOrderUpdate events (where I can store myOrder = order) and later possibly 4 partial fill OnExecutionUpdate events.
          Yes, orders will trigger OnOrderUpdate() as the order updates. Yes, you can assign the order object to a variable in OnOrderUpdate(). Yes, 4 partial fills would result in OnExecutionUpdate() updating 4 times for each execution.
          further ... if execution also submits exit orders (e.g. stoploss and target)
          You can submit exit stop and limit orders in OnOrderUpdate(), OnExecutionUpdate(), OnBarUpdate(), or in any method.
          The sequence of these is not guaranteed, so we recommend putting all logic in OnOrderUpdate() or all logic in OnExecutionUpdate() but not mixing logic between the two.
          should I submit my exit orders with partial qty on each partial fill?
          You could do that in OnExecutionUpdate(). You would need to update the exit stop and limit order quantities on each part fill. As those can be rapid you would also need to be ready to handle unable able to change order errors. Further some brokerages do not allow orders using OCO to be modified, so you may have to cancel the exits and resubmit them instead.
          It's a lot easier to use separate entries with smaller quantities to avoid part fills altogether.
          if I repeat my entry order 4 times qty=1, I only get one signal qty=1, does that sound right?
          I would recommend you using 4 different unique signal names for the 4 entry orders and attach the exit orders from entry signal to the entries signal name.
          if it is then if the stoploss is repeated 4 times, will they also be ignored?.
          If an order is submitted with the same signal name as an order that is already working, the existing order is updated instead of a new order being submitted.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            thank you, I'm always impressed by the details is your response.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by lightsun47, Today, 03:51 PM
            0 responses
            2 views
            0 likes
            Last Post lightsun47  
            Started by 00nevest, Today, 02:27 PM
            1 response
            8 views
            0 likes
            Last Post 00nevest  
            Started by futtrader, 04-21-2024, 01:50 AM
            4 responses
            41 views
            0 likes
            Last Post futtrader  
            Started by Option Whisperer, Today, 09:55 AM
            1 response
            13 views
            0 likes
            Last Post bltdavid  
            Started by port119, Today, 02:43 PM
            0 responses
            8 views
            0 likes
            Last Post port119
            by port119
             
            Working...
            X