Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Overfill default and custom handling - NT7

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

    Overfill default and custom handling - NT7

    Hello,

    I have a fairly complex strategy which uses managed orders. I get occasional overfills in live operation, which are always as a result of my strat calling CancelOrder as the exchange is filling it.

    My problems are twofold. Firstly, the default behaviour is supposed to be stop the strat and attempt to close the position, right? Well, the close is not attempted, meaning the default behaviour is to leave a position on, with no stop (because the strat stops before putting the stop on) and no strat running to handle it. In my opinion that is very dangerous default behaviour.

    I'd be happy to code my own overfill handling, but that means I have to convert my whole strategy to unmanaged, right? Which is a lot of work. And even if I do that, could you please point me at an example of custom overfill handling, since I see nothing in the docs about how to do it.

    thanks
    Dave

    #2
    Dave, I will have someone get back to you on Monday.
    AustinNinjaTrader Customer Service

    Comment


      #3
      @Dave1992


      I would just substitute the existing Managed functions like EnterLong, EnterShort, SetStoppLoss, SetProfitTarget with your own implementation.

      This way you do not have to change your strategies logic.

      There are several options to do this:

      1. Implement all these functions in UserdefinedMethods.cs
      for example
      IOrder EnterLong(){

      returnnull;
      // do your implementation
      }

      This will hide the base class implementation of the Managed Order funtions. Problems could arise from the fact that calls from StrategyBase will still address the NinjaTrader implementation.

      Therefore I suggest to change the new functions name to daveEnterLong()

      and then add the prefix "dave" in your strategies.


      2. You could also define these functions as an extension to class StrategyBase.

      keywords for google: C# class extensions, partial


      regards
      Andreas



      Comment


        #4
        Hi Andreas,

        Thanks for the reply. Do you not have to put a lot of stuff in to check order status, and then do things like cancel your own stops/limits etc. It's not just hide the unmanaged functions is it?

        It would me really nice if I could just set ignore overfill in managed, then I could just check for it and handle it in a still running strategy. What happens if you set ignore overfill in managed?

        Comment


          #5
          dave1992,

          If you set RealtimeErrorHandling to TakeNoAction you will then want to make sure you self program to handle any scenarios that may arise.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            OK, thanks - so if I set that I only have to handle rejected orders?

            I am a little worried though that the default behaviour did not close the position. Is that a bug?

            Comment


              #7
              dave1992,

              Please send in a timestamp and your log/traces as to when you saw this. Please note that it will attempt to close your position and such, but there is no guarantee it will be able to for any number of reasons.

              Setting RealtimeErrorHandling to TakeNoAction means you need to handle everything, not just order rejects. Things like disconnects for instance should be handled in OnConnectionStatus().
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Josh,

                Can you please grab the log/trace off Brett as he already has them.

                Is there a full list of the situations that need to be handled? It would be a shame to miss one.

                thanks
                Dave

                Comment


                  #9
                  Dave,

                  Unfortunately it seems we do not have them anymore and will need them again. Please attach your latest log/traces and the timestamp as to when you experienced the issue.

                  There is no list because it is really dependent on how exactly your strategy is coded and what it might be susceptible to. The general basics that need to be addressed are overfills, disconnects, and order rejects.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Josh,

                    I've emailed you the files.

                    Perhaps there could be a variable for each type of error handling sometime in the future. It's a shame to have to handle all the others just because I need to fix overfills.

                    So how do I replicate the default behaviour for disconnects? Is there a proc I can call from OnConnectionStatus?

                    Comment


                      #11
                      Dave,

                      Based on the log/traces you sent in we have applied a change in an area we suspect to have caused the overfill issue and it should not happen again. Thanks.

                      For the OnConnectionStatus(), it is really up to you how you want to program this. Some people want to try and close positions, some people want to try and leave working orders active and wait for a reconnect, some people want to just stop the strategy right there. So it is up to you how you want to do it.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks Josh,

                        What I mean is, I don't have to handle the trying to reconnect stuff etc, that'll just happen? Essentially I'm happy with the default behaviour and want to add as little code as possible.

                        Comment


                          #13
                          For the simplest behavior you can just disable the strategy on a disconnect.


                          Note that this would still leave open positions open and such and you would need to close those manually if you should desire.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Josh,

                            What I mean is, if I do nothing, will the strat carry on running and reconnect as per the current default behaviour.

                            thanks
                            Dave

                            Comment


                              #15
                              Dave, this will be determined by the ConnectionLoss handling you've set to use, here are possible options for you - http://www.ninjatrader.com/support/h...sshandling.htm

                              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
                              369 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