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

OCO Orders cancelling at bar close

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

    #16
    Hello Paco0,

    Can the behavior be reproduced on Playback if you download a day of ES 12-19 data from the NinjaTrader Market Replay Servers?

    With Immediately submit selected without the Synchronize account, would need the account manually synchronized to the position of the account. Other wise these will be out of sync.

    However, I would not expect this to cause an exit order's total filled quantity to be different than the entry order's total filled quantity.

    The issue looks like there was an execution from the last part fill that was not processed.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      Hi ChelseaB,

      I could not reproduce the issue with ES 12-19 market replay and Playback101 account (Sim101 was not available in selection). I don't think the strategy conditions will ever be met with that instrument. What I noticed today is that whenever there is a partial stoploss order fill followed by stop order cancellation (which is not correct behavior) strategy Sync status goes from "true" to "false". When I Synchronize the strategy manually at that point, a market sell order is submitted to my broker for the remaining quantity of cancelled stop order - does that help in identifying the possible cause?

      I have the market replay recording enabled now although I am not sure if it will be possible to export the replay and provide it to you for testing on your side..
      Tomorrow I will try to set the primary data series to 150 ticks instead of 1 tick I am using now and change the start behavior to see if it has any impact (ruling out network/latency issues with 1 tick updates perhaps? I am just guessing at this point..)
      Other than that, I am running out of ideas and this issue will cause the NT to be not usable for me as not having protective orders behaving correctly is a big risk for my algo trading.

      Again, I really appreciate your continuous support.

      Comment


        #18
        Hello Paco0,

        When connected to the Playback connection orders will be placed to the Playback101 account. This will be the only account available.

        Are you able to reproduce with any future or forex instrument with Market Replay data?

        Can you reproduce using an equity in Playback with historical tick data?

        I'm wanting an instrument, bar type, date, and time where I can run this script and reproduce the behavior on my end.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          Hi ChelseaB,

          I'm very happy (and relieved) to tell you that this issue seems to have disappeared when I restricted Set orders to BIP == 1 (I really really don't understand why and how).
          May I have two additional question please -

          1. I took a sample NT multi-timeframe strategy code screenshot - what happens if I move BIP condition from where it is to empty red box? Does it impact sma calculation in some way? I would expect it does not if I am explicitly calling BarsArray[1] or BarsArray[2] in indicator calculation.

          2. I don't use primary dataseries [0] anywhere in my code. If I set CalculateOnBarClose = false and Calculate.OnPriceChange, does it matter what primary [0] dataseries is going to be in real-time trading (not in backtest)? I would expect that it should not matter whether I select 1min or 2min dataseries as primary [0] dataseries, as I should be getting the same values for indicators calculated based on say [1] dataseries with my Calculate settings, regardless of primary dataseries selected. Could it impact values which are being printed perhaps? I noticed that Timestamp print is always incremented in minutes when I select 1min as primary [0] dataseries for example and I am not sure what values would be displayed for example for indicator that is calculated based on [1] series.

          Thank you.


          Comment


            #20
            Hello Paco0,

            Moving the return for all BarsInProgress other than 0 above the variable assignments would cause those variables to only be assigned if the primary series is processing. The variables would not be assigned for any other BarsInProgress.

            Calculate set to On price change would cause OnBarUpdate to trigger in real-time for all series.

            This means that OnBarUpdate will trigger after every price change for every series added to the chart instead of waiting for the bar to close for each series.

            Indicator values would also be updating in real-time for every price change for the series supplied to the indicator instead of waiting for the bar to close.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              Hi ChelseaB,

              I have observed the same behavior with incorrect order quantities submitted to IB using Managed order approach for over a month now since I opened this topic. I suspect that IB and NT are not exchanging Order status updates correctly. I observed that quantities are not always updated incorrectly, it seems it happens only on partial fills when fills are too fast and maybe NT and IB are not able to exchange the information as fast as it would be necessary. Here is another example from today:

              Date: 12/26/2019
              Time: 9:46am (16 minutes after market open)
              Instrument: NLNK
              Limit order entered (and filled) quantity: 2059 shares (Using EnterLongLimit)
              Stoploss quantity submitted: 100 shares (using managed approach Set... function)
              Profit target quantity submitted: 100 shares (using managed approach Set... function)

              Order object print is attached. Also attached is the error message I sometimes get when OCO orders are submitted with incorrect quantities.
              Thanks for your help.



              Attached Files

              Comment


                #22
                Hello Paco0,

                If you would like our technicians to review log and trace files, please send an email to platformsupport [at] ninjatrader [dot] com.

                The Managed approach only has OCO available with Set methods like SetProfitTarget/SetStopLoss.

                The information in text file you have provided is not using OCO.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #23
                  Hi ChelseaB,

                  I am using SetProfitTarget and SetTrailStop in combination with EnterLongLimit. Content of the file I have provided was generated today using methods I mentioned in this post. Is SetTrailStop not part of the Managed Approach or what do you mean by your post?

                  Comment


                    #24
                    Hello Paco0,

                    Ah, I see the orders you are referring to using the OCO Ids oco='NLNK/0000e22a.5e047010.01.01'.

                    This does show these two orders are submitted.


                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #25
                      Hi ChelseaB,

                      Orders were submitted indeed, but the OCO orders quantities did not match the entry order total filled quantity, that is the issue. It causes the strategy to go to "false" Sync status and there is nothing I can do about it as I understand Managed approach logic is managed by NT team. When I purchased the NT software, I did not expect that the standard functionality offered in the package was not going to work as it should. I hope this can be resolved.

                      Comment


                        #26
                        Hello Paco0,

                        Are you seeing this from printing the order object in updates to OnOrderUpdate()?

                        To report an issue, we would need a reproducible script and the log and trace files showing the issue.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #27
                          Hi ChelseaB,

                          Yes, I am printing this in OnOrderUpdate.

                          Comment


                            #28
                            Hello Paco0,

                            Please include the output from the output window.

                            Right-click the Output window -> select Save As -> give the file a name and save -> attach this to your post.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #29
                              Hi ChelseaB,

                              Please find attached. I print a lot of stuff so I tried to make the file as clean as possible for you, leaving all order updates in the file. Please note the timezone difference (15:45 in the file means 15 min after US market open).
                              Attached Files

                              Comment


                                #30
                                Hello Paco0,

                                To confirm, the issue is that the Buy order filled with a quantity of 2059, and the stop loss and profit target are submitted with a quantity of 100, is this correct?

                                What is the code used to submit the stop loss and profit target?

                                Are these set before the entry order is placed?
                                Chelsea B.NinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by elderan, Today, 08:03 PM
                                0 responses
                                2 views
                                0 likes
                                Last Post elderan
                                by elderan
                                 
                                Started by algospoke, Today, 06:40 PM
                                0 responses
                                10 views
                                0 likes
                                Last Post algospoke  
                                Started by maybeimnotrader, Today, 05:46 PM
                                0 responses
                                9 views
                                0 likes
                                Last Post maybeimnotrader  
                                Started by quantismo, Today, 05:13 PM
                                0 responses
                                7 views
                                0 likes
                                Last Post quantismo  
                                Started by AttiM, 02-14-2024, 05:20 PM
                                8 responses
                                169 views
                                0 likes
                                Last Post jeronymite  
                                Working...
                                X